Skip to content

Commit

Permalink
update 2022年 6月19日 星期日 19时44分04秒 CST
Browse files Browse the repository at this point in the history
  • Loading branch information
No-Github committed Jun 19, 2022
1 parent ccf3956 commit 5b543c2
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ var filename = flag.String("in", "", "输入文件名")
var cidrSlice []string
var iprangeSlice []string
var wrongSlice []string
var ipv4_left = ""
var ipv4_right = ""
var ipv4Left = ""
var ipv4Right = ""
var numSlice []uint

func main() {
Expand Down Expand Up @@ -67,8 +67,10 @@ func todo() {
cidr()

// 处理非预期格式
fmt.Println("-----非预期格式-----")
wrong()
if len(wrongSlice) > 0 {
fmt.Println("-----存在非预期格式-----")
wrong()
}

}

Expand All @@ -77,12 +79,12 @@ func iprange() {
for _, v := range iprangeSlice {
arr := strings.Split(v, "-")
if len(arr) == 2 {
ipv4_left = arr[0]
ipv4_right = arr[1]
ipv4Left = arr[0]
ipv4Right = arr[1]
// 左边地址
addressRight := net.ParseIP(ipv4_left)
addressRight := net.ParseIP(ipv4Left)
// 右边地址
addressRight2 := net.ParseIP(ipv4_right)
addressRight2 := net.ParseIP(ipv4Right)
if addressRight == nil {
// 格式非预期
wrongSlice = append(wrongSlice, v)
Expand All @@ -91,8 +93,8 @@ func iprange() {
wrongSlice = append(wrongSlice, v)
} else {
// 转10进制
num1, _ := exnet.IPString2Long(ipv4_left)
num2, _ := exnet.IPString2Long(ipv4_right)
num1, _ := exnet.IPString2Long(ipv4Left)
num2, _ := exnet.IPString2Long(ipv4Right)
if num1 > num2 {
// 格式非预期
wrongSlice = append(wrongSlice, v)
Expand Down

0 comments on commit 5b543c2

Please sign in to comment.