Remove Forward struct that wasn't doing anything
This commit is contained in:
16
main.go
16
main.go
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user