Skip to content

Commit

Permalink
Fix broadcast filter not applied to mixed stack
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Nov 13, 2023
1 parent b2d75f5 commit 9102428
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions stack_mixed.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func (m *Mixed) wintunLoop(winTun WinTun) {
}

func (m *Mixed) processIPv4(packet clashtcpip.IPv4Packet) error {
destination := packet.DestinationIP()
if destination == m.broadcastAddr || !destination.IsGlobalUnicast() {
return common.Error(m.tun.Write(packet))
}
switch packet.Protocol() {
case clashtcpip.TCP:
return m.processIPv4TCP(packet, packet.Payload())
Expand All @@ -163,6 +167,9 @@ func (m *Mixed) processIPv4(packet clashtcpip.IPv4Packet) error {
}

func (m *Mixed) processIPv6(packet clashtcpip.IPv6Packet) error {
if !packet.DestinationIP().IsGlobalUnicast() {
return common.Error(m.tun.Write(packet))
}
switch packet.Protocol() {
case clashtcpip.TCP:
return m.processIPv6TCP(packet, packet.Payload())
Expand Down

0 comments on commit 9102428

Please sign in to comment.