]> Cypherpunks.ru repositories - govpn.git/blobdiff - cmd/govpn-client/main.go
Replace handshake NULLs with an IDtag
[govpn.git] / cmd / govpn-client / main.go
index 8b621c8bdcfef50d57316dabd169202fa6e8ee57..119a03d3ddbfe0152e8b877e5478563abd926e07 100644 (file)
@@ -52,6 +52,7 @@ func main() {
        govpn.Noncediff = *nonceDiff
 
        id := govpn.IDDecode(*IDRaw)
+       govpn.PeersInitDummy(id)
        key := govpn.KeyRead(*keyPath)
        if id == nil {
                panic("ID is not specified")
@@ -120,13 +121,18 @@ MainCycle:
                        }
 
                        udpPktData = udpBuf[:udpPkt.Size]
-                       if govpn.IsValidHandshakePkt(udpPktData) {
+                       if peer == nil {
                                if udpPkt.Addr.String() != remote.String() {
                                        udpReady <- struct{}{}
                                        log.Println("Unknown handshake message")
                                        continue
                                }
-                               if p := handshake.Client(conn, key, udpPktData); p != nil {
+                               if govpn.IDsCache.Find(udpPktData) == nil {
+                                       log.Println("Invalid identity in handshake packet")
+                                       udpReady <- struct{}{}
+                                       continue
+                               }
+                               if p := handshake.Client(id, conn, key, udpPktData); p != nil {
                                        log.Println("Handshake completed")
                                        if firstUpCall {
                                                go govpn.ScriptCall(*upPath, *ifaceName)