handshake.go 814 B

1234567891011121314151617181920212223242526272829
  1. package nebula
  2. import (
  3. "github.com/slackhq/nebula/header"
  4. "github.com/slackhq/nebula/udp"
  5. )
  6. func HandleIncomingHandshake(f *Interface, addr *udp.Addr, packet []byte, h *header.H, hostinfo *HostInfo) {
  7. // First remote allow list check before we know the vpnIp
  8. if !f.lightHouse.remoteAllowList.AllowUnknownVpnIp(addr.IP) {
  9. f.l.WithField("udpAddr", addr).Debug("lighthouse.remote_allow_list denied incoming handshake")
  10. return
  11. }
  12. switch h.Subtype {
  13. case header.HandshakeIXPSK0:
  14. switch h.MessageCounter {
  15. case 1:
  16. ixHandshakeStage1(f, addr, packet, h)
  17. case 2:
  18. newHostinfo, _ := f.handshakeManager.QueryIndex(h.RemoteIndex)
  19. tearDown := ixHandshakeStage2(f, addr, newHostinfo, packet, h)
  20. if tearDown && newHostinfo != nil {
  21. f.handshakeManager.DeleteHostInfo(newHostinfo)
  22. }
  23. }
  24. }
  25. }