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

38
internal/vl2/network.go Normal file
View File

@@ -0,0 +1,38 @@
package vl2
import (
"log/slog"
"zeromesh/internal/identity"
)
type NetworkConfig struct {
ID uint32
Name string
IPRange string
IP6Range string
MTU int
Multicast bool
}
type Network struct {
Config NetworkConfig
Switch *Switch
ARP *ARPProxy
LocalMAC [6]byte
log *slog.Logger
}
func NewNetwork(config NetworkConfig, nodeAddr identity.Address, sender PeerSender, log *slog.Logger) *Network {
netLog := log.With("network", config.ID, "name", config.Name)
mac := GenerateMAC(config.ID, nodeAddr)
var macArr [6]byte
copy(macArr[:], mac)
return &Network{
Config: config,
Switch: NewSwitch(config.ID, sender, netLog),
ARP: NewARPProxy(netLog),
LocalMAC: macArr,
log: netLog,
}
}