Compare commits
	
		
			3 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 4c592f1407 | |||
| 5e9cac53b9 | |||
| 47d220731e | 
| @ -2,12 +2,17 @@ package main | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"crypto/tls" | 	"crypto/tls" | ||||||
|  | 	"encoding/base64" | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"flag" | 	"flag" | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  | 	"net" | ||||||
| 	"net/http" | 	"net/http" | ||||||
|  | 	"net/url" | ||||||
| 	"os" | 	"os" | ||||||
|  | 	"regexp" | ||||||
| 	"runtime" | 	"runtime" | ||||||
|  | 	"strings" | ||||||
|  |  | ||||||
| 	_ "net/http/pprof" | 	_ "net/http/pprof" | ||||||
|  |  | ||||||
| @ -22,9 +27,34 @@ var ( | |||||||
| 	pprofEnabled  = os.Getenv("PROFILING") != "" | 	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() { | func init() { | ||||||
| 	gost.SetLogger(&gost.LogLogger{}) | 	gost.SetLogger(&gost.LogLogger{}) | ||||||
|  | 	shortcut() | ||||||
| 	var ( | 	var ( | ||||||
| 		printVersion bool | 		printVersion bool | ||||||
| 	) | 	) | ||||||
| @ -40,7 +70,6 @@ func init() { | |||||||
| 		flag.StringVar(&pprofAddr, "P", ":6060", "profiling HTTP server address") | 		flag.StringVar(&pprofAddr, "P", ":6060", "profiling HTTP server address") | ||||||
| 	} | 	} | ||||||
| 	flag.Parse() | 	flag.Parse() | ||||||
|  |  | ||||||
| 	if printVersion { | 	if printVersion { | ||||||
| 		fmt.Fprintf(os.Stdout, "gost %s (%s %s/%s)\n", | 		fmt.Fprintf(os.Stdout, "gost %s (%s %s/%s)\n", | ||||||
| 			gost.Version, runtime.Version(), runtime.GOOS, runtime.GOARCH) | 			gost.Version, runtime.Version(), runtime.GOOS, runtime.GOARCH) | ||||||
| @ -58,6 +87,8 @@ func init() { | |||||||
| 		flag.PrintDefaults() | 		flag.PrintDefaults() | ||||||
| 		os.Exit(0) | 		os.Exit(0) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	fmt.Println(4) | ||||||
| } | } | ||||||
|  |  | ||||||
| func main() { | func main() { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	