ip

package module
v0.0.0-...-55f34b4 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2014 License: Apache-2.0 Imports: 6 Imported by: 0

README

ip

a ip lookup adapter. It can use many ip databases. It only support QQ ip database now.

How to install?

go get github.com/ianzeng/ip

How to use it?

Use it like this:

import (
    "github.com/ianzeng/ip"
)

func main() {
    ip := "192.168.60.66"
    //Init a ip analyzer
    an, e := ip.NewIPAnalyzer("qq", "./QQWry.DAT")
    if e != nil {
        fmt.Println("Create ip analyzer error, desc:", e)
        return
    }

    location, isp, e := an.Analyze(ip)
    if e != nil {
        fmt.Println("Analyze ip error, desc:", e)
        return
    }

    fmt.Println("location:",location,", isp:",isp)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, adapter IPAnalyzer)

Adapter register

Types

type IPAnalyzer

type IPAnalyzer interface {
	//Init adapter via dbFile
	Init(dbFile string) error
	//Analyze ip string, return location and isp
	Analyze(ip string) (string, string, error)
}

func NewIPAnalyzer

func NewIPAnalyzer(adapterName, dbFile string) (IPAnalyzer, error)

Create a IP analyzer, according to adapterName, initialized via dbFile

type QQIPAnalyzer

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

IPAnalyzer adapter

func (*QQIPAnalyzer) Analyze

func (a *QQIPAnalyzer) Analyze(ip string) (string, string, error)

Analyze ip string

func (*QQIPAnalyzer) Init

func (a *QQIPAnalyzer) Init(dbFile string) error

Initialize

Jump to

Keyboard shortcuts

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