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

No files matched your search

-9
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
+1 -3
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
}