From 8e148c0e6e45ffc94fc882feac43199b737948b2 Mon Sep 17 00:00:00 2001 From: shadow1ng Date: Fri, 5 Feb 2021 16:05:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9icmp=E5=8F=91=E5=8C=85?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F,=E6=9B=B4=E9=80=82=E5=90=88=E5=A4=A7?= =?UTF-8?q?=E8=A7=84=E6=A8=A1=E6=8E=A2=E6=B5=8B=E3=80=82=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8A=A5=E9=94=99=E6=8F=90=E7=A4=BA,--debug=E6=97=B6,?= =?UTF-8?q?=E5=A6=82=E6=9E=9C10=E7=A7=92=E5=86=85=E6=B2=A1=E6=9C=89LogSucc?= =?UTF-8?q?ess=E7=9A=84=E6=B6=88=E6=81=AF,=E6=AF=8F=E9=9A=9410=E7=A7=92?= =?UTF-8?q?=E5=B0=B1=E4=BC=9A=E6=89=93=E5=8D=B0=E4=B8=80=E4=B8=8B=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plugins/icmp.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Plugins/icmp.go b/Plugins/icmp.go index a009b10..939b74e 100644 --- a/Plugins/icmp.go +++ b/Plugins/icmp.go @@ -53,12 +53,13 @@ func GetSys() SystemInfo { } func IcmpCheck(hostslist []string) { + TmpHosts := make(map[string]struct{}) + var chanHosts = make(chan string) conn, err := icmp.ListenPacket("ip4:icmp", "0.0.0.0") endflag := false if err != nil { log.Fatal(err) } - var chanHosts = make(chan string) go func() { for { if endflag == true { @@ -74,7 +75,8 @@ func IcmpCheck(hostslist []string) { go func() { for ip := range chanHosts { - if !IsContain(AliveHosts, ip) { + if _, ok := TmpHosts[ip]; !ok { + TmpHosts[ip] = struct{}{} fmt.Printf("(icmp) Target '%s' is alive\n", ip) AliveHosts = append(AliveHosts, ip) } @@ -84,7 +86,8 @@ func IcmpCheck(hostslist []string) { for _, host := range hostslist { write(host, conn) } - if len(hostslist) > 10 { + + if len(hostslist) > 100 { time.Sleep(6 * time.Second) } else { time.Sleep(3 * time.Second)