diff --git a/.gitignore b/.gitignore index 25fd207..89c1377 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -ggrok \ No newline at end of file +ggrok +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..c3b03b6 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,26 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin +archives: + - replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' diff --git a/main.go b/main.go index a0f35dd..595dbb4 100644 --- a/main.go +++ b/main.go @@ -3,19 +3,15 @@ package main import ( "flag" "log" - "net/http" - "os" "github.com/onyas/ggrok/core" ) -var client bool var proxyServer string var port int var config *core.Config func init() { - flag.BoolVar(&client, "client", false, "start client") flag.StringVar(&proxyServer, "proxyServer", "", "provide server address, for example: https://proxy.yourdomain.com") flag.IntVar(&port, "port", -1, "provide port, for example: 8080") config = core.NewConfig() @@ -25,29 +21,16 @@ func main() { flag.Parse() log.SetFlags(0) - if client { - if proxyServer != "" { - saveToConfig(proxyServer) - return - } - - if port != -1 { - startProxy(port) - } - log.Println("Using -proxyServer or -port args") + if proxyServer != "" { + saveToConfig(proxyServer) return } - port := os.Getenv("PORT") - if port == "" { - log.Fatal("$PORT must be set") + if port != -1 { + startProxy(port) } - s := core.NewServer() + log.Println("Using -proxyServer or -port args") - http.HandleFunc("/$$ggrok", s.Register) - http.HandleFunc("/", s.Proxy) - log.Println("Server started at port:", port) - log.Fatal(http.ListenAndServe(":"+port, nil)) } func saveToConfig(proxyServer string) {