File size: 3,342 Bytes
7a4c980 | 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 | package main
import (
"crypto/rand"
"encoding/base64"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"strings"
"time"
"golang.org/x/crypto/curve25519"
)
func check(err error) {
if err != nil {
panic(err)
}
}
type response struct {
Result *struct {
ID string
Type string
Model string
Name string
Key string
Account *struct {
ID string
AccountType string `json:"account_type"`
Created *time.Time
Updated *time.Time
PremiumData uint `json:"premium_data"`
Quota uint
Usage uint
WarpPlus bool `json:"warp_plus"`
ReferralCount uint `json:"referral_count"`
ReferralRenewalCountdown uint `json:"referral_renewal_countdown"`
Role string
License string
}
Config *struct {
ClientID string `json:"client_id"`
Peers []struct {
PublicKey string `json:"public_key"`
Endpoint *struct {
V4 string
V6 string
Host string
}
}
Interface *struct {
Addresses *struct {
V4 string
V6 string
}
}
Services *struct {
HTTPProxy string `json:"http_proxy"`
}
}
Token string
WarpEnabled bool `json:"warp_enabled"`
WaitlistEnabled bool `json:"waitlist_enabled"`
Created *time.Time
Updated *time.Time
Tos *time.Time
Place uint
Locale string
Enabled bool
InstallID string `json:"install_id"`
FCMToken string `json:"fcm_token"`
}
Success bool
Errors []string
Messages []string
}
func main() {
pk := new([32]byte)
sk := new([32]byte)
_, err := io.ReadFull(rand.Reader, sk[:])
check(err)
curve25519.ScalarBaseMult(pk, sk)
reqBody := strings.NewReader(`{"key":"` + base64.StdEncoding.EncodeToString(pk[:]) + `","tos":"` + time.Now().Format(time.RFC3339) + `","type":"ios","model":"iPhone11,6","fcm_token":"","device_token":""}`)
req, err := http.NewRequest("POST", "https://api.cloudflareclient.com/v0i2003111800/reg", reqBody)
check(err)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "*/*")
req.Header.Set("User-Agent", "1.1.1.1/2003111800.1")
req.Header.Set("Accept-Language", "en-us")
res, err := http.DefaultClient.Do(req)
check(err)
resBytes, err := ioutil.ReadAll(res.Body)
check(err)
var response *response
err = json.Unmarshal(resBytes, &response)
check(err)
reqBody = strings.NewReader(`{"warp_enabled":true}`)
req, err = http.NewRequest("PATCH", "https://api.cloudflareclient.com/v0i2003111800/reg/"+response.Result.ID, reqBody)
check(err)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "*/*")
req.Header.Set("User-Agent", "1.1.1.1/2003111800.1")
req.Header.Set("Accept-Language", "en-us")
req.Header.Set("Authorization", "Bearer "+response.Result.Token)
res, err = http.DefaultClient.Do(req)
check(err)
fmt.Println(`[Interface]
PrivateKey = ` + base64.StdEncoding.EncodeToString(sk[:32]) + `
DNS = 1.1.1.1
Address = ` + response.Result.Config.Interface.Addresses.V4 + `/32
[Peer]
PublicKey = ` + response.Result.Config.Peers[0].PublicKey + `
AllowedIPs = 0.0.0.0/0
Endpoint = 162.159.192.5:2408
`)
}
|