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

View File

@@ -0,0 +1,46 @@
package main
import (
"flag"
"log/slog"
"os"
"os/signal"
"syscall"
"zeromesh/internal/agent"
"zeromesh/internal/config"
)
func main() {
cfgPath := flag.String("config", "config.yaml", "config file path")
flag.Parse()
cfg, err := config.Load(*cfgPath)
if err != nil {
slog.Error("load config", "err", err)
os.Exit(1)
}
logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelInfo}))
slog.SetDefault(logger)
ag, err := agent.New(cfg.Agent, logger)
if err != nil {
slog.Error("init agent", "err", err)
os.Exit(1)
}
if err := ag.Start(); err != nil {
slog.Error("start agent", "err", err)
os.Exit(1)
}
slog.Info("agent started", "address", ag.Identity().Address)
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
slog.Info("stopping agent...")
ag.Stop()
}