Conversation
4be4cf9 to
bef7b6e
Compare
9ca82fc to
474e2a3
Compare
66a3a15 to
c743c80
Compare
DivMode
added a commit
to DivMode/gotatun
that referenced
this pull request
Apr 29, 2026
…eTunnelPeers Tasks 7-9 of PRD #1618. Brings the JNI surface from "skeleton" to "functionally complete" — every Java native call now drives real GotaTun work. New modules: - runtime.rs: process-wide Tokio multi-thread runtime + tunnel registry. Type-erased Device behind a DeviceShutdown trait so the registry doesn't propagate the DeviceTransports generic. Lazy OnceLock for the runtime so we only pay the build cost on first awgTurnOn. - tun_bridge.rs: wraps a raw Linux TUN fd (delivered over JNI from Android's VpnService.Builder().establish()) as a tun::AsyncDevice via Configuration::raw_fd, then hands to gotatun TunDevice. - udp_factory.rs: FdRecordingUdpFactory wraps GotaTun's UdpSocketFactory and captures bound socket fds via UdpSocket's AsFd impl. The Atomic<i32> handles are cloned into the TunnelEntry so the JNI surface can read them without holding a reference to the factory (which lives inside the Device's transport state). awgTurnOn flow: parse settings → build TunDevice from raw fd → DeviceBuilder.with_uapi + with_udp(FdRecording) + with_ip(tun) → block_on .build() → UapiClient.send_sync(Set) to install peers → store in registry → return i32 handle. awgTurnOff: Registry.remove(handle) → DeviceShutdown.stop_blocking() drops UAPI client + awaits Device::stop on the runtime. awgGetSocketV4/V6: read AtomicI32 from registry entry. -1 if handle unknown or socket not yet bound (transient before DeviceBuilder finishes; awgTurnOn has already returned by that point in practice). awgGetConfig: send Request::Get(Get::default()) via UapiClient, format the GetResponse via its Display impl. Returns "" on error so the Kotlin side gets a parseable empty config. awgUpdateTunnelPeers: parse new settings, strip interface-level fields, build a peers-only Set with replace_peers=true, send via UapiClient. Matches amneziawg-go's CreatePeerIPCRequest semantics — replaces the peer table without disturbing the private key/listen port. Tests: 19/19 still passing on host. New runtime/tun_bridge/udp_factory modules don't have unit tests because they need a real TUN device or real UDP bind to exercise — those are integration-level concerns covered by the localhost-loopback test in task mullvad#10 and the live phone test in task mullvad#11. Tracks: DivMode/catchseo#1618
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change is