I have a icmp listening func :
func Start(url string) {
conn, err := icmp.ListenPacket("ip4:icmp", url)
if err != nil {
log.Fatal(err)
}
for {
var msg []byte
length, sourceIP, err := conn.ReadFrom(msg)
if err != nil {
log.Println(err)
continue
}
fmt.Println(url + "===========")
log.Printf("message = '%s', length = %d, source-ip = %s", string(msg), length, sourceIP)
}
_ = conn.Close()
}
because of there are two network cards in my server host, I start this func with "Start(0.0.0.0)",
at the time of ping to this server, got the following information:
2020/08/31 11:11:02 message = '', length = 0, source-ip = 192.168.255.133
192.168.255.128===========
2020/08/31 11:11:03 message = '', length = 0, source-ip = 192.168.255.133
192.168.255.128===========
2020/08/31 11:11:04 message = '', length = 0, source-ip = 192.168.255.133
Source ip address only , how to get ping target ip addr?