Loop on errors, rather than failing
This commit is contained in:
16
main.go
16
main.go
@@ -35,11 +35,12 @@ func Forward(server *tsnet.Server, proto, port, dst string, finish chan error) {
|
||||
if err != nil {
|
||||
finish <- err
|
||||
}
|
||||
defer ln.Close()
|
||||
err = netforward.Forward(Dialer { proto: proto, addr: dst }, ln)
|
||||
if err != nil {
|
||||
finish <- err
|
||||
defer ln.Close();
|
||||
for true {
|
||||
err = netforward.Forward(Dialer { proto: proto, addr: dst }, ln);
|
||||
log.Print(err);
|
||||
}
|
||||
finish <- err;
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -58,12 +59,11 @@ func main() {
|
||||
}
|
||||
defer s.Close()
|
||||
|
||||
err_chan := make(chan error)
|
||||
finish := make(chan error)
|
||||
for _, arg := range os.Args[2:] {
|
||||
args := strings.SplitN(arg, ":", 3)
|
||||
proto, port, dst := args[0], args[1], args[2]
|
||||
go Forward(s, proto, port, dst, err_chan);
|
||||
go Forward(s, proto, port, dst, finish);
|
||||
}
|
||||
err := <- err_chan
|
||||
log.Fatal(err)
|
||||
<- finish;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user