Refactor: split up files
This commit is contained in:
parent
4deae6b72c
commit
3f85ef852d
38
api.go
Normal file
38
api.go
Normal file
@ -0,0 +1,38 @@
|
||||
package mullsox
|
||||
|
||||
type MyIPDetails struct {
|
||||
Ip string `json:"ip"`
|
||||
Country string `json:"country"`
|
||||
City string `json:"city"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
Latitude float64 `json:"latitude"`
|
||||
MullvadExitIp bool `json:"mullvad_exit_ip"`
|
||||
MullvadExitIpHostname string `json:"mullvad_exit_ip_hostname"`
|
||||
MullvadServerType string `json:"mullvad_server_type"`
|
||||
Blacklisted struct {
|
||||
Blacklisted bool `json:"blacklisted"`
|
||||
Results []struct {
|
||||
Name string `json:"name"`
|
||||
Link string `json:"link"`
|
||||
Blacklisted bool `json:"blacklisted"`
|
||||
} `json:"results"`
|
||||
} `json:"blacklisted"`
|
||||
Organization string `json:"organization"`
|
||||
}
|
||||
|
||||
type MullvadServer struct {
|
||||
Hostname string `json:"hostname"`
|
||||
CountryCode string `json:"country_code"`
|
||||
CountryName string `json:"country_name"`
|
||||
CityCode string `json:"city_code"`
|
||||
CityName string `json:"city_name"`
|
||||
Active bool `json:"active"`
|
||||
Owned bool `json:"owned"`
|
||||
Provider string `json:"provider"`
|
||||
Ipv4AddrIn string `json:"ipv4_addr_in"`
|
||||
Ipv6AddrIn string `json:"ipv6_addr_in"`
|
||||
NetworkPortSpeed int `json:"network_port_speed"`
|
||||
Pubkey string `json:"pubkey"`
|
||||
MultihopPort int `json:"multihop_port"`
|
||||
SocksName string `json:"socks_name"`
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package mullsox
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -9,9 +9,9 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const AimHost = "am.i.mullvad.net"
|
||||
const Ipv4Endpoint = `https://ipv4.` + AimHost
|
||||
const Ipv6Endpoint = `https://ipv6.` + AimHost
|
||||
const baseEndpoint = "am.i.mullvad.net"
|
||||
const Ipv4Endpoint = `https://ipv4.` + baseEndpoint
|
||||
const Ipv6Endpoint = `https://ipv6.` + baseEndpoint
|
||||
|
||||
func CheckIP4(ctx context.Context, h *http.Client) (details *MyIPDetails, err error) {
|
||||
return checkIP(ctx, h, false)
|
||||
@ -102,40 +102,3 @@ func checkIP(ctx context.Context, h *http.Client, ipv6 bool) (details *MyIPDetai
|
||||
err = json.Unmarshal(cytes, &details)
|
||||
return
|
||||
}
|
||||
|
||||
type MyIPDetails struct {
|
||||
Ip string `json:"ip"`
|
||||
Country string `json:"country"`
|
||||
City string `json:"city"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
Latitude float64 `json:"latitude"`
|
||||
MullvadExitIp bool `json:"mullvad_exit_ip"`
|
||||
MullvadExitIpHostname string `json:"mullvad_exit_ip_hostname"`
|
||||
MullvadServerType string `json:"mullvad_server_type"`
|
||||
Blacklisted struct {
|
||||
Blacklisted bool `json:"blacklisted"`
|
||||
Results []struct {
|
||||
Name string `json:"name"`
|
||||
Link string `json:"link"`
|
||||
Blacklisted bool `json:"blacklisted"`
|
||||
} `json:"results"`
|
||||
} `json:"blacklisted"`
|
||||
Organization string `json:"organization"`
|
||||
}
|
||||
|
||||
type MullvadServer struct {
|
||||
Hostname string `json:"hostname"`
|
||||
CountryCode string `json:"country_code"`
|
||||
CountryName string `json:"country_name"`
|
||||
CityCode string `json:"city_code"`
|
||||
CityName string `json:"city_name"`
|
||||
Active bool `json:"active"`
|
||||
Owned bool `json:"owned"`
|
||||
Provider string `json:"provider"`
|
||||
Ipv4AddrIn string `json:"ipv4_addr_in"`
|
||||
Ipv6AddrIn string `json:"ipv6_addr_in"`
|
||||
NetworkPortSpeed int `json:"network_port_speed"`
|
||||
Pubkey string `json:"pubkey"`
|
||||
MultihopPort int `json:"multihop_port"`
|
||||
SocksName string `json:"socks_name"`
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package mullsox
|
||||
|
||||
import (
|
||||
"context"
|
Loading…
Reference in New Issue
Block a user