-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.go
46 lines (36 loc) · 924 Bytes
/
main.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
package main
import (
"encoding/base64"
"flag"
"log"
"net/http"
"time"
)
var nekoXProxyString string
var nekoXProxyBaseDomain string
var nekoXProxyDomains []string
var client *http.Client
func main() {
listen := flag.String("l", "127.0.0.1:26641", "HttpProxy listen port")
_nekoXProxyString := flag.String("p", "", "NekoX Proxy URL (keep empty if you don't know)")
flag.Parse()
var ok bool
if *_nekoXProxyString != "" {
ok = parseNekoXString(base64.RawURLEncoding.EncodeToString([]byte(*_nekoXProxyString)))
} else {
log.Println("Getting NekoX public proxy...")
ok = parseNekoXString(getNekoXString())
}
if !ok {
log.Println("Failed to parse NekoX proxy.")
return
}
client = &http.Client{}
http.HandleFunc("/", relay)
server := &http.Server{
Addr: *listen,
WriteTimeout: 10 * time.Second,
}
log.Println("Telegram HTTP Proxy started at", *listen)
server.ListenAndServe()
}