-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheck.go
41 lines (34 loc) · 792 Bytes
/
Check.go
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
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type MullvadResponse struct {
MullvadExitIP string `json:"mullvad_exit_ip"`
}
func main() {
resp, err := http.Get("https://am.i.mullvad.net/json")
if err != nil {
fmt.Println("Error making request to Mullvad API:", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return
}
var mullvadResponse MullvadResponse
err = json.Unmarshal(body, &mullvadResponse)
if err != nil {
fmt.Println("Error unmarshalling response:", err)
return
}
if mullvadResponse.MullvadExitIP == "" {
fmt.Println("Not connected to Mullvad VPN. Aborting...")
return
}
// Other checks or additional actions can go here
}