MCPcopy Create free account
hub / github.com/Hidden-Node/GooseRelayVPN-AndroidClient / main

Function main

cmd/server/main.go:18–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16var version = "dev"
17
18func main() {
19 configPath := flag.String("config", "server_config.json", "path to server config JSON")
20 showVersion := flag.Bool("version", false, "show version and exit")
21 flag.Parse()
22
23 if *showVersion {
24 fmt.Println(version)
25 return
26 }
27
28 cfg, err := config.LoadServer(*configPath)
29 if err != nil {
30 log.Fatalf("%v", err)
31 }
32
33 srv, err := exit.New(exit.Config{
34 ListenAddr: cfg.ListenAddr,
35 AESKeyHex: cfg.AESKeyHex,
36 DebugTiming: cfg.DebugTiming,
37 UpstreamProxy: cfg.UpstreamProxy,
38 InitialResponseBytesPreEncode: cfg.InitialResponseBytesPreEncode,
39 Version: version,
40 })
41 if err != nil {
42 log.Fatalf("exit: %v", err)
43 }
44
45 // Surface a few sanity-check URLs the operator can curl to verify the
46 // server is reachable from outside (Apps Script must be able to POST here).
47 _, port, _ := net.SplitHostPort(cfg.ListenAddr)
48 log.Printf("[exit] tunnel_key loaded (32 bytes)")
49 log.Printf("[exit] healthz: curl http://YOUR.VPS.IP:%s/healthz (should return HTTP 200)", port)
50 log.Printf("[exit] tunnel : POST http://YOUR.VPS.IP:%s/tunnel (this is the VPS_URL in Code.gs)", port)
51 if cfg.DebugTiming {
52 log.Printf("[exit] debug_timing enabled — per-session dial breakdown will be logged")
53 }
54 if cfg.UpstreamProxy != "" {
55 log.Printf("[exit] upstream_proxy enabled — outbound connections routed via SOCKS5 %s", cfg.UpstreamProxy)
56 }
57
58 if err := srv.ListenAndServe(); err != nil {
59 msg := err.Error()
60 if strings.Contains(msg, "address already in use") {
61 log.Fatalf("port %s is already in use — another goose-server may be running.\n Check with: sudo lsof -i :%s", port, port)
62 }
63 if strings.Contains(msg, "permission denied") {
64 log.Fatalf("permission denied binding %s — ports below 1024 require root, or pick a different server_port (e.g. 8443)", cfg.ListenAddr)
65 }
66 log.Fatalf("listen: %v", err)
67 }
68}

Callers

nothing calls this directly

Calls 4

LoadServerFunction · 0.92
NewFunction · 0.92
ListenAndServeMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected