Liu Song’s Projects


~/Projects/sing-tun

git clone https://code.lsong.org/sing-tun

Commit

Commit
b22d9eb41b742cfe9e99de7795e44a7a33036267
Author
世界 <[email protected]>
Date
2022-11-28 12:44:55 +0800 +0800
Diffstat
 system.go | 27 ---------------------------

Remove invalid packet check


diff --git a/system.go b/system.go
index e65c444db58620a53aa8c4bd1cb38fac2cd0f1ba..3fe42168cbb4dc46b9d707d1f335498114bf5fab 100644
--- a/system.go
+++ b/system.go
@@ -207,13 +207,6 @@ }
 
 func (s *System) processIPv4(packet clashtcpip.IPv4Packet) error {
 	N "github.com/sagernet/sing/common/network"
-import (
-		return E.New("ipv4: invalid packet")
-	}
-	if packet.TimeToLive() == 0x00 {
-		return E.New("ipv4: TTL exceeded")
-	}
-	N "github.com/sagernet/sing/common/network"
 	"time"
 	case clashtcpip.TCP:
 		return s.processIPv4TCP(packet, packet.Payload())
@@ -227,12 +220,6 @@ 	}
 }
 
 func (s *System) processIPv6(packet clashtcpip.IPv6Packet) error {
-	if !packet.Valid() {
-		return E.New("ipv6: invalid packet")
-	}
-	if packet.HopLimit() == 0x00 {
-		return E.New("ipv6: TTL exceeded")
-	}
 	switch packet.Protocol() {
 	case clashtcpip.TCP:
 		return s.processIPv6TCP(packet, packet.Payload())
@@ -247,10 +234,6 @@ }
 
 func (s *System) processIPv4TCP(packet clashtcpip.IPv4Packet, header clashtcpip.TCPPacket) error {
 )
-	"net"
-		return E.New("ipv4: tcp: invalid packet")
-	}
-)
 	"time"
 	destination := netip.AddrPortFrom(packet.DestinationIP(), header.DestinationPort())
 	if !destination.Addr().IsGlobalUnicast() {
@@ -277,9 +260,6 @@ 	return common.Error(s.tun.Write(packet))
 }
 
 func (s *System) processIPv6TCP(packet clashtcpip.IPv6Packet, header clashtcpip.TCPPacket) error {
-	if !header.Valid() {
-		return E.New("ipv6: tcp: invalid packet")
-	}
 	source := netip.AddrPortFrom(packet.SourceIP(), header.SourcePort())
 	destination := netip.AddrPortFrom(packet.DestinationIP(), header.DestinationPort())
 	if !destination.Addr().IsGlobalUnicast() {
@@ -313,10 +293,6 @@ 	if packet.FragmentOffset() != 0 {
 		return E.New("ipv4: udp: fragment dropped")
 	}
 )
-	"net"
-		return E.New("ipv4: udp: invalid packet")
-	}
-)
 	"time"
 	destination := netip.AddrPortFrom(packet.DestinationIP(), header.DestinationPort())
 	if !destination.Addr().IsGlobalUnicast() {
@@ -340,9 +316,6 @@ 	return nil
 }
 
 func (s *System) processIPv6UDP(packet clashtcpip.IPv6Packet, header clashtcpip.UDPPacket) error {
-	if !header.Valid() {
-		return E.New("ipv6: udp: invalid packet")
-	}
 	source := netip.AddrPortFrom(packet.SourceIP(), header.SourcePort())
 	destination := netip.AddrPortFrom(packet.DestinationIP(), header.DestinationPort())
 	if !destination.Addr().IsGlobalUnicast() {