From edfbd3a3cfec4627ee35bd5e1b34fa4302cedfe5 Mon Sep 17 00:00:00 2001 From: esrrhs Date: Mon, 17 Dec 2018 15:57:01 +0800 Subject: [PATCH] add --- src/pingtunnel/pingtunnel.go | 9 --------- src/pingtunnel/server.go | 4 +--- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/pingtunnel/pingtunnel.go b/src/pingtunnel/pingtunnel.go index bd46eea..e4d144b 100644 --- a/src/pingtunnel/pingtunnel.go +++ b/src/pingtunnel/pingtunnel.go @@ -6,7 +6,6 @@ import ( "encoding/base64" "encoding/binary" "encoding/hex" - "golang.org/x/net/ipv4" "io" ) @@ -20,14 +19,6 @@ const ( protocolICMP = 1 ) -func ipv4Payload(b []byte) []byte { - if len(b) < ipv4.HeaderLen { - return b - } - hdrlen := int(b[0]&0x0f) << 2 - return b[hdrlen:] -} - type Msg struct { TYPE int ID string // identifier diff --git a/src/pingtunnel/server.go b/src/pingtunnel/server.go index 5b816be..f149dd2 100644 --- a/src/pingtunnel/server.go +++ b/src/pingtunnel/server.go @@ -65,10 +65,8 @@ func (p *Server) Recv() error { } } - bytes1 := ipv4Payload(bytes) - var m *icmp.Message - if m, err = icmp.ParseMessage(protocolICMP, bytes1[:n]); err != nil { + if m, err = icmp.ParseMessage(protocolICMP, bytes[:n]); err != nil { fmt.Println("Error parsing icmp message") return err }