Skip to content

Commit

Permalink
Merge pull request #95 from libp2p/sim-open
Browse files Browse the repository at this point in the history
use the assigned role when upgrading a sim open connection
  • Loading branch information
marten-seemann authored Sep 25, 2021
2 parents 35074ee + e9c99b7 commit a054232
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions p2p/transport/tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import (
"runtime"
"time"

logging "github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/transport"

tptu "github.com/libp2p/go-libp2p-transport-upgrader"
rtpt "github.com/libp2p/go-reuseport-transport"

logging "github.com/ipfs/go-log/v2"
ma "github.com/multiformats/go-multiaddr"
mafmt "github.com/multiformats/go-multiaddr-fmt"
manet "github.com/multiformats/go-multiaddr/net"
Expand Down Expand Up @@ -148,7 +150,11 @@ func (t *TcpTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID)
if err != nil {
return nil, err
}
return t.Upgrader.UpgradeOutbound(ctx, t, c, p)
direction := network.DirOutbound
if ok, isClient, _ := network.GetSimultaneousConnect(ctx); ok && !isClient {
direction = network.DirInbound
}
return t.Upgrader.Upgrade(ctx, t, c, direction, p)
}

// UseReuseport returns true if reuseport is enabled and available.
Expand Down

0 comments on commit a054232

Please sign in to comment.