goip

package module
v1.0.48 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 9 Imported by: 1

README

Golang

📦 Golang IP数据库

godoc goproxy.cn goreportcard.com deps.dev

安装

go get -v -u go.dtapp.net/goip@v1.0.48

使用

package main

import (
	"context"
	"go.dtapp.net/goip"
	"testing"
)

func TestGoIp(t *testing.T) {
	// 获取Mac地址
	t.Log(goip.GetMacAddr(context.Background()))
	// 内网ip
	t.Log(goip.GetInsideIp(context.Background()))
	// 外网ip
	t.Log(goip.GetOutsideIp(context.Background()))
}

Documentation

Index

Constants

View Source
const Version = "1.0.48"

Variables

View Source
var (
	QueryIncorrect = errors.New("ip地址不正确")
)

Functions

func GetInsideIp

func GetInsideIp(ctx context.Context) string

GetInsideIp 内网ip

func GetMacAddr added in v1.0.21

func GetMacAddr(ctx context.Context) (arrays []string)

GetMacAddr 获取Mac地址

func GetOutsideIp

func GetOutsideIp(ctx context.Context) string

GetOutsideIp 外网ip

func Ips

func Ips(ctx context.Context) (map[string]string, error)

Ips 获取全部网卡的全部IP

func IsIp added in v1.0.37

func IsIp(ipStr string) string

IsIp 是否ip

func IsIpConsistent added in v1.0.37

func IsIpConsistent(ipStr1, ipStr2 string) bool

IsIpConsistent 两个ip是否一致

Types

type AnalyseResult

type AnalyseResult struct {
	Ip                string  `json:"ip"`                 // ip
	Continent         string  `json:"continent"`          // 大陆
	Country           string  `json:"country"`            // 国家
	Province          string  `json:"province"`           // 省份
	City              string  `json:"city"`               // 城市
	Isp               string  `json:"isp"`                // 运营商
	LocationTimeZone  string  `json:"location_time_zone"` // 位置时区
	LocationLatitude  float64 `json:"location_latitude"`  // 位置纬度
	LocationLongitude float64 `json:"location_longitude"` // 位置经度
}

type Client added in v1.0.21

type Client struct {
	// contains filtered or unexported fields
}

func NewIp added in v1.0.21

func NewIp(config *ClientConfig) (*Client, error)

NewIp 实例化

func (*Client) Analyse added in v1.0.21

func (c *Client) Analyse(ip string) (resp AnalyseResult)

func (*Client) CheckIpv4 added in v1.0.21

func (c *Client) CheckIpv4(ips string) bool

CheckIpv4 检查数据是不是IPV4

func (*Client) CheckIpv6 added in v1.0.21

func (c *Client) CheckIpv6(ips string) bool

CheckIpv6 检测是不是IPV6

func (*Client) Close added in v1.0.31

func (c *Client) Close()

func (*Client) GetGeo added in v1.0.43

func (c *Client) GetGeo() *geoip.Client

func (*Client) GetQqWry added in v1.0.46

func (c *Client) GetQqWry() *qqwry.Client

func (*Client) QueryGeoIp added in v1.0.31

func (c *Client) QueryGeoIp(ipAddress string) (result geoip.QueryCityResult, err error)

QueryGeoIp ip2region https://www.maxmind.com/

func (*Client) QueryQqWry added in v1.0.31

func (c *Client) QueryQqWry(ipAddress string) (result qqwry.QueryResult, err error)

QueryQqWry 纯真IP库 https://www.cz88.net/

type ClientConfig added in v1.0.42

type ClientConfig struct {
	GeoipAsnPath     string
	GeoipCityPath    string
	GeoipCountryPath string
	QqwryPath        string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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