]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/cypherpunks.ru/govpn/cmd/govpn-client/main.go
Reconnect client after timeout, do not exit
[govpn.git] / src / cypherpunks.ru / govpn / cmd / govpn-client / main.go
index 3d8cbe65953fd935f480a9aefde3efec28ed61d8..7a858bba79eef5cbe868111462a11f77b7a9a80d 100644 (file)
@@ -78,6 +78,12 @@ func main() {
                govpn.EGDInit(*egdPath)
        }
 
+       if *proxyAddr != "" {
+               *proto = "tcp"
+       }
+       if !(*proto == "udp" || *proto == "tcp") {
+               log.Fatalln("Unknown protocol specified")
+       }
        if *verifierRaw == "" {
                log.Fatalln("No verifier specified")
        }
@@ -139,9 +145,6 @@ MainCycle:
                timeouted := make(chan struct{})
                rehandshaking := make(chan struct{})
                termination := make(chan struct{})
-               if *proxyAddr != "" {
-                       *proto = "tcp"
-               }
                switch *proto {
                case "udp":
                        go startUDP(timeouted, rehandshaking, termination)
@@ -151,8 +154,6 @@ MainCycle:
                        } else {
                                go startTCP(timeouted, rehandshaking, termination)
                        }
-               default:
-                       log.Fatalln("Unknown protocol specified")
                }
                select {
                case <-termSignal:
@@ -160,7 +161,8 @@ MainCycle:
                        termination <- struct{}{}
                        break MainCycle
                case <-timeouted:
-                       break MainCycle
+                       govpn.BothPrintf(`[sleep seconds="%d"]`, timeout)
+                       time.Sleep(time.Second * time.Duration(timeout))
                case <-rehandshaking:
                }
                close(timeouted)