platform: modularize api/gui, add docs-tests-web foundation, and refresh root config

This commit is contained in:
beckline
2026-03-26 22:40:54 +03:00
parent 0e2d7f61ea
commit 6a56d734c2
562 changed files with 70151 additions and 16423 deletions

View File

@@ -0,0 +1,59 @@
package cli
import (
"flag"
"fmt"
"io"
"os"
)
type AutoloopParams struct {
Iface string
Table string
MTU int
StateDir string
DefaultLocation string
}
type AutoloopDeps struct {
StateDirDefault string
ResolveIface func(flagIface string) string
Run func(params AutoloopParams)
Stderr io.Writer
}
func RunAutoloop(args []string, deps AutoloopDeps) int {
if deps.ResolveIface == nil || deps.Run == nil {
return 1
}
stderr := deps.Stderr
if stderr == nil {
stderr = os.Stderr
}
fs := flag.NewFlagSet("autoloop", flag.ContinueOnError)
fs.SetOutput(stderr)
iface := fs.String("iface", "", "VPN interface (empty/auto = detect active)")
table := fs.String("table", "agvpn", "routing table name")
mtu := fs.Int("mtu", 1380, "MTU for default route")
stateDir := fs.String("state-dir", deps.StateDirDefault, "state directory")
defaultLoc := fs.String("default-location", "Austria", "default location")
if err := fs.Parse(args); err != nil {
return 2
}
resolvedIface := deps.ResolveIface(*iface)
if resolvedIface == "" {
fmt.Fprintln(stderr, "autoloop: cannot resolve VPN interface (set --iface or preferred iface)")
return 1
}
deps.Run(AutoloopParams{
Iface: resolvedIface,
Table: *table,
MTU: *mtu,
StateDir: *stateDir,
DefaultLocation: *defaultLoc,
})
return 0
}