Skip to content

Commit 0bfbaf6

Browse files
committed
build client
1 parent 7f40f7e commit 0bfbaf6

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
ggrok
1+
ggrok
2+
dist/

.goreleaser.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
builds:
4+
- env:
5+
- CGO_ENABLED=0
6+
goos:
7+
- linux
8+
- windows
9+
- darwin
10+
archives:
11+
- replacements:
12+
darwin: Darwin
13+
linux: Linux
14+
windows: Windows
15+
386: i386
16+
amd64: x86_64
17+
checksum:
18+
name_template: 'checksums.txt'
19+
snapshot:
20+
name_template: "{{ incpatch .Version }}-next"
21+
changelog:
22+
sort: asc
23+
filters:
24+
exclude:
25+
- '^docs:'
26+
- '^test:'

main.go

+5-22
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@ package main
33
import (
44
"flag"
55
"log"
6-
"net/http"
7-
"os"
86

97
"github.com/onyas/ggrok/core"
108
)
119

12-
var client bool
1310
var proxyServer string
1411
var port int
1512
var config *core.Config
1613

1714
func init() {
18-
flag.BoolVar(&client, "client", false, "start client")
1915
flag.StringVar(&proxyServer, "proxyServer", "", "provide server address, for example: https://proxy.yourdomain.com")
2016
flag.IntVar(&port, "port", -1, "provide port, for example: 8080")
2117
config = core.NewConfig()
@@ -25,29 +21,16 @@ func main() {
2521
flag.Parse()
2622
log.SetFlags(0)
2723

28-
if client {
29-
if proxyServer != "" {
30-
saveToConfig(proxyServer)
31-
return
32-
}
33-
34-
if port != -1 {
35-
startProxy(port)
36-
}
37-
log.Println("Using -proxyServer or -port args")
24+
if proxyServer != "" {
25+
saveToConfig(proxyServer)
3826
return
3927
}
4028

41-
port := os.Getenv("PORT")
42-
if port == "" {
43-
log.Fatal("$PORT must be set")
29+
if port != -1 {
30+
startProxy(port)
4431
}
45-
s := core.NewServer()
32+
log.Println("Using -proxyServer or -port args")
4633

47-
http.HandleFunc("/$$ggrok", s.Register)
48-
http.HandleFunc("/", s.Proxy)
49-
log.Println("Server started at port:", port)
50-
log.Fatal(http.ListenAndServe(":"+port, nil))
5134
}
5235

5336
func saveToConfig(proxyServer string) {

0 commit comments

Comments
 (0)