Commit 823812a5 authored by Jeromy's avatar Jeromy

allow nil for dialer laddr

parent f4bd862c
...@@ -36,6 +36,13 @@ func NewTCPTransport() *TcpTransport { ...@@ -36,6 +36,13 @@ func NewTCPTransport() *TcpTransport {
} }
func (t *TcpTransport) Dialer(laddr ma.Multiaddr, opts ...tpt.DialOpt) (tpt.Dialer, error) { func (t *TcpTransport) Dialer(laddr ma.Multiaddr, opts ...tpt.DialOpt) (tpt.Dialer, error) {
if laddr == nil {
zaddr, err := ma.NewMultiaddr("/ip4/0.0.0.0/tcp/0")
if err != nil {
return nil, err
}
laddr = zaddr
}
t.dlock.Lock() t.dlock.Lock()
defer t.dlock.Unlock() defer t.dlock.Unlock()
s := laddr.String() s := laddr.String()
...@@ -176,13 +183,6 @@ func (d *tcpDialer) Dial(raddr ma.Multiaddr) (tpt.Conn, error) { ...@@ -176,13 +183,6 @@ func (d *tcpDialer) Dial(raddr ma.Multiaddr) (tpt.Conn, error) {
} }
func (d *tcpDialer) DialContext(ctx context.Context, raddr ma.Multiaddr) (tpt.Conn, error) { func (d *tcpDialer) DialContext(ctx context.Context, raddr ma.Multiaddr) (tpt.Conn, error) {
if raddr == nil {
zaddr, err := ma.NewMultiaddr("/ip4/0.0.0.0/tcp/0")
if err != nil {
return nil, err
}
raddr = zaddr
}
var c manet.Conn var c manet.Conn
var err error var err error
if d.doReuse { if d.doReuse {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment