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,44 @@
package app
import (
"fmt"
"strings"
egressutilpkg "selective-vpn-api/app/egressutil"
)
func egressProbeExternalIP() (string, error) {
endpoints := egressIPEndpoints()
ip, errs := egressutilpkg.ProbeFirstSuccess(endpoints, func(rawURL string) (string, error) {
body, err := egressutilpkg.HTTPGetBody(egressHTTPClient, rawURL, egressIdentityProbeTimeout, "selective-vpn-api/egress-identity", 8*1024)
if err != nil {
return "", err
}
return egressutilpkg.ParseIPFromBody(body)
})
if strings.TrimSpace(ip) != "" {
return ip, nil
}
if len(errs) == 0 {
return "", fmt.Errorf("egress probe endpoints are not configured")
}
return "", fmt.Errorf("%s", strings.Join(errs, "; "))
}
func egressProbeExternalIPViaInterface(iface string) (string, error) {
iface = strings.TrimSpace(iface)
if iface == "" {
return egressProbeExternalIP()
}
endpoints := egressIPEndpoints()
ip, errs := egressutilpkg.ProbeFirstSuccess(endpoints, func(rawURL string) (string, error) {
return egressProbeURLViaInterface(rawURL, iface, egressIdentityProbeTimeout)
})
if strings.TrimSpace(ip) != "" {
return ip, nil
}
if len(errs) == 0 {
return "", fmt.Errorf("egress probe endpoints are not configured")
}
return "", fmt.Errorf("%s", strings.Join(errs, "; "))
}