-
-
Notifications
You must be signed in to change notification settings - Fork 271
Userspace TUN for RSD #1409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Userspace TUN for RSD #1409
Conversation
6bd8922
to
48ce9e1
Compare
@@ -139,14 +142,16 @@ | |||
class RemotePairingTunnel(ABC): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Abstracted RemotePairingTunnel
, OSRemotePairingTunnel
=> Use OS TUN interface (pytun_pmd3), UserspacePairingTunnel
=> Use userspace TCP/IPv6 stack (swtcp6_pmd3)
@staticmethod | ||
def _encode_cdtunnel_packet(data: dict) -> bytes: | ||
return CDTunnelPacket.build({'body': json.dumps(data).encode()}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as the same way of go-ios
: create a tcp server at _userspace_host:random_port
When connecting to a RSD service:
intf_poll_task
sync raw IPv6 data between idevice and virtual NIC- Client (see ServiceConnection) connect to the userspace wrapper tcp server
- Send address and port of RSD service (dest) => server tries to connect dest via virtual NIC
- Server sync all data sent by client to dest
try: | ||
yield TunnelResult( | ||
client.tun.name, handshake_response['serverAddress'], handshake_response['serverRSDPort'], | ||
client.get_interface(), handshake_response['serverAddress'], handshake_response['serverRSDPort'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.get_interface
will be '<userspace TUN server host> <port>'
if isinstance(client, UserspaceRemotePairingTunnel)
if script_mode: | ||
print(f'{tunnel_result.address} {tunnel_result.port}') | ||
if userspace_host: | ||
print(f'{tunnel_result.address} {tunnel_result.port} {tunnel_result.interface}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here tunnel_result.interface
is '<host> <port>'
of Userspace TUN server if use_userspace
self._run_coroutine(self.send_packet_to_device(packet)) | ||
|
||
@asyncio_print_traceback | ||
async def intf_poll_task(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
poll
means let virtual NIC process all incoming raw IPv6 bytes (from a buffer), outgoing traffic (to a buffer)
after poll, outgoing buffer would be some data so send it to device
await self._polled.wait() | ||
to_send = await r.read(available_buf) | ||
if not to_send: | ||
# connection lost |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connect between ServiceConnection and the function lost
How to run the userspace tunnel? will it be its own pypi package? |
48ce9e1
to
3194a12
Compare
By normal way you start tunnel but with a |
I failed to figure out how to use swtcp6-pmd3. It should have a proper README and uploaded to pypi. Doesn't seem to contain any CLI for bringing up the server you mentioned |
Ah sorry sir I forget to mention that. It was used as a library in |
I see. This means this dependency needs to be either optional or be compiled cross platforms using cibuildwheel to be included |
55dc986
to
33239d2
Compare
4d271b1
to
945cfa1
Compare
945cfa1
to
0a9c2c6
Compare
0a9c2c6
to
dcfca88
Compare
@strobecat can the rsd which started in this way be used to start debug server ? |
it should function like system tun ideally btw pr progress: I'm currently try to give |
This PR wants to add a userspace TUN to connect to RSD service.
I've tested that
pymobiledevice3 developer dvt ls / --userspace-wrapper ... --rsd ...
withpymobiledevice3 lockdown start-tunnel --userspace-host 0.0.0.0
works on iPadOS 18.5 and Python 3.10.12. Tunneld current not portedSource of
swtcp6_pmd3
is here: strobecat/swtcp6-pmd3 (I assume Apple only use ipv6 for RSD)the packages serve as a virtual NIC and TCP FSMs, process (everytime
.poll()
got called) raw IPv6 bytes from device, update TCP FSM, and send raw bytes to the device.Closes #1260
For community
⬇️ Please click the 👍 reaction instead of leaving a
+1
or 👍 comment