}
configureLogger()
+ #if os(macOS)
+ wgEnableRoaming(true)
+ #endif
wg_log(.info, message: "Starting tunnel from the " + (activationAttemptId == nil ? "OS directly, rather than the app" : "app"))
}
private func pathUpdate(path: Network.NWPath) {
- guard let handle = handle, let packetTunnelSettingsGenerator = packetTunnelSettingsGenerator else { return }
+ guard let handle = handle else { return }
wg_log(.debug, message: "Network change detected with \(path.status) route and interface order \(path.availableInterfaces)")
- _ = packetTunnelSettingsGenerator.endpointUapiConfiguration().withGoString { return wgSetConfig(handle, $0) }
+ #if os(iOS)
+ if let packetTunnelSettingsGenerator = packetTunnelSettingsGenerator {
+ _ = packetTunnelSettingsGenerator.endpointUapiConfiguration().withGoString { return wgSetConfig(handle, $0) }
+ }
+ #endif
var interfaces = path.availableInterfaces
if let ifname = ifname {
interfaces = interfaces.filter { $0.name != ifname }
}()
}
+//export wgEnableRoaming
+func wgEnableRoaming(enabled bool) {
+ roamingDisabled = !enabled
+}
+
//export wgSetLogger
func wgSetLogger(loggerFn uintptr) {
loggerFunc = unsafe.Pointer(loggerFn)
#include <sys/types.h>
#include <stdint.h>
+#include <stdbool.h>
typedef struct { const char *p; size_t n; } gostring_t;
typedef void(*logger_fn_t)(int level, const char *msg);
+extern void wgEnableRoaming(bool enabled);
extern void wgSetLogger(logger_fn_t logger_fn);
extern int wgTurnOn(gostring_t settings, int32_t tun_fd);
extern void wgTurnOff(int handle);