Skip to content

Commit

Permalink
Update TLS cert flag name
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Aug 9, 2019
1 parent 324cd68 commit 1d62603
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .circleci/run_build_locally.sh
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

curl --user "${CIRCLE_TOKEN}:" \
--request POST \
--form revision=0a042d26a7bdb34291c175d8603dbe8bfb21ad7b\
--form config=@config.yml \
--form notify=false \
https://circleci.com/api/v1.1/project/github/miguelmota/ipdr/tree/master
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -256,25 +256,25 @@ make test

## FAQ

- Q: How can I configure the local registry host or port that IPDR uses when pushing or pulling Docker images?
- Q: How do I configure the local registry host or port that IPDR uses when pushing or pulling Docker images?

- A: Use the `--docker-registry-host` flag, eg. `--docker-registry-host docker.for.mac.local:5000`

- Q: How can I configure the IPFS host that IPDR uses for pushing Docker images?
- Q: How do I configure the IPFS host that IPDR uses for pushing Docker images?

- A: Use the `--ipfs-host` flag, eg. `--ipfs-host 127.0.0.1:5001`

- Q: How can I configure the IPFS gateway that IPDR uses for pulling Docker images?
- Q: How do I configure the IPFS gateway that IPDR uses for pulling Docker images?

- A: Use the `--ipfs-gateway` flag, eg. `--ipfs-gateway https://ipfs.io`

- Q: How can I configure the port for the IPDR registry server?

- A: Use the `--port` flag, eg. `--port 5000`

- Q: How can I use a HTTPS-secured registry when using `server`?
- Q: How do I setup HTTPS/TLS on the IPDR registry server?

- A: Use the `--tlsKeyPath` and `--tlsCrPath` flag, eg. ` --tlsKeyPath path/server.key --tlsCrtPath path/server.crt`
- A: Use the `--tlsKeyPath` and `--tlsCertPath` flag, eg. ` --tlsKeyPath path/server.key --tlsCertPath path/server.crt`

## Contributing

Expand Down
10 changes: 5 additions & 5 deletions cmd/ipdr/main.go
Expand Up @@ -34,7 +34,7 @@ func main() {
var format string
var dockerRegistryHost string
var port uint
var tlsCrtPath string
var tlsCertPath string
var tlsKeyPath string
var silent bool

Expand Down Expand Up @@ -138,10 +138,10 @@ More info: https://github.com/miguelmota/ipdr`,
Long: "Start the IPFS-backed Docker registry server that proxies images stored on IPFS to Docker registry format",
RunE: func(cmd *cobra.Command, args []string) error {
srv := server.NewServer(&server.Config{
Port: port,
Debug: !silent,
Port: port,
Debug: !silent,
TLSKeyPath: tlsKeyPath,
TLSCrtPath: tlsCrtPath,
TLSCrtPath: tlsCertPath,
})

return srv.Start()
Expand All @@ -150,7 +150,7 @@ More info: https://github.com/miguelmota/ipdr`,

serverCmd.Flags().BoolVarP(&silent, "silent", "s", false, "Silent flag suppresses logs")
serverCmd.Flags().UintVarP(&port, "port", "p", 5000, "The port for the Docker registry to listen on")
serverCmd.Flags().StringVarP(&tlsCrtPath, "tlsCrtPath", "", "", "The path to the .crt file for TLS")
serverCmd.Flags().StringVarP(&tlsCertPath, "tlsCertPath", "", "", "The path to the .crt file for TLS")
serverCmd.Flags().StringVarP(&tlsKeyPath, "tlsKeyPath", "", "", "The path to the .key file for TLS")

convertCmd := &cobra.Command{
Expand Down
15 changes: 8 additions & 7 deletions server/server.go
Expand Up @@ -19,17 +19,17 @@ type Server struct {
listener net.Listener
host string
ipfsGateway string
tlsCrtPath string
tlsKeyPath string
tlsCertPath string
tlsKeyPath string
}

// Config is server config
type Config struct {
Debug bool
Port uint
IPFSGateway string
TLSCrtPath string
TLSKeyPath string
TLSCertPath string
TLSKeyPath string
}

// InfoResponse is response for manifest info response
Expand Down Expand Up @@ -63,7 +63,7 @@ func NewServer(config *Config) *Server {
host: fmt.Sprintf("0.0.0.0:%v", port),
debug: config.Debug,
ipfsGateway: ipfs.NormalizeGatewayURL(config.IPFSGateway),
tlsCrtPath: config.TLSCrtPath,
tlsCertPath: config.TLSCertPath,
tlsKeyPath: config.TLSKeyPath,
}
}
Expand Down Expand Up @@ -177,9 +177,10 @@ func (s *Server) Start() error {
}

s.Debugf("[registry/server] listening on %s", s.listener.Addr())
if s.tlsKeyPath != "" && s.tlsCrtPath != "" {
return http.ServeTLS(s.listener, nil, s.tlsCrtPath, s.tlsKeyPath)
if s.tlsKeyPath != "" && s.tlsCertPath != "" {
return http.ServeTLS(s.listener, nil, s.tlsCertPath, s.tlsKeyPath)
}

return http.Serve(s.listener, nil)
}

Expand Down

0 comments on commit 1d62603

Please sign in to comment.