ip

package
v1.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

ip检索工具

最简洁的ip检索工具

使用

import (
  "gitee.com/novanest/toolkit/match/ip"
)

func ExampleSample() {
	// 模拟一个大的 IP 池
	ipPoolData := []string{
		"192.168.1.1",
		"192.168.1.0/24",
		"192.168.100.10-192.168.100.20",
		"10.0.0.1-10.0.0.100",
		"172.16.0.0/16",
	}

	// 初始化 IP 池
	pool := NewIPPool(ipPoolData)

	// 测试 IP 地址
	testIPs := []string{
		"192.168.1.1",
		"192.168.1.50",
		"192.168.100.15",
		"10.0.0.50",
		"172.16.5.5",
		"8.8.8.8",
	}

	// 并行处理多个 IP 的查询
	results := pool.ParallelIPCheck(testIPs)

	// 输出结果
	for i, ip := range testIPs {
		if results[i] {
			fmt.Printf("IP %s 在池子中\n", ip)
		} else {
			fmt.Printf("IP %s 不在池子中\n", ip)
		}
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIPPool

func NewIPPool(pool []string) *ipPool

初始化 IP 池,将池中的 IP 地址预处理并分类

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL