Skip to content

Conversation

@keeshux
Copy link
Member

@keeshux keeshux commented Dec 12, 2025

First, logging. Repurpose NSLogDestination as platform-oriented SimpleLogDestination:

  • NSLog on Apple
  • Logcat on Android
  • printf() elsewhere, with stderr for errors

Then, rather than exposing complex C functions in the ABI, only receive an optional subject for the tunctrl.h signatures (the ref argument):

  • pp_tun_ctrl_set_tunnel
  • pp_tun_ctrl_configure_sockets
  • pp_tun_ctrl_clear_tunnel

If present, VirtualTunnelController will forward the ref to all the tunctrl.h callbacks in the similarly named methods of TunnelController:

  • setTunnelSettings → pp_tun_ctrl_set_tunnel(ref, ...)
  • configureSockets → pp_tun_ctrl_configure_sockets(ref, ...)
  • clearTunnelSettings → pp_tun_ctrl_clear_tunnel(ref, ...)

Therefore, VirtualTunnelControllerImpl is no longer needed.

The Android basic tun controller is paired with the Kotlin code in PartoutVpnWrapper, which tunctrl.c invokes via JNI. Later, VirtualTunnelController will need to encode the TunnelRemoteInfo parameter as JSON so that Kotlin can decode and apply the modules with VpnService.Builder. Linux/Windows will likely be pure C.

Finally, simplify the way wg-go is linked because there's no need to use dlopen() / LoadLibrary(). However, cgo doesn't generate an import lib on Windows, so this must be done POSTBUILD with gendef/dlltool.

- Error.localizedDescription
- Throw rather than crash on undone JSON
Embed basic Android NDK + Kotlin/JNI implementation.
Use logcat on Android, printf() otherwise.
@keeshux keeshux self-assigned this Dec 12, 2025
@keeshux keeshux added enhancement New feature or request Android labels Dec 12, 2025
@keeshux keeshux added the Cross Building on non-Apple platforms label Dec 12, 2025
@keeshux keeshux moved this to In Progress in 2025 Q2-Q4 Scaling Dec 12, 2025
@keeshux keeshux added this to the 1.0.0 milestone Dec 12, 2025
@keeshux keeshux modified the milestones: 1.0.0, Multiplatform: ABI Dec 12, 2025
Generate import library for Windows to avoid dynamic symbols.
@keeshux keeshux merged commit 05dd438 into master Dec 12, 2025
1 check passed
@keeshux keeshux deleted the feature/android-abi branch December 12, 2025 14:55
@keeshux keeshux moved this from In Progress to Done in 2025 Q2-Q4 Scaling Dec 12, 2025
keeshux added a commit that referenced this pull request Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android Cross Building on non-Apple platforms enhancement New feature or request

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants