From f55a995069e17c43ced85ab3b22986e060e9b17b Mon Sep 17 00:00:00 2001 From: Anders Pitman Date: Fri, 29 Jan 2021 06:49:50 -0700 Subject: [PATCH] Remove go implementation Having go code in the repo may create confusion, as it was a prototype that's no longer used. --- sirtunnel.go | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 sirtunnel.go diff --git a/sirtunnel.go b/sirtunnel.go deleted file mode 100644 index aa87b45..0000000 --- a/sirtunnel.go +++ /dev/null @@ -1,49 +0,0 @@ -package main - -import ( - "fmt" - "os" - "os/signal" - "net/http" - "bytes" -) - - -func main() { - - args := os.Args[1:] - host := args[0] - port := args[1] - tunnelId := host + "-" + port - - client := &http.Client{} - - caddyAddRouteStr := fmt.Sprintf("{\"@id\":\"%s\",\"match\":[{\"host\":[\"%s\"]}],\"handle\":[{\"handler\":\"reverse_proxy\",\"upstreams\":[{\"dial\":\":%s\"}]}]}", tunnelId, host, port); - - resp, err := http.Post("http://127.0.0.1:2019/config/apps/http/servers/sirtunnel/routes", "application/json", bytes.NewBuffer([]byte(caddyAddRouteStr))) - - if err != nil { - fmt.Println("Tunnel creation failed") - panic(err) - } - defer resp.Body.Close() - - fmt.Println("Tunnel created successfully") - - // wait for CTRL-C - c := make(chan os.Signal, 1) - signal.Notify(c, os.Interrupt) - <-c - - fmt.Println("Cleaning up tunnel") - - req, err := http.NewRequest("DELETE", fmt.Sprintf("http://127.0.0.1:2019/id/%s", tunnelId), nil) - if err != nil { - panic(err) - } - - req.Header.Add("Content-Type", "application/json") - _, err = client.Do(req) - - fmt.Println("Exiting") -}