initial: ZeroTier-like P2P mesh VPN server with multi-tenant Web UI
This commit is contained in:
19
internal/vl2/mac.go
Normal file
19
internal/vl2/mac.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user