mirror of
https://github.com/caddyserver/caddy.git
synced 2025-12-08 06:09:53 +00:00
check addr type first
This commit is contained in:
parent
dd230be8aa
commit
264e9b7fde
1 changed files with 20 additions and 17 deletions
|
|
@ -357,36 +357,39 @@ func (st *ServerType) listenersForServerBlockAddress(sblock serverBlock, addr Ad
|
||||||
|
|
||||||
lnIfaceAddresses := []string{}
|
lnIfaceAddresses := []string{}
|
||||||
for _, ifaceAddress := range ifaceAddresses {
|
for _, ifaceAddress := range ifaceAddresses {
|
||||||
var addrok, netwok bool
|
var (
|
||||||
|
ip net.IP
|
||||||
var ip net.IP
|
ipok bool
|
||||||
|
)
|
||||||
switch ifaceAddressValue := ifaceAddress.(type) {
|
switch ifaceAddressValue := ifaceAddress.(type) {
|
||||||
case *net.IPAddr:
|
case *net.IPAddr:
|
||||||
ip, addrok, netwok = ifaceAddressValue.IP, true, true
|
ip, ipok = ifaceAddressValue.IP, true
|
||||||
case *net.IPNet:
|
case *net.IPNet:
|
||||||
ip, addrok, netwok = ifaceAddressValue.IP, true, true
|
ip, ipok = ifaceAddressValue.IP, true
|
||||||
case *net.TCPAddr:
|
case *net.TCPAddr:
|
||||||
ip, addrok, netwok = ifaceAddressValue.IP, true, caddy.IsTCPNetwork(lnNetw)
|
ip, ipok = ifaceAddressValue.IP, caddy.IsTCPNetwork(lnNetw)
|
||||||
case *net.UDPAddr:
|
case *net.UDPAddr:
|
||||||
ip, addrok, netwok = ifaceAddressValue.IP, true, caddy.IsUDPNetwork(lnNetw)
|
ip, ipok = ifaceAddressValue.IP, caddy.IsUDPNetwork(lnNetw)
|
||||||
}
|
}
|
||||||
if netwok {
|
|
||||||
netwok = len(ip) == net.IPv4len && caddy.IsIPv4Network(lnNetw) || len(ip) == net.IPv6len && caddy.IsIPv6Network(lnNetw)
|
if ipok {
|
||||||
}
|
if caddy.IsIPv4Network(lnNetw) && len(ip) == net.IPv4len || caddy.IsIPv6Network(lnNetw) && len(ip) == net.IPv6len {
|
||||||
if addrok {
|
|
||||||
if netwok {
|
|
||||||
lnIfaceAddresses = append(lnIfaceAddresses, ip.String())
|
lnIfaceAddresses = append(lnIfaceAddresses, ip.String())
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var name string
|
var (
|
||||||
|
name string
|
||||||
|
nameok bool
|
||||||
|
)
|
||||||
switch ifaceAddressValue := ifaceAddress.(type) {
|
switch ifaceAddressValue := ifaceAddress.(type) {
|
||||||
case *net.UnixAddr:
|
case *net.UnixAddr:
|
||||||
name, addrok, netwok = ifaceAddressValue.Name, true, caddy.IsUnixNetwork(lnNetw)
|
name, nameok = ifaceAddressValue.Name, true
|
||||||
}
|
}
|
||||||
if addrok {
|
|
||||||
if netwok {
|
if nameok {
|
||||||
|
if caddy.IsUnixNetwork(lnNetw) {
|
||||||
lnIfaceAddresses = append(lnIfaceAddresses, name)
|
lnIfaceAddresses = append(lnIfaceAddresses, name)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue