status-go/vendor/github.com/anacrolix/torrent/url-net-addr.go

27 lines
345 B
Go
Raw Normal View History

2022-03-10 09:44:48 +00:00
package torrent
import (
"net"
"net/url"
)
type urlNetAddr struct {
u *url.URL
}
func (me urlNetAddr) Network() string {
return me.u.Scheme
}
func (me urlNetAddr) String() string {
return me.u.Host
}
func remoteAddrFromUrl(urlStr string) net.Addr {
u, err := url.Parse(urlStr)
if err != nil {
return nil
}
return urlNetAddr{u}
}