Commit 633b04e5 authored by Łukasz Magiera's avatar Łukasz Magiera

p2p: remove redundant listener address check

License: MIT
Signed-off-by: default avatarŁukasz Magiera <magik6k@gmail.com>
parent a0ad8cfd
...@@ -2,7 +2,6 @@ package p2p ...@@ -2,7 +2,6 @@ package p2p
import ( import (
"context" "context"
"errors"
"time" "time"
ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr" ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr"
...@@ -29,34 +28,24 @@ type outboundListener struct { ...@@ -29,34 +28,24 @@ type outboundListener struct {
// Dial creates new P2P stream to a remote listener // Dial creates new P2P stream to a remote listener
func (p2p *P2P) Dial(ctx context.Context, peer peer.ID, proto string, bindAddr ma.Multiaddr) (Listener, error) { func (p2p *P2P) Dial(ctx context.Context, peer peer.ID, proto string, bindAddr ma.Multiaddr) (Listener, error) {
lnet, _, err := manet.DialArgs(bindAddr) maListener, err := manet.Listen(bindAddr)
if err != nil { if err != nil {
return nil, err return nil, err
} }
switch lnet { listener := &outboundListener{
case "tcp", "tcp4", "tcp6": p2p: p2p,
maListener, err := manet.Listen(bindAddr) id: p2p.identity,
if err != nil {
return nil, err
}
listener := &outboundListener{
p2p: p2p,
id: p2p.identity,
proto: proto, proto: proto,
peer: peer, peer: peer,
listener: maListener, listener: maListener,
} }
go listener.acceptConns() go listener.acceptConns()
return listener, nil return listener, nil
default:
return nil, errors.New("unsupported proto: " + lnet)
}
} }
func (l *outboundListener) dial() (net.Stream, error) { func (l *outboundListener) dial() (net.Stream, error) {
......
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