This commit is contained in:
esrrhs 2018-12-17 15:57:01 +08:00
parent 70e47f3757
commit edfbd3a3cf
2 changed files with 1 additions and 12 deletions

View File

@ -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

View File

@ -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
}