]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/govpn/cmd/govpn-client/udp.go
Configure MTU on per-user basis
[govpn.git] / src / govpn / cmd / govpn-client / udp.go
index b4398f327a0b69931fa87350e34be004b97a7719..581e66cf74f122ceee169a53c86f1dab0f6b6dc3 100644 (file)
@@ -1,6 +1,6 @@
 /*
 GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2015 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@ func startUDP(timeouted, rehandshaking, termination chan struct{}) {
        log.Println("Connected to UDP:" + *remoteAddr)
 
        hs := govpn.HandshakeStart(*remoteAddr, conn, conf)
-       buf := make([]byte, govpn.MTU)
+       buf := make([]byte, *mtu*2)
        var n int
        var timeouts int
        var peer *govpn.Peer
@@ -72,14 +72,12 @@ MainCycle:
                        }
                        if atomic.LoadInt64(&peer.BytesIn)+atomic.LoadInt64(&peer.BytesOut) > govpn.MaxBytesPerKey {
                                log.Println("Need rehandshake")
-                               terminator <- struct{}{}
-                               terminator = nil
                                rehandshaking <- struct{}{}
                                break MainCycle
                        }
                        continue
                }
-               if govpn.IDsCache.Find(buf[:n]) == nil {
+               if idsCache.Find(buf[:n]) == nil {
                        log.Println("Invalid identity in handshake packet")
                        continue
                }
@@ -120,4 +118,5 @@ MainCycle:
        if hs != nil {
                hs.Zero()
        }
+       conn.Close()
 }