-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtg.go
87 lines (76 loc) · 2.16 KB
/
tg.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
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
package main
import (
"encoding/base64"
"fmt"
"net/url"
"strings"
)
var mapper = make(map[string]int)
func parseNekoXString(a string) bool {
// fmt.Println(a)
b, _ := base64.RawURLEncoding.DecodeString(a)
url, err := url.Parse(string(b))
if err != nil {
return false
}
pldstr, _ := base64.RawURLEncoding.DecodeString(url.Query().Get("payload"))
plds := strings.Split(string(pldstr), ",")
nekoXProxyBaseDomain = url.Host
nekoXProxyDomains = append([]string{""}, plds...)
putmapper := func(ip string, dc int) {
mapper[ip] = dc
}
putmapper("149.154.175.5", 1)
putmapper("95.161.76.100", 2)
putmapper("149.154.175.100", 3)
putmapper("149.154.167.91", 4)
putmapper("149.154.167.92", 4)
putmapper("149.154.171.5", 5)
putmapper("2001:b28:f23d:f001:0000:0000:0000:000a", 1)
putmapper("2001:67c:4e8:f002:0000:0000:0000:000a", 2)
putmapper("2001:b28:f23d:f003:0000:0000:0000:000a", 3)
putmapper("2001:67c:4e8:f004:0000:0000:0000:000a", 4)
putmapper("2001:b28:f23f:f005:0000:0000:0000:000a", 5)
putmapper("149.154.161.144", 2)
putmapper("149.154.167.", 2)
putmapper("149.154.175.1", 3)
putmapper("91.108.4.", 4)
putmapper("149.154.164.", 4)
putmapper("149.154.165.", 4)
putmapper("149.154.166.", 4)
putmapper("91.108.56.", 5)
putmapper("2001:b28:f23d:f001:0000:0000:0000:000d", 1)
putmapper("2001:67c:4e8:f002:0000:0000:0000:000d", 2)
putmapper("2001:b28:f23d:f003:0000:0000:0000:000d", 3)
putmapper("2001:67c:4e8:f004:0000:0000:0000:000d", 4)
putmapper("2001:b28:f23f:f005:0000:0000:0000:000d", 5)
putmapper("149.154.175.40", 6)
putmapper("149.154.167.40", 7)
putmapper("149.154.175.117", 8)
putmapper("2001:b28:f23d:f001:0000:0000:0000:000e", 6)
putmapper("2001:67c:4e8:f002:0000:0000:0000:000e", 7)
putmapper("2001:b28:f23d:f003:0000:0000:0000:000e", 8)
return true
}
func dc2wsurl(dc int) string {
if dc == 0 {
return ""
}
return fmt.Sprintf("https://%s.%s/api", nekoXProxyDomains[dc], nekoXProxyBaseDomain)
}
func ip2dc(ip string) int {
for k, v := range mapper {
if ip == k {
return v
}
}
for k, v := range mapper {
if strings.HasPrefix(ip, k) {
return v
}
}
return 0
}
func ip2wsurl(ip string) string {
return dc2wsurl(ip2dc(ip))
}