Necessary for a test that expects one connection to each other Client.
PublicIp6 net.IP
DisableAcceptRateLimiting bool
+ dropDuplicatePeerIds bool
}
func (cfg *ClientConfig) SetListenAddr(addr string) *ClientConfig {
if t.closed.IsSet() {
return errors.New("torrent closed")
}
+ for c0 := range t.conns {
+ if c.PeerID != c0.PeerID {
+ continue
+ }
+ if !t.cl.config.dropDuplicatePeerIds {
+ continue
+ }
+ if left, ok := c.hasPreferredNetworkOver(c0); ok && left {
+ c0.Close()
+ t.deleteConnection(c0)
+ } else {
+ return errors.New("existing connection preferred")
+ }
+ }
if !t.wantConns() {
return errors.New("don't want conns")
}