mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-30 15:58:10 +08:00
core: add bindaddr directive, allowing you to specify what address to listen on
This commit is contained in:
@ -11,6 +11,9 @@ type Config struct {
|
||||
// The hostname or IP on which to serve
|
||||
Host string
|
||||
|
||||
// The address to bind on - defaults to Host if empty
|
||||
BindAddress string
|
||||
|
||||
// The port to listen on
|
||||
Port string
|
||||
|
||||
@ -44,6 +47,9 @@ type Config struct {
|
||||
|
||||
// Address returns the host:port of c as a string.
|
||||
func (c Config) Address() string {
|
||||
if c.BindAddress != "" {
|
||||
return net.JoinHostPort(c.BindAddress, c.Port)
|
||||
}
|
||||
return net.JoinHostPort(c.Host, c.Port)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user