Skip to content

iproxy programatic connection #1460

@morellexf13

Description

@morellexf13

Hi, I have a question.

Currently, by using tunnels (for example: fd7b:e5b:6f53::1 64337), this is the way we programmatically make the necessary callback to collect performance data.

  def _run_async_rsd_connection(self, address, port, callback):
      async def async_connection():
          async with RemoteServiceDiscoveryService((address, port)) as rsd:
              loop = asyncio.get_running_loop()

              def run_blocking_callback():
                  with DvtSecureSocketProxyService(rsd) as dvt:
                      callback(dvt)

              await loop.run_in_executor(None, run_blocking_callback)

      try:
          loop = asyncio.get_event_loop()
          if loop.is_running():
              with concurrent.futures.ThreadPoolExecutor() as executor:
                  future = executor.submit(asyncio.run, async_connection())
                  future.result()
          else:
              loop.run_until_complete(async_connection())
      except RuntimeError:
          asyncio.run(async_connection())

  def connection_context(self, callback):
      try:
          if Version(self.device_info.os.version) >= Version('17.0'):
              available_address = tunnel_creator.get_available_address()
              if available_address:
                  self._run_async_rsd_connection(available_address["address"], available_address["port"], callback)
              else:
                  raise Exception("An error occurred getting tunnels addresses...")
          else:
              # Use USB Mux
              lockdown = self.get_lockdown()
              with DvtSecureSocketProxyService(lockdown=lockdown) as dvt:
                  callback(dvt)
      except OSError:  # no route to host (Intel fix)
          pass
      except DeviceLockedError:
          raise
      except Exception as e:
          raise Exception(f"Connection not established... {e}")

We handle 6 different “monitors,” which means we have different contexts, and that forces me to open 6 tunnels in parallel, and it works perfectly.

My problem is that now I’m running this on a computer where I don’t have the necessary permissions to open that type of addresses/tunnels. What I do have available is iproxy (for example: iproxy 1716 juan 3u IPv4 0xe039a78a75d7935b 0t0 TCP 127.0.0.1:8200 (LISTEN)).

How can I use this type of address with pymobiledevice? What would be the programmatic way to obtain that dvt/context in this case? I’ve tried passing this type of address/port to the same code (above), but it doesn’t work. I’m no expert in this, and I need some help to figure this out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions