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
| var listen = flag.String("l", ":8000", "订阅的监听端口")
var yport = flag.String("p", "443", "原服务的端口")
var yhost = flag.String("h", "", "原服务的域名或ip,默认空")
var yuuid = flag.String("u", "", "原服务的uuid,默认空")
var route = flag.String("r", "app", "访问订阅的路由")
func getFakeID() string { str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" strb := []byte(str) r := rand.New(rand.NewSource(time.Now().UnixNano())) var result []byte for i := 0; i < 22; i++ { result = append(result, strb[r.Intn(len(strb))]) } return string(result) }
func GetBody(ip, port string) []byte { path := "if5ax/?fakeid=" + getFakeID() + "&spid=81117&pid=81117&spip=" + ip + "&spport=" + port
host := "http://dir.v.wo.cn:809/" m := md5.Sum([]byte(path + "3d99ff138e1f41e931e58617e7d128e2")) key := hex.EncodeToString(m[:]) r, _ := http.Get(host + path + "&spkey=" + key) body, _ := io.ReadAll(r.Body)
return body }
func getUrl(w http.ResponseWriter, _ *http.Request) {
body := GetBody(*yhost, *yport)
rj := map[string]string{} json.Unmarshal(body, &rj)
pp := strings.Index(rj["url"], ":809") p := strings.Index(rj["url"], "/if5ax") t := strings.Index(rj["url"], "lsttm=") ip := rj["url"][7:pp]
path := rj["url"][p:] tt := rj["url"][t+6 : t+20]
vmess := []byte(`{"add":"` + ip + `","aid":"0","host":"` + ip + `","id":"` + *yuuid + `","net":"ws","path":"` + path + `","port":"809","ps":"联通809` + tt + `过期","sni":"","tls":"","type":"none","v":"2"}`) vmessUrl := []byte("vmess://" + base64.StdEncoding.EncodeToString(vmess)) final := base64.StdEncoding.EncodeToString(vmessUrl) fmt.Fprintf(w, final)
}
func main() { flag.Parse() if _, err := net.ResolveTCPAddr("tcp", *listen); err != nil { log.Fatalf("解析监听地址异常,%s", err) } http.HandleFunc("/"+*route, getUrl)
log.Println("订阅地址监听", *listen+"/"+*route, "中...") err := http.ListenAndServe(*listen, nil) if err != nil { log.Println("启动端口发生异常, 请检查端口是否被占用", err) time.Sleep(time.Minute) os.Exit(1) } }
|