Source File
ip_addr.go
Belonging Package
github.com/quic-go/quic-go/http3
package http3import ()// An addrList represents a list of network endpoint addresses.// Copy from [net.addrList] and change type from [net.Addr] to [net.IPAddr]type addrList []net.IPAddr// isIPv4 reports whether addr contains an IPv4 address.func isIPv4( net.IPAddr) bool {return .IP.To4() != nil}// isNotIPv4 reports whether addr does not contain an IPv4 address.func isNotIPv4( net.IPAddr) bool { return !isIPv4() }// forResolve returns the most appropriate address in address for// a call to ResolveTCPAddr, ResolveUDPAddr, or ResolveIPAddr.// IPv4 is preferred, unless addr contains an IPv6 literal.func ( addrList) (, string) net.IPAddr {var boolswitch {case "ip":// IPv6 literal (addr does NOT contain a port)= strings.ContainsRune(, ':')case "tcp", "udp":// IPv6 literal. (addr contains a port, so look for '[')= strings.ContainsRune(, '[')}if {return .first(isNotIPv4)}return .first(isIPv4)}// first returns the first address which satisfies strategy, or if// none do, then the first address of any kind.func ( addrList) ( func(net.IPAddr) bool) net.IPAddr {for , := range {if () {return}}return [0]}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |