mirror of
https://github.com/tailscale/tailscale.git
synced 2026-05-05 20:26:47 +02:00
wgengine/magicsock: log when sending traffic to specific Mullvad node
Change-Id: I0baa642a789ea0a96650023a36e8564403305ef4
This commit is contained in:
parent
cafdc3b303
commit
1633a8e0fe
@ -418,6 +418,8 @@ func NewConn(opts Options) (*Conn, error) {
|
||||
c.portMapper.SetGatewayLookupFunc(opts.NetMon.GatewayAndSelfIP)
|
||||
}
|
||||
c.netMon = opts.NetMon
|
||||
c.pconn4.logf = c.logf
|
||||
c.pconn6.logf = c.logf
|
||||
|
||||
if err := c.rebind(keepCurrentPort); err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
|
||||
"golang.org/x/net/ipv6"
|
||||
"tailscale.com/net/netaddr"
|
||||
"tailscale.com/types/logger"
|
||||
"tailscale.com/types/nettype"
|
||||
)
|
||||
|
||||
@ -30,6 +31,8 @@ type RebindingUDPConn struct {
|
||||
mu sync.Mutex // held while changing pconn (and pconnAtomic)
|
||||
pconn nettype.PacketConn
|
||||
port uint16
|
||||
|
||||
logf logger.Logf
|
||||
}
|
||||
|
||||
// setConnLocked sets the provided nettype.PacketConn. It should be called only
|
||||
@ -63,14 +66,25 @@ func (c *RebindingUDPConn) readFromWithInitPconn(pconn nettype.PacketConn, b []b
|
||||
}
|
||||
}
|
||||
|
||||
var testAddr = netip.MustParseAddr("146.70.116.98")
|
||||
|
||||
// ReadFromUDPAddrPort reads a packet from c into b.
|
||||
// It returns the number of bytes copied and the source address.
|
||||
func (c *RebindingUDPConn) ReadFromUDPAddrPort(b []byte) (int, netip.AddrPort, error) {
|
||||
return c.readFromWithInitPconn(*c.pconnAtomic.Load(), b)
|
||||
n, src, err := c.readFromWithInitPconn(*c.pconnAtomic.Load(), b)
|
||||
if src.Addr() == testAddr {
|
||||
c.logf("RebindingUDPConn.ReadFromUDPAddrPort([]byte{/* %d */}) = (%d, %q, %v)", len(b), n, src, err)
|
||||
}
|
||||
return n, src, err
|
||||
}
|
||||
|
||||
// WriteBatchTo writes buffs to addr.
|
||||
func (c *RebindingUDPConn) WriteBatchTo(buffs [][]byte, addr netip.AddrPort) error {
|
||||
func (c *RebindingUDPConn) WriteBatchTo(buffs [][]byte, addr netip.AddrPort) (retErr error) {
|
||||
if addr.Addr() == testAddr {
|
||||
defer func() {
|
||||
c.logf("RebindingUDPConn.WriteBatchTo([][]byte{/* %d */, %s) = %v", len(buffs), addr, retErr)
|
||||
}()
|
||||
}
|
||||
for {
|
||||
pconn := *c.pconnAtomic.Load()
|
||||
b, ok := pconn.(*batchingUDPConn)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user