Documentation
¶
Index ¶
Constants ¶
const ( // Country 国家 Country = "country" // Province 省份 Province = "province" // City 城市 City = "city" // ISP 运营商 ISP = "isp" // ASN 自治域号 ASN = "asn" // Continent 大洲 Continent = "continent" // UTCOffset UTC 偏移值 UTCOffset = "utcOffset" // Latitude 纬度 Latitude = "latitude" // Longitude 经度 Longitude = "longitude" // ChinaAdminCode 中国行政区划代码 ChinaAdminCode = "chinaAdminCode" )
const ( // IPv4 represents the version for IPv4 IP database. IPv4 = 1 // IPv6 represents the version for IPv6 IP database. IPv6 = 2 // MetaVersion represents the version of the metadata. MetaVersion = 1 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlfredIcon ¶ added in v0.2.7
AlfredIcon represents the icon for an AlfredItem.
type AlfredItem ¶ added in v0.2.7
type AlfredItem struct { Title string `json:"title"` Subtitle string `json:"subtitle"` Arg string `json:"arg"` Icon AlfredIcon `json:"icon"` Valid bool `json:"valid"` Text AlfredText `json:"text"` }
AlfredItem represents an item to be displayed in Alfred's result list.
type AlfredText ¶ added in v0.2.7
type AlfredText struct {
Copy string `json:"copy"`
}
AlfredText provides additional text information for an AlfredItem.
type DataList ¶ added in v0.2.7
type DataList struct { Items []interface{} `json:"items,omitempty"` Domains []interface{} `json:"domains,omitempty"` }
DataList holds a list of items to be displayed in Alfred's result list.
func (*DataList) AddAlfredItemByDomainInfo ¶ added in v0.2.8
func (d *DataList) AddAlfredItemByDomainInfo(info *DomainInfo)
AddAlfredItemByDomainInfo creates an AlfredItem from the provided DomainInfo and adds it to the DataList.
func (*DataList) AddAlfredItemByIPInfo ¶ added in v0.2.7
AddAlfredItemByIPInfo creates an AlfredItem from the provided IPInfo and adds it to the DataList.
func (*DataList) AddAlfredItemEmpty ¶ added in v0.2.7
func (d *DataList) AddAlfredItemEmpty()
AddAlfredItemEmpty adds a default "Not found" AlfredItem to the DataList if the list is empty.
type DomainInfo ¶ added in v0.2.5
type DomainInfo struct { // Domain is the domain name. Domain string `json:"domain"` // MainDomain is the main domain name. MainDomain string `json:"main_domain"` // Data holds the actual information related to the domain. Data map[string]string `json:"data"` }
DomainInfo holds details about a specific domain, including its name, main domain, and associated data.
func (*DomainInfo) Values ¶ added in v0.2.8
func (d *DomainInfo) Values() []string
Values extracts the values from the Data map, sorts them alphabetically, and returns them as a slice of strings. If the DomainInfo receiver or its Data map is nil, it returns nil to indicate the absence of data.
type IPInfo ¶
type IPInfo struct { // IP represents the IP address. IP net.IP // IPNet denotes the network range to which the IP belongs. IPNet *ipnet.Range // Data holds the actual information related to the IP in a key-value format. Data map[string]string // FieldAlias maps common field names to their corresponding database field names. FieldAlias map[string]string // Fields lists the fields that should be output. Fields []string // ReplaceFields specifies fields that should be replaced with specific values. // operate.FieldSelector use this to replace the value of the field. ReplaceFields map[string]string }
IPInfo represents information related to a specific IP address.
func (*IPInfo) AddCommonFieldAlias ¶
AddCommonFieldAlias adds common field aliases to the FieldAlias map. It maps a database-specific field name to a common field name.
func (*IPInfo) GetData ¶
GetData retrieves the data for the given field. It first checks if the field exists in the Data map directly. If not, it checks the FieldAlias map to determine the corresponding database field and retrieves the value. Returns the value and a boolean indicating if the field was found.
func (*IPInfo) Output ¶
func (i *IPInfo) Output(dbFiled bool) *IPInfoOutput
Output constructs and returns an IPInfoOutput based on the current IPInfo. It decides whether to use the database field or the common field based on the dbFiled flag.
type IPInfoOutput ¶
type IPInfoOutput struct { IP string `json:"ip"` Net string `json:"net"` Data map[string]string `json:"data"` }
IPInfoOutput represents the structure for outputting IP information.
type Meta ¶
type Meta struct { // MetaVersion indicates the version of the metadata. MetaVersion int // Format represents the data format of the IP database. Format string // IPVersion indicates the version of the IP database (IPv4 or IPv6). IPVersion int // Fields lists the data fields available in the IP database. Fields []string // FieldAlias maps common field names to database-specific field names. FieldAlias map[string]string }
Meta represents the metadata for the IP database.
func (*Meta) AddCommonFieldAlias ¶
AddCommonFieldAlias adds aliases for common fields to the metadata. It checks if the provided database field exists in the metadata's fields.
func (*Meta) IsIPv4Support ¶
IsIPv4Support checks if the metadata supports IPv4.
func (*Meta) IsIPv6Support ¶
IsIPv6Support checks if the metadata supports IPv6.
func (*Meta) SupportFields ¶
SupportFields returns a map of fields that are supported by the metadata. It includes both the original fields and the alias fields.