Compare commits

..

No commits in common. "jimmyjin" and "master" have entirely different histories.

View File

@ -2,17 +2,12 @@ package main
import (
"crypto/tls"
"encoding/base64"
"errors"
"flag"
"fmt"
"net"
"net/http"
"net/url"
"os"
"regexp"
"runtime"
"strings"
_ "net/http/pprof"
@ -27,34 +22,9 @@ var (
pprofEnabled = os.Getenv("PROFILING") != ""
)
func shortcut() {
strPre := "gost-"
if len(os.Args) < 2 {
fileName := os.Args[0]
fmt.Println("fileName:" + fileName)
reg := regexp.MustCompile(strPre + "(\\w*\\.?)(\\w*\\.?){1}\\.(com.cn|net.cn|gov.cn|org\\.nz|org.cn|com|net|org|gov|cc|biz|info|cn|co|cx|cc|ink)")
data := reg.Find([]byte(fileName))
hostName := strings.ReplaceAll(string(data), strPre, "")
fmt.Println("host:" + hostName)
os.Args = append(os.Args, shortcutsGetDnsConfig(hostName)...)
}
}
func shortcutsGetDnsConfig(pwdHost string) []string {
addr, err := net.LookupTXT(pwdHost)
if err != nil {
fmt.Println("The network is not connected. Please check the network, or contact the developer!")
return make([]string, 0)
}
dnsConfig := addr[0]
decoded, _ := base64.URLEncoding.DecodeString(dnsConfig[2:])
dnsConfigDec, _ := url.PathUnescape(string(decoded))
fmt.Println("dnsConfigDec:" + dnsConfigDec)
return strings.Split(dnsConfigDec, " ")
}
func init() {
gost.SetLogger(&gost.LogLogger{})
shortcut()
var (
printVersion bool
)
@ -70,6 +40,7 @@ func init() {
flag.StringVar(&pprofAddr, "P", ":6060", "profiling HTTP server address")
}
flag.Parse()
if printVersion {
fmt.Fprintf(os.Stdout, "gost %s (%s %s/%s)\n",
gost.Version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
@ -87,8 +58,6 @@ func init() {
flag.PrintDefaults()
os.Exit(0)
}
fmt.Println(4)
}
func main() {