handshake.go 705 B

12345678910111213141516171819202122232425262728
  1. package nebula
  2. const (
  3. handshakeIXPSK0 = 0
  4. handshakeXXPSK0 = 1
  5. )
  6. func HandleIncomingHandshake(f *Interface, addr *udpAddr, packet []byte, h *Header, hostinfo *HostInfo) {
  7. if !f.lightHouse.remoteAllowList.Allow(addr.IP) {
  8. f.l.WithField("udpAddr", addr).Debug("lighthouse.remote_allow_list denied incoming handshake")
  9. return
  10. }
  11. switch h.Subtype {
  12. case handshakeIXPSK0:
  13. switch h.MessageCounter {
  14. case 1:
  15. ixHandshakeStage1(f, addr, packet, h)
  16. case 2:
  17. newHostinfo, _ := f.handshakeManager.QueryIndex(h.RemoteIndex)
  18. tearDown := ixHandshakeStage2(f, addr, newHostinfo, packet, h)
  19. if tearDown && newHostinfo != nil {
  20. f.handshakeManager.DeleteHostInfo(newHostinfo)
  21. }
  22. }
  23. }
  24. }