Skip to content

Commit f691519

Browse files
committed
Make godoc a little nicer
1 parent 5cccfea commit f691519

File tree

2 files changed

+8
-33
lines changed

2 files changed

+8
-33
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# vpnapi
2-
A Go client for vpnapi.io
2+
A Go client for [vpnapi.io](https://vpnapi.io)
33

44
[![Go Reference](https://pkg.go.dev/badge/github.com/bitlux/vpnapi.svg)](https://pkg.go.dev/github.com/bitlux/vpnapi)
55
[![Lint Status](https://github.com/bitlux/vpnapi/workflows/golangci-lint/badge.svg)](https://github.com/bitlux/vpnapi/actions?query=workflow%3Agolangci-lint)

vpnapi.go

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ const baseURL = "https://vpnapi.io/api/"
1212

1313
var ErrRateLimited = errors.New("rate limited, try again later")
1414

15+
// The security section of a response
1516
type Security struct {
1617
VPN bool `json:"vpn"`
1718
Proxy bool `json:"proxy"`
1819
Tor bool `json:"tor"`
1920
Relay bool `json:"relay"`
2021
}
2122

23+
// The location section of a response
2224
type Location struct {
2325
City string `json:"city"`
2426
Region string `json:"region"`
@@ -34,27 +36,32 @@ type Location struct {
3436
IsInEuropeanUnion bool `json:"is_in_european_union"`
3537
}
3638

39+
// The network section of a response
3740
type Network struct {
3841
Network string `json:"network"`
3942
AutonomousSystemNumber string `json:"autonomous_system_number"`
4043
AutonomousSystemOrganization string `json:"autonomous_system_organization"`
4144
}
4245

46+
// The response type returned from a query
4347
type Response struct {
4448
IP string `json:"ip"`
4549
Security Security `json:"security"`
4650
Location Location `json:"location"`
4751
Network Network `json:"network"`
4852
}
4953

54+
// Client makes queries to the API.
5055
type Client struct {
5156
apiKey string
5257
}
5358

59+
// New creates a new Client. Obtain an API key by registering at vpnapi.io.
5460
func New(apiKey string) *Client {
5561
return &Client{apiKey: apiKey}
5662
}
5763

64+
// Query queries the API for details about ip.
5865
func (c *Client) Query(ip string) (*Response, error) {
5966
resp, err := http.Get(baseURL + ip + "?" + c.apiKey)
6067
if err != nil {
@@ -81,35 +88,3 @@ func (c *Client) Query(ip string) (*Response, error) {
8188

8289
return ret, nil
8390
}
84-
85-
/*
86-
{
87-
"ip": "8.8.8.8",
88-
"security": {
89-
"vpn": false,
90-
"proxy": false,
91-
"tor": false,
92-
"relay": false,
93-
},
94-
"location": {
95-
"city": "",
96-
"region": "",
97-
"country": "United States",
98-
"continent": "North America",
99-
"region_code": "",
100-
"country_code": "US",
101-
"continent_code": "NA",
102-
"latitude": "37.7510",
103-
"longitude": "-97.8220",
104-
"time_zone": "America/Chicago",
105-
"locale_code": "en",
106-
"metro_code": "",
107-
"is_in_european_union": false
108-
},
109-
"network": {
110-
"network": "8.8.8.0/24",
111-
"autonomous_system_number": "AS15169",
112-
"autonomous_system_organization": "GOOGLE"
113-
}
114-
}
115-
*/

0 commit comments

Comments
 (0)