Commit 75e68219 authored by Steven Allen's avatar Steven Allen

Revert "fix source address not being set in non REUSEPORT dialer"

This reverts commit 5ebce0ea.

If we do this, we end up using the source *port* for dialing. That's not what we
want when not using reuseport.

fixes #19
parent 7596c750
......@@ -52,12 +52,6 @@ func (t *TcpTransport) Dialer(laddr ma.Multiaddr, opts ...tpt.DialOpt) (tpt.Dial
}
var base manet.Dialer
la, err := manet.ToNetAddr(laddr)
if err != nil {
return nil, err // something wrong with laddr.
}
base.Dialer.LocalAddr = la
var doReuse bool
for _, o := range opts {
switch o := o.(type) {
......@@ -143,6 +137,12 @@ type tcpDialer struct {
var _ tpt.Dialer = &tcpDialer{}
func (t *TcpTransport) newTcpDialer(base manet.Dialer, laddr ma.Multiaddr, doReuse bool) (*tcpDialer, error) {
// get the local net.Addr manually
la, err := manet.ToNetAddr(laddr)
if err != nil {
return nil, err // something wrong with laddr.
}
var pattern mafmt.Pattern
if TCP4.Matches(laddr) {
pattern = TCP4
......@@ -154,7 +154,10 @@ func (t *TcpTransport) newTcpDialer(base manet.Dialer, laddr ma.Multiaddr, doReu
if doReuse && ReuseportIsAvailable() {
rd := reuseport.Dialer{
D: base.Dialer,
D: net.Dialer{
LocalAddr: la,
Timeout: base.Timeout,
},
}
return &tcpDialer{
......
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