Skip to content

Fix direct outbound TUN loopback before inbound start - #3

Open
leekery wants to merge 1 commit into
KaringX:karing_v1.13.19from
leekery:fix/windows-tun-direct-loop
Open

Fix direct outbound TUN loopback before inbound start#3
leekery wants to merge 1 commit into
KaringX:karing_v1.13.19from
leekery:fix/windows-tun-direct-loop

Conversation

@leekery

@leekery leekery commented Aug 25, 2026

Copy link
Copy Markdown

Summary

  • seed the direct outbound loopback ranges from Karing's configured TUN prefixes before the TUN interface starts
  • retain interface discovery as a fallback when no configured TUN prefix is available
  • add regression coverage for an address inside the TUN prefix, an unrelated LAN address, and configurations without a TUN prefix

Problem

Karing starts outbounds before the TUN inbound. During direct outbound startup, InterfaceMonitor().MyInterfaces() can therefore still be empty, leaving myAddresses unset. A packet routed to direct whose destination is the TUN peer can then re-enter the TUN repeatedly. This was observed with UDP traffic to ports 5351 and 1900, but the fix intentionally protects the entire configured TUN range rather than hard-coding ports.

For a TUN address of 10.20.0.1/30, the regression test verifies that 10.20.0.2 is rejected before the physical interface exists while 192.168.1.254 remains allowed.

Related reports:

Testing

  • go test -tags with_karing ./protocol/direct ./adapter/inbound -count=1
  • go vet -tags with_karing ./protocol/direct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant