diff options
| author | Melonai <einebeere@gmail.com> | 2021-07-25 23:56:25 +0200 |
|---|---|---|
| committer | Melonai <einebeere@gmail.com> | 2021-07-26 00:16:10 +0200 |
| commit | 309490948bea7cdfc4ba8b0b11966185fdd35aa9 (patch) | |
| tree | 70c091117225b0b5f19d4691024b739c478bd32d /main.go | |
| download | portgate-309490948bea7cdfc4ba8b0b11966185fdd35aa9.tar.zst portgate-309490948bea7cdfc4ba8b0b11966185fdd35aa9.zip | |
Proxy requests to target ports
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/main.go b/main.go new file mode 100644 index 0000000..9870dee --- /dev/null +++ b/main.go @@ -0,0 +1,29 @@ +package main + +import ( + "github.com/valyala/fasthttp" + "log" +) + +func main() { + log.Print("Starting Portgate...") + + // Get global Portgate config. + config, err := GetConfig() + if err != nil { + log.Fatal("Failed to get Portgate config.") + } + + // Create handler for requests + handler := RequestHandler{ + config: &config, + client: fasthttp.Client{}, + } + + // Start to listen to the outside world. + log.Print("Listening for requests on port 8080.") + err = fasthttp.ListenAndServe(config.PortgateAddress(), handler.handleRequest) + if err != nil { + log.Fatalf("Portgate server could not be started: %s", err) + } +} |
