mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-25 09:40:13 +08:00
httpserver: Fix address display and routing for IPv6 IPs/wildcards
This commit is contained in:
parent
8369a12115
commit
f2491580e0
|
@ -428,11 +428,12 @@ func (a Address) String() string {
|
|||
if s != "" {
|
||||
s += "://"
|
||||
}
|
||||
s += a.Host
|
||||
if a.Port != "" &&
|
||||
((scheme == "https" && a.Port != DefaultHTTPSPort) ||
|
||||
(scheme == "http" && a.Port != DefaultHTTPPort)) {
|
||||
s += ":" + a.Port
|
||||
s += net.JoinHostPort(a.Host, a.Port)
|
||||
} else {
|
||||
s += a.Host
|
||||
}
|
||||
if a.Path != "" {
|
||||
s += a.Path
|
||||
|
|
|
@ -32,7 +32,12 @@ type vhostTrie struct {
|
|||
|
||||
// newVHostTrie returns a new vhostTrie.
|
||||
func newVHostTrie() *vhostTrie {
|
||||
return &vhostTrie{edges: make(map[string]*vhostTrie), fallbackHosts: []string{"0.0.0.0", ""}}
|
||||
// TODO: fallbackHosts doesn't discriminate between network interfaces;
|
||||
// i.e. if there is a host "0.0.0.0", it could match a request coming
|
||||
// in to "[::1]" (and vice-versa) even though the IP versions differ.
|
||||
// This might be OK, or maybe it's not desirable. The 'bind' directive
|
||||
// can be used to restrict what interface a listener binds to.
|
||||
return &vhostTrie{edges: make(map[string]*vhostTrie), fallbackHosts: []string{"0.0.0.0", "[::]", ""}}
|
||||
}
|
||||
|
||||
// Insert adds stack to t keyed by key. The key should be
|
||||
|
|
Loading…
Reference in New Issue
Block a user