mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-26 11:11:01 +00:00
wgengine/netstack: log ForwarderRequest in readable form, only in debug mode (#1758)
* wgengine/netstack: log ForwarderRequest in readable form, only in debug mode Fixes #1757 Signed-off-by: Naman Sood <mail@nsood.in>
This commit is contained in:
parent
07c95a0219
commit
4a90a91d29
@ -393,12 +393,10 @@ func (ns *Impl) injectInbound(p *packet.Parsed, t *tstun.Wrapper) filter.Respons
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ns *Impl) acceptTCP(r *tcp.ForwarderRequest) {
|
func (ns *Impl) acceptTCP(r *tcp.ForwarderRequest) {
|
||||||
if debugNetstack {
|
|
||||||
// Kinda ugly:
|
|
||||||
// ForwarderRequest: &{{{{0 0}}} 0xc0001c30b0 0xc0004c3d40 {1240 6 true 826109390 0 true}
|
|
||||||
ns.logf("[v2] ForwarderRequest: %v", r)
|
|
||||||
}
|
|
||||||
reqDetails := r.ID()
|
reqDetails := r.ID()
|
||||||
|
if debugNetstack {
|
||||||
|
ns.logf("[v2] TCP ForwarderRequest: %s", stringifyTEI(reqDetails))
|
||||||
|
}
|
||||||
dialAddr := reqDetails.LocalAddress
|
dialAddr := reqDetails.LocalAddress
|
||||||
dialNetAddr, _ := netaddr.FromStdIP(net.IP(dialAddr))
|
dialNetAddr, _ := netaddr.FromStdIP(net.IP(dialAddr))
|
||||||
isTailscaleIP := tsaddr.IsTailscaleIP(dialNetAddr)
|
isTailscaleIP := tsaddr.IsTailscaleIP(dialNetAddr)
|
||||||
@ -472,7 +470,10 @@ func (ns *Impl) forwardTCP(client *gonet.TCPConn, wq *waiter.Queue, dialAddr tcp
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ns *Impl) acceptUDP(r *udp.ForwarderRequest) {
|
func (ns *Impl) acceptUDP(r *udp.ForwarderRequest) {
|
||||||
ns.logf("[v2] UDP ForwarderRequest: %v", r)
|
reqDetails := r.ID()
|
||||||
|
if debugNetstack {
|
||||||
|
ns.logf("[v2] UDP ForwarderRequest: %v", stringifyTEI(reqDetails))
|
||||||
|
}
|
||||||
var wq waiter.Queue
|
var wq waiter.Queue
|
||||||
ep, err := r.CreateEndpoint(&wq)
|
ep, err := r.CreateEndpoint(&wq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -563,3 +564,9 @@ func startPacketCopy(ctx context.Context, cancel context.CancelFunc, dst net.Pac
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stringifyTEI(tei stack.TransportEndpointID) string {
|
||||||
|
localHostPort := net.JoinHostPort(tei.LocalAddress.String(), strconv.Itoa(int(tei.LocalPort)))
|
||||||
|
remoteHostPort := net.JoinHostPort(tei.RemoteAddress.String(), strconv.Itoa(int(tei.RemotePort)))
|
||||||
|
return fmt.Sprintf("%s -> %s", remoteHostPort, localHostPort)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user