Compare commits
9 commits
Author | SHA1 | Date | |
---|---|---|---|
|
82aaf92dde | ||
|
3f403d2cc2 | ||
|
f55a995069 | ||
|
419900c48c | ||
|
194cc778eb | ||
|
c6f1efe3f1 | ||
|
d545c2ed05 | ||
|
594b414050 | ||
|
df98167eef |
4 changed files with 13 additions and 54 deletions
13
README.md
13
README.md
|
@ -20,7 +20,7 @@ And you run the following command on your laptop:
|
|||
ssh -tR 9001:localhost:8080 example.com sirtunnel.py sub1.example.com 9001
|
||||
```
|
||||
|
||||
Now any requests to `https://sub.example.com` will be proxied to your local
|
||||
Now any requests to `https://sub1.example.com` will be proxied to your local
|
||||
webserver.
|
||||
|
||||
|
||||
|
@ -77,6 +77,17 @@ recommended), setting the `CAP_NET_BIND_SERVICE` capability on the Caddy binary
|
|||
to a different port (say 9000) and using something like iptables to forward
|
||||
to that port.
|
||||
|
||||
# Future Features
|
||||
|
||||
SirTunnel is intended to be a minimal tool. As such, I'm unlikely to add many
|
||||
features moving forward. However, the simplicity makes it easier to modify
|
||||
for your needs. If you find a feature missing, maybe one of the forks below
|
||||
has what you need or gives you some ideas:
|
||||
|
||||
* https://github.com/matiboy/SirTunnel adds functionality to help multiple
|
||||
users avoid overwriting each others' tunnels.
|
||||
* https://github.com/daps94/SirTunnel implements tunnel checking and auto
|
||||
cleanup to address issue with stale tunnels.
|
||||
|
||||
|
||||
[0]: https://github.com/anderspitman/awesome-tunneling
|
||||
|
|
|
@ -4,4 +4,4 @@ domain=$1
|
|||
serverPort=$2
|
||||
localPort=$3
|
||||
|
||||
ssh -t -R $serverPort:localhost:$localPort $domain sirtunnel $domain:$serverPort
|
||||
ssh -t -R $serverPort:localhost:$localPort $domain sirtunnel $domain $serverPort
|
|
@ -1,7 +1,6 @@
|
|||
#/bin/bash
|
||||
|
||||
caddyVersion=2.1.1
|
||||
sirtunnelVersion=0.1.0
|
||||
|
||||
echo Download Caddy
|
||||
caddyGz=caddy_${caddyVersion}_linux_amd64.tar.gz
|
||||
|
|
51
main.go
51
main.go
|
@ -1,51 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"net/http"
|
||||
"bytes"
|
||||
)
|
||||
|
||||
|
||||
func main() {
|
||||
|
||||
args := os.Args[1:]
|
||||
tunnelSpecParts := strings.Split(args[0], ":")
|
||||
tunnelId := args[0]
|
||||
host := tunnelSpecParts[0]
|
||||
port := tunnelSpecParts[1]
|
||||
|
||||
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")
|
||||
}
|
Loading…
Reference in a new issue