]> Sergey Matveev's repositories - btrtrc.git/blob - ipport.go
Promote ipPort to its own file
[btrtrc.git] / ipport.go
1 package torrent
2
3 import (
4         "net"
5         "strconv"
6
7         "github.com/anacrolix/missinggo"
8 )
9
10 type ipPort struct {
11         IP   net.IP
12         Port uint16
13 }
14
15 func (me ipPort) String() string {
16         return net.JoinHostPort(me.IP.String(), strconv.FormatUint(uint64(me.Port), 10))
17 }
18
19 func ipPortFromNetAddr(na net.Addr) ipPort {
20         return ipPort{missinggo.AddrIP(na), uint16(missinggo.AddrPort(na))}
21 }