1
0
Эх сурвалжийг харах

allow more protos to have ports parsed

JackDoan 3 долоо хоног өмнө
parent
commit
14f80450fb
2 өөрчлөгдсөн 5 нэмэгдсэн , 2 устгасан
  1. 3 0
      iputil/packet.go
  2. 2 2
      outside.go

+ 3 - 0
iputil/packet.go

@@ -32,6 +32,9 @@ const (
 	IPProtocolICMPv6      = 58
 	IPProtocolTCP         = 6
 	IPProtocolUDP         = 17
+	IPProtocolUDPLite     = 136
+	IPProtocolDCCP        = 33
+	IPProtocolSCTP        = 132
 	ICMPv6TypeEchoRequest = 128
 	ICMPv6TypeEchoReply   = 129
 )

+ 2 - 2
outside.go

@@ -385,7 +385,7 @@ func parseV6(data []byte, incoming bool, fp *firewall.ParsedPacket) error {
 			fp.RemotePort = 0
 		}
 
-	case iputil.IPProtocolTCP, iputil.IPProtocolUDP:
+	case iputil.IPProtocolTCP, iputil.IPProtocolUDP, iputil.IPProtocolDCCP, iputil.IPProtocolSCTP, iputil.IPProtocolUDPLite:
 		if dataLen < offset+4 {
 			return ErrIPv6PacketTooShort
 		}
@@ -464,7 +464,7 @@ func parseV4(data []byte, incoming bool, fp *firewall.ParsedPacket) error {
 		fp.RemotePort = binary.BigEndian.Uint16(data[ihl+4 : ihl+6]) //identifier
 		fp.LocalPort = 0                                             //code would be uint16(data[ihl+1])
 
-	case iputil.IPProtocolTCP, iputil.IPProtocolUDP:
+	case iputil.IPProtocolTCP, iputil.IPProtocolUDP, iputil.IPProtocolDCCP, iputil.IPProtocolSCTP, iputil.IPProtocolUDPLite:
 		if incoming {
 			fp.RemotePort = binary.BigEndian.Uint16(data[ihl : ihl+2])  //src port
 			fp.LocalPort = binary.BigEndian.Uint16(data[ihl+2 : ihl+4]) //dst port