Remove Forward struct that wasn't doing anything

This commit is contained in:
bluepython508
2025-04-09 01:14:14 +01:00
parent 5a9cfc022c
commit eccd448453

16
main.go
View File

@@ -19,23 +19,17 @@ type Dialer struct{
addr string;
}
type Forward struct{
proto string;
port string;
dst string;
}
func (dialer Dialer) Dial() (net.Conn, error) {
return net.Dial(dialer.proto, dialer.addr)
}
func (forward Forward) Run(server *tsnet.Server, finish chan error) {
ln, err := server.Listen(forward.proto, fmt.Sprint(":", forward.port))
func Forward(server *tsnet.Server, proto, port, dst string, finish chan error) {
ln, err = server.Listen(proto, fmt.Sprint(":", port))
defer ln.Close()
if err != nil {
finish <- err
}
err = netforward.Forward(Dialer { proto: forward.proto, addr: forward.dst }, ln)
err = netforward.Forward(Dialer { proto: proto, addr: dst }, ln)
if err != nil {
finish <- err
}
@@ -61,9 +55,7 @@ func main() {
for _, arg := range os.Args[2:] {
args := strings.SplitN(arg, ":", 3)
proto, port, dst := args[0], args[1], args[2]
go func() {
Forward { proto, port, dst }.Run(s, err_chan);
}();
go Forward(s, proto, port, dst, err_chan);
}
err := <- err_chan
log.Fatal(err)