func (t *UtpTransport) newConn(addr ma.Multiaddr, opts ...DialOpt) (*UtpSocket, error) { network, netaddr, err := manet.DialArgs(addr) if err != nil { return nil, err } s, err := utp.NewSocket("udp"+network[3:], netaddr) if err != nil { return nil, err } laddr, err := manet.FromNetAddr(mautp.MakeAddr(s.LocalAddr())) if err != nil { return nil, err } return &UtpSocket{ s: s, laddr: laddr, transport: t, }, nil }
func TestFromUTP(t *testing.T) { a := &net.UDPAddr{IP: net.ParseIP("10.20.30.40"), Port: 1234} testConvert(t, "/ip4/10.20.30.40/udp/1234/utp", func() (ma.Multiaddr, error) { return FromNetAddr(mautp.MakeAddr(a)) }) }