From 01b105d42d16c9dd625eb61c03bc6e71081944e5 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Sat, 19 Feb 2022 17:36:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E5=9C=A8=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20-allip=20=E5=8F=82=E6=95=B0=E6=97=B6=20/32=20?= =?UTF-8?q?=E5=AD=90=E7=BD=91=E6=8E=A9=E7=A0=81=E8=AF=86=E5=88=AB=E4=B8=BA?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=20IP=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task/ip.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/task/ip.go b/task/ip.go index 93ff47d..02d3359 100644 --- a/task/ip.go +++ b/task/ip.go @@ -27,6 +27,9 @@ func InitRandSeed() { } func randIPEndWith(num byte) byte { + if num == 0 { // 对于 /32 这种单独的 IP + return byte(0) + } return byte(rand.Intn(int(num))) } @@ -86,10 +89,6 @@ func (r *IPRanges) getIPRange() (minIP, hosts byte) { hosts = 255 return } - if total == 0 { - hosts = 1 - return - } hosts = byte(total) return }