mirror of
https://github.com/genuinetools/reg.git
synced 2024-09-28 11:46:20 -04:00
server: Allow to restrict listen address (#115)
e.g. limit to listen on localhost only
This commit is contained in:
parent
c524001541
commit
b3c826e2e4
2 changed files with 8 additions and 5 deletions
|
@ -219,6 +219,7 @@ Run a static UI server for a registry.
|
||||||
Flags:
|
Flags:
|
||||||
|
|
||||||
-u, --username username for the registry (default: <none>)
|
-u, --username username for the registry (default: <none>)
|
||||||
|
--listen-address address to listen on (default: <none>)
|
||||||
--asset-path Path to assets and templates (default: <none>)
|
--asset-path Path to assets and templates (default: <none>)
|
||||||
-f, --force-non-ssl force allow use of non-ssl (default: false)
|
-f, --force-non-ssl force allow use of non-ssl (default: false)
|
||||||
--once generate the templates once and then exit (default: false)
|
--once generate the templates once and then exit (default: false)
|
||||||
|
|
12
server.go
12
server.go
|
@ -35,6 +35,7 @@ func (cmd *serverCommand) Register(fs *flag.FlagSet) {
|
||||||
|
|
||||||
fs.StringVar(&cmd.cert, "cert", "", "path to ssl cert")
|
fs.StringVar(&cmd.cert, "cert", "", "path to ssl cert")
|
||||||
fs.StringVar(&cmd.key, "key", "", "path to ssl key")
|
fs.StringVar(&cmd.key, "key", "", "path to ssl key")
|
||||||
|
fs.StringVar(&cmd.listenAddress, "listen-address", "", "address to listen on")
|
||||||
fs.StringVar(&cmd.port, "port", "8080", "port for server to run on")
|
fs.StringVar(&cmd.port, "port", "8080", "port for server to run on")
|
||||||
fs.StringVar(&cmd.assetPath, "asset-path", "", "Path to assets and templates")
|
fs.StringVar(&cmd.assetPath, "asset-path", "", "Path to assets and templates")
|
||||||
|
|
||||||
|
@ -48,10 +49,11 @@ type serverCommand struct {
|
||||||
|
|
||||||
generateAndExit bool
|
generateAndExit bool
|
||||||
|
|
||||||
cert string
|
cert string
|
||||||
key string
|
key string
|
||||||
port string
|
listenAddress string
|
||||||
assetPath string
|
port string
|
||||||
|
assetPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *serverCommand) Run(ctx context.Context, args []string) error {
|
func (cmd *serverCommand) Run(ctx context.Context, args []string) error {
|
||||||
|
@ -180,7 +182,7 @@ func (cmd *serverCommand) Run(ctx context.Context, args []string) error {
|
||||||
|
|
||||||
// Set up the server.
|
// Set up the server.
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
Addr: ":" + cmd.port,
|
Addr: cmd.listenAddress + ":" + cmd.port,
|
||||||
Handler: mux,
|
Handler: mux,
|
||||||
}
|
}
|
||||||
logrus.Infof("Starting server on port %q", cmd.port)
|
logrus.Infof("Starting server on port %q", cmd.port)
|
||||||
|
|
Loading…
Reference in a new issue