netaddress.go
func NewNetAddress(addr net.Addr) *NetAddress {
	tcpAddr, ok := addr.(*net.TCPAddr)
	if !ok {
		if flag.Lookup("test.v") == nil { // normal run
			cmn.PanicSanity(cmn.Fmt("Only TCPAddrs are supported. Got: %v", addr))
		} else { // in testing
			return NewNetAddressIPPort(net.IP("0.0.0.0"), 0)
		}
	}
	ip := tcpAddr.IP
	port := uint16(tcpAddr.Port)
	return NewNetAddressIPPort(ip, port)
}
func NewNetAddress(addr net.Addr) *NetAddress {
	tcpAddr, ok := addr.(*net.TCPAddr)
	if !ok {
		if flag.Lookup("test.v") == nil { // normal run
			cmn.PanicSanity(cmn.Fmt("Only TCPAddrs are supported. Got: %v", addr))
		} else { // in testing
			return NewNetAddressIPPort(net.IP("0.0.0.0"), 0)
		}
	}
	ip := tcpAddr.IP
	port := uint16(tcpAddr.Port)
	return NewNetAddressIPPort(ip, port)
}
func NewNetAddress ( addr net . Addr ) * NetAddress { tcpAddr , ok := addr . ( * net . TCPAddr ) if ! ok { if flag . Lookup ( " " ) == nil { // normal run cmn . PanicSanity ( cmn . Fmt ( " " , addr ) ) } else { // in testing return NewNetAddressIPPort ( net . IP ( " " ) , 0 ) } } ip := tcpAddr . IP port := uint16 ( tcpAddr . Port ) return NewNetAddressIPPort ( ip , port ) }
// NewNetAddress returns a new NetAddress using the provided TCP
// address. When testing, other net.Addr (except TCP) will result in
// using 0.0.0.0:0. When normal run, other net.Addr (except TCP) will
// panic.
// TODO: socks proxies?
NewNetAddress returns a new NetAddress using the provided TCP address . When testing other net . Addr ( except TCP ) will result in using 0 . 0 . 0 . 0 : 0 . When normal run other net . Addr ( except TCP ) will panic . TODO : socks proxies?