ip

package
v0.0.0-...-a8182c1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultIPKeyMap map[string]string = map[string]string{
	"inet6num": "inetnum",

	"NetName": "netname",

	"route":  "route/id",
	"route6": "route/id",
	"origin": "asn",

	"mnt-irt": "mnt_irt",
	"irt":     "irt/id",

	"nic-hdl": "person+role/id",
	"person":  "name",
	"role":    "name",

	"organization": "org/id",
	"org-name":     "name",

	"mntner": "mntner/id",

	"admin-c":       "admin",
	"tech-c":        "tech",
	"mnt-by":        "mnt_by",
	"mnt-lower":     "mnt_lower",
	"mnt-routes":    "mnt_routes",
	"abuse-mailbox": "abuse_mailbox",
	"e-mail":        "email",
	"fax-no":        "fax",
	"irt-nfy":       "notified_email",
	"notify":        "notified_email",
	"last-modified": "updated_date",

	"NetRange":       "inetnum",
	"CIDR":           "range/cidr",
	"OriginAS":       "asn",
	"Comment":        "descr",
	"OrgId":          "org/id",
	"OrgName":        "name",
	"Updated":        "updated_date",
	"Address":        "address",
	"Country":        "country",
	"Ref":            "ref",
	"OrgTechHandle":  "org-tech/id",
	"OrgTechName":    "name",
	"OrgTechPhone":   "phone",
	"OrgTechEmail":   "email",
	"OrgTechRef":     "ref",
	"OrgAbuseHandle": "org-abuse/id",
	"OrgAbuseName":   "name",
	"OrgAbusePhone":  "phone",
	"OrgAbuseEmail":  "email",
	"OrgAbuseRef":    "ref",
	"OrgDNSHandle":   "org-dns/id",
	"OrgDNSName":     "name",
	"OrgDNSPhone":    "phone",
	"OrgDNSEmail":    "email",
	"OrgDNSRef":      "ref",

	"owner":      "org",
	"aut-num":    "asn",
	"inetnum-up": "parent",
}

Functions

func WhoisNotFound

func WhoisNotFound(rawtext string) bool

WhoisNotFound check keywords in rawtext

Types

type Contact

type Contact struct {
	ID             string   `json:"id,omitempty"` // primary key
	Type           string   `json:"type,omitempty"`
	Name           string   `json:"name,omitempty"`
	Address        []string `json:"address,omitempty"`
	Country        string   `json:"country,omitempty"`
	Phone          []string `json:"phone,omitempty"`
	Fax            []string `json:"fax,omitempty"`
	Email          []string `json:"email,omitempty"`
	Description    []string `json:"descr,omitempty"`
	Remarks        []string `json:"remarks,omitempty"`
	ContactAdmin   []string `json:"admin,omitempty"`   // admin-c, for troubleshooting
	ContactTech    []string `json:"tech,omitempty"`    // tech-c, for troubleshooting
	ContactOwner   []string `json:"owner,omitempty"`   // owner-c
	ContactRouting []string `json:"routing,omitempty"` // routing-c
	ContactAbuse   []string `json:"abuse,omitempty"`   // abuse-c
	NotifiedEmail  []string `json:"notified_email,omitempty"`
	AbuseMailbox   []string `json:"abuse_mailbox,omitempty"`
	MntBy          []string `json:"mnt_by,omitempty"`
	MntLower       string   `json:"mnt_lower,omitempty"`
	MntRoutes      string   `json:"mnt_routes,omitempty"`
	Ref            []string `json:"ref,omitempty"`
	Auth           []string `json:"auth,omitempty"`
	UpdatedDate    string   `json:"updated_date,omitempty"`
	UpdatedDateRaw string   `json:"-"`
	Source         string   `json:"source,omitempty"`
}
Contact store from all kinds of contact object, includes

* Person from https://www.apnic.net/manage-ip/using-whois/guide/person/ * Orgnization from https://www.apnic.net/manage-ip/using-whois/guide/organization/ * Irt from https://www.apnic.net/manage-ip/using-whois/guide/irt/ * ...

type IParser

type IParser interface {
	Do(string, ...map[string]string) (*ParsedWhois, error)
}

IParser is used to parse whois information when input is ip

type Network

type Network struct {
	Inetnum  string `json:"inetnum,omitempty"`
	Range    *Range `json:"range,omitempty"`
	Org      string `json:"org,omitempty"`
	Netname  string `json:"netname,omitempty"`
	MntIrt   string `json:"mnt_irt,omitempty"`
	OriginAS string `json:"asn,omitempty"` // Origin As Network
	Parent   string `json:"parent,omitempty"`
	Contact
}

Network records (NETs) define a range of IPv4 or IPv6 addresses and show the organizations and POCs with authority over them. To reposrt networtk abuse, contact mnt-irt

type ParsedWhois

type ParsedWhois struct {
	Networks []Network `json:"networks,omitempty"`
	Contacts []Contact `json:"contacts,omitempty"`
	Routes   []Route   `json:"routes,omitempty"`
}

type Parser

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

func NewParser

func NewParser(ip string, logger logrus.FieldLogger) *Parser

func (*Parser) Do

func (wp *Parser) Do(rawtext string, specKeyMaps ...map[string]string) (*ParsedWhois, error)

type Range

type Range struct {
	From string   `json:"from,omitempty"`
	To   string   `json:"to,omitempty"`
	CIDR []string `json:"cidr,omitempty"`
}

Range parse result from Inetnum

type Route

type Route struct {
	OriginAS string `json:"asn,omitempty"`
	Route    string `json:"route,omitempty"`
	Contact
}

type Whois

type Whois struct {
	ParsedWhois *ParsedWhois `json:"parsed_whois"`
	WhoisServer string       `json:"whois_server,omitempty"` // whois server which response the rawtext, OrgId
	RawText     string       `json:"rawtext,omitempty"`
}

func NewWhois

func NewWhois(parsedWhois *ParsedWhois, rawtext, whoisServer string) *Whois

Jump to

Keyboard shortcuts

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