X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgovpn%2Fcmd%2Fgovpn-client%2Fmain.go;h=c7b04a7635af89d2e2fdb8fa931543a996295764;hb=0cdad04d71e2bbaa182cf2cc98c6425c98bd2b6e;hp=c2ddb3e1b9a1d5e1773f8855cd42e4a3bd3903f1;hpb=649e55e1ead338121ea76d6ae1187617ea9839d6;p=govpn.git diff --git a/src/cypherpunks.ru/govpn/cmd/govpn-client/main.go b/src/cypherpunks.ru/govpn/cmd/govpn-client/main.go index c2ddb3e..c7b04a7 100644 --- a/src/cypherpunks.ru/govpn/cmd/govpn-client/main.go +++ b/src/cypherpunks.ru/govpn/cmd/govpn-client/main.go @@ -45,11 +45,13 @@ var ( mtu = flag.Int("mtu", govpn.MTUDefault, "MTU of TAP interface") timeoutP = flag.Int("timeout", 60, "Timeout seconds") timeSync = flag.Int("timesync", 0, "Time synchronization requirement") + noreconnect = flag.Bool("noreconnect", false, "Disable reconnection after timeout") noisy = flag.Bool("noise", false, "Enable noise appending") encless = flag.Bool("encless", false, "Encryptionless mode") cpr = flag.Int("cpr", 0, "Enable constant KiB/sec out traffic rate") egdPath = flag.String("egd", "", "Optional path to EGD socket") syslog = flag.Bool("syslog", false, "Enable logging to syslog") + version = flag.Bool("version", false, "Print version information") warranty = flag.Bool("warranty", false, "Print warranty information") conf *govpn.PeerConf @@ -57,7 +59,7 @@ var ( timeout int firstUpCall bool = true knownPeers govpn.KnownPeers - idsCache *govpn.CipherCache + idsCache *govpn.MACCache ) func main() { @@ -66,6 +68,10 @@ func main() { fmt.Println(govpn.Warranty) return } + if *version { + fmt.Println(govpn.VersionGet()) + return + } timeout = *timeoutP var err error log.SetFlags(log.Ldate | log.Lmicroseconds | log.Lshortfile) @@ -78,6 +84,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") } @@ -108,7 +120,7 @@ func main() { Verifier: verifier, DSAPriv: priv, } - idsCache = govpn.NewCipherCache() + idsCache = govpn.NewMACCache() confs := map[govpn.PeerId]*govpn.PeerConf{*verifier.Id: conf} idsCache.Update(&confs) log.Println(govpn.VersionGet()) @@ -139,9 +151,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,17 +160,18 @@ MainCycle: } else { go startTCP(timeouted, rehandshaking, termination) } - default: - log.Fatalln("Unknown protocol specified") } select { case <-termSignal: - log.Println("Finishing") - govpn.Println("Finishing") + govpn.BothPrintf(`[finish remote="%s"]`, *remoteAddr) termination <- struct{}{} break MainCycle case <-timeouted: - break MainCycle + if *noreconnect { + break MainCycle + } + govpn.BothPrintf(`[sleep seconds="%d"]`, timeout) + time.Sleep(time.Second * time.Duration(timeout)) case <-rehandshaking: } close(timeouted)