Skip to content

Commit

Permalink
chore: improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Jul 5, 2024
1 parent 439d70a commit 169cd86
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/transporter/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ func (b *baseTransporter) RelayTCPConn(c net.Conn, handshakeF TCPHandShakeF) err
}
}

// rate limit
if b.cfg.MaxReadRateKbps > 0 {
c = conn.NewRateLimitedConn(c, b.cfg.MaxReadRateKbps)
}

clonedRemote := remote.Clone()
rc, err := handshakeF(clonedRemote)
if err != nil {
return err
}
defer rc.Close()

// rate limit
if b.cfg.MaxReadRateKbps > 0 {
c = conn.NewRateLimitedConn(c, b.cfg.MaxReadRateKbps)
}

b.l.Infof("RelayTCPConn from %s to %s", c.LocalAddr(), remote.Address)
relayConn := conn.NewRelayConn(
b.cfg.Label, c, rc, conn.WithHandshakeDuration(clonedRemote.HandShakeDuration))
Expand Down

0 comments on commit 169cd86

Please sign in to comment.