Explorar o código

don't allow a useless handshake with yourself (#402)

* don't allow a useless handshake with yourself

* remove helper
Ryan Huber %!s(int64=4) %!d(string=hai) anos
pai
achega
3aaaea6309
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      handshake_ix.go

+ 8 - 0
handshake_ix.go

@@ -107,6 +107,14 @@ func ixHandshakeStage1(f *Interface, addr *udpAddr, packet []byte, h *Header) {
 	certName := remoteCert.Details.Name
 	fingerprint, _ := remoteCert.Sha256Sum()
 
+	if vpnIP == ip2int(f.certState.certificate.Details.Ips[0].IP) {
+		l.WithField("vpnIp", IntIp(vpnIP)).WithField("udpAddr", addr).
+			WithField("certName", certName).
+			WithField("fingerprint", fingerprint).
+			WithField("handshake", m{"stage": 1, "style": "ix_psk0"}).Error("Refusing to handshake with myself")
+		return
+	}
+
 	myIndex, err := generateIndex()
 	if err != nil {
 		l.WithError(err).WithField("vpnIp", IntIp(vpnIP)).WithField("udpAddr", addr).