Generate a RemoteAddr for webseed Peers
This commit is contained in:
parent
669905e203
commit
955e337b78
|
@ -2114,6 +2114,7 @@ func (t *Torrent) addWebSeed(url string) {
|
|||
reconciledHandshakeStats: true,
|
||||
peerSentHaveAll: true,
|
||||
PeerMaxRequests: maxRequests,
|
||||
RemoteAddr: remoteAddrFromUrl(url),
|
||||
},
|
||||
client: webseed.Client{
|
||||
HttpClient: http.DefaultClient,
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
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}
|
||||
}
|
Loading…
Reference in New Issue