Files
opsx-vpn/client/tunnel-go/route_darwin.go
T

22 lines
501 B
Go

//go:build darwin
package main
import (
"context"
"errors"
"net/netip"
"os/exec"
"time"
)
func physicalExitFor(endpoint netip.Addr) (physicalRoute, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
output, err := exec.CommandContext(ctx, "/sbin/route", "-n", "get", endpoint.String()).Output()
if err != nil {
return physicalRoute{}, errors.New("无法读取 VPN 网关的当前物理出口")
}
return parsePhysicalRoute(string(output))
}