initial: ZeroTier-like P2P mesh VPN server with multi-tenant Web UI

This commit is contained in:
xieyao
2026-06-17 03:50:23 +08:00
commit ee5f036325
74 changed files with 9517 additions and 0 deletions

19
internal/vl2/mac.go Normal file
View File

@@ -0,0 +1,19 @@
package vl2
import (
"net"
"zeromesh/internal/identity"
)
// GenerateMAC creates a deterministic MAC address from network ID and node address.
func GenerateMAC(networkID uint32, nodeAddr identity.Address) net.HardwareAddr {
mac := make(net.HardwareAddr, 6)
mac[0] = 0x02 // locally administered, unicast
mac[1] = byte(networkID >> 16)
mac[2] = byte(networkID >> 8)
mac[3] = byte(networkID)
mac[4] = nodeAddr[3]
mac[5] = nodeAddr[4]
return mac
}