Simplify dhtPort()

A similar case of `haveDhtServer`
This commit is contained in:
YenForYang 2021-09-03 21:24:35 -05:00 committed by Matt Joiner
parent 99ba75f458
commit f86355ac0b
1 changed files with 4 additions and 4 deletions

View File

@ -991,10 +991,10 @@ func (cl *Client) sendInitialMessages(conn *PeerConn, torrent *Torrent) {
}
func (cl *Client) dhtPort() (ret uint16) {
cl.eachDhtServer(func(s DhtServer) {
ret = uint16(missinggo.AddrPort(s.Addr()))
})
return
if len(cl.dhtServers) == 0 {
return
}
return uint16(missinggo.AddrPort(cl.dhtServers[len(cl.dhtServers)-1].Addr()))
}
func (cl *Client) haveDhtServer() bool {