Compare commits

...

9 commits

Author SHA1 Message Date
Anders Pitman
82aaf92dde
Update README.md 2024-03-24 14:15:50 -06:00
Anders Pitman
3f403d2cc2
Update README.md 2024-03-24 14:15:14 -06:00
Anders Pitman
f55a995069 Remove go implementation
Having go code in the repo may create confusion, as it was a
prototype that's no longer used.
2021-01-29 06:49:50 -07:00
Anders Pitman
419900c48c
Update README.md 2021-01-08 13:39:50 -07:00
Anders Pitman
194cc778eb
Update README.md 2021-01-08 13:39:26 -07:00
Anders Pitman
c6f1efe3f1
Update README.md 2020-10-14 15:17:37 -06:00
Anders Pitman
d545c2ed05 Remove sirtunnel from install script 2020-09-27 09:49:59 -06:00
Anders Pitman
594b414050 Update example 2020-09-27 09:47:17 -06:00
Anders Pitman
df98167eef Make sirtunnel.go match latest protocol 2020-09-27 09:42:39 -06:00
4 changed files with 13 additions and 54 deletions

View file

@ -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

View file

@ -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

View file

@ -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
View file

@ -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")
}