-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.go
More file actions
210 lines (191 loc) · 5.79 KB
/
models.go
File metadata and controls
210 lines (191 loc) · 5.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
package geoip
import (
"encoding/json"
)
type IP struct {
IP string `json:"ip"`
CountryName string `json:"country_name"`
CountryCode string `json:"country_code"`
RegionName string `json:"region_name"`
RegionCode string `json:"region_code"`
City string `json:"city"`
ZipCode string `json:"zipcode"`
Timezone Timezone `json:"timezone"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
MetroCode int `json:"metro_code"`
ISP string `json:"isp"`
Org string `json:"org"`
As string `json:"as"`
Location Location `json:"location"`
Currency Currency `json:"currency"`
Connection Connection `json:"connection"`
}
func (ip *IP) ToJSONString() string {
data, err := json.Marshal(ip)
if err != nil {
return ""
}
return string(data)
}
type IPResult struct {
}
type DebugResult struct {
RawResponse []byte `json:"-"`
RequestedURL string `json:"requested_url"`
Status string `json:"status"`
StatusCode int `json:"status_code"`
}
// freegeoip.net IP
type IPStackResult struct {
IPResult
IP string `json:"ip"`
Hostname string `json:"hostname"`
Type string `json:"type"`
ContinentCode string `json:"continent_code"`
ContinentName string `json:"continent_name"`
CountryCode string `json:"country_code"`
CountryName string `json:"country_name"`
RegionCode string `json:"region_code"`
RegionName string `json:"region_name"`
City string `json:"city"`
ZipCode string `json:"zip"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Location Location `json:"location"`
Timezone Timezone `json:"time_zone"`
Currency Currency `json:"currency"`
MetroCode int `json:"metro_code"`
}
type Timezone struct {
ID string `json:"id"`
CurrentTime string `json:"current_time"`
GMTOffset int `json:"gmt_offset"`
Code string `json:"code"`
IsDST bool `json:"is_daylight_saving"`
}
// "time_zone": {
// "id": "America/Los_Angeles",
// "current_time": "2018-03-29T07:35:08-07:00",
// "gmt_offset": -25200,
// "code": "PDT",
// "is_daylight_saving": true
// },
type Location struct {
GeonameId int `json:"geoname_id"`
Capital string `json:"capital"`
Languages []map[string]interface{} `json:"languages"`
CountryFlag string `json:"country_flag"`
CountryFlagEmoji string `json:"country_flag_emoji"`
CountryFlagEmojiUnicode string `json:"country_flag_emoji_unicode"`
CallingCode string `json:"calling_code"`
IsEU bool `json:"is_eu"`
}
// "location": {
// "geoname_id": 5368361,
// "capital": "Washington D.C.",
// "languages": [
// {
// "code": "en",
// "name": "English",
// "native": "English"
// }
// ],
// "country_flag": "https://assets.ipstack.com/images/assets/flags_svg/us.svg",
// "country_flag_emoji": "🇺🇸",
// "country_flag_emoji_unicode": "U+1F1FA U+1F1F8",
// "calling_code": "1",
// "is_eu": false
// },
type Currency struct {
Code string `json:"code"`
Name string `json:"name"`
Plural string `json:"plural"`
Symbol string `json:"symbol"`
SymbolNative string `json:"symbol_native"`
}
// "currency": {
// "code": "USD",
// "name": "US Dollar",
// "plural": "US dollars",
// "symbol": "$",
// "symbol_native": "$"
// },
type Connection struct {
ASN int `json:"asn"`
ISP string `json:"isp"`
}
// "connection": {
// "asn": 25876,
// "isp": "Los Angeles Department of Water & Power"
// },
type Security struct {
IsProxy bool `json:"is_proxy"`
// ProxyType
IsCrawler bool `json:"is_crawler"`
// CrawlerName
// CrawlerType
IsTOR bool `json:"is_tor"`
ThreatLevel string `json:"threat_level"`
// ThreatTypes string `json:"threat_types"`
}
// "security": {
// "is_proxy": false,
// "proxy_type": null,
// "is_crawler": false,
// "crawler_name": null,
// "crawler_type": null,
// "is_tor": false,
// "threat_level": "low",
// "threat_types": null
// }
// {
// "ip": "134.201.250.155",
// "hostname": "134.201.250.155",
// "type": "ipv4",
// "continent_code": "NA",
// "continent_name": "North America",
// "country_code": "US",
// "country_name": "United States",
// "region_code": "CA",
// "region_name": "California",
// "city": "Los Angeles",
// "zip": "90013",
// "latitude": 34.0453,
// "longitude": -118.2413,
// }
// ip-api.com IP
// usage limits
// http://ip-api.com/docs/api:json#usage_limits
type IPApiResult struct {
IPResult
IP string `json:"ip"`
CountryCode string `json:"countryCode"`
CountryName string `json:"country"`
RegionCode string `json:"region_code"`
RegionName string `json:"regionName"`
City string `json:"city"`
ZipCode string `json:"zip"`
Timezone string `json:"timezone"`
Latitude float64 `json:"lat"`
Longitude float64 `json:"lon"`
ISP string `json:"isp"`
Org string `json:"org"`
As string `json:"as"`
}
// {
// "as": "AS14907 Wikimedia Foundation, Inc.",
// "city": "San Francisco",
// "country": "United States",
// "countryCode": "US",
// "isp": "Wikimedia Foundation, Inc.",
// "lat": 37.7898,
// "lon": -122.3942,
// "org": "Wikimedia Foundation, Inc.",
// "query": "208.80.152.201",
// "region": "CA",
// "regionName": "California",
// "status": "success",
// "timezone": "America/Los_Angeles",
// "zip": "94105"
// }