# jon5307/ios-exitnode architecture

> Architecture diagram of the GitHub repository jon5307/ios-exitnode, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jon5307/ios-exitnode
- Repository: https://github.com/jon5307/ios-exitnode

## Overview

gateway is an iOS userspace WireGuard exit-node experiment. An operator starts the gateway and provisions client peers in the app; the Go backend runs WireGuard and forwards client TCP/UDP traffic through gVisor netstack. The app also offers configuration delivery and a SideStore repair flow that patches and repackages an IPA. The README documents the backend and repair capabilities; several Go internals and app helpers were not sampled, so their detailed call relationships are omitted.

Main entry points: [`gateway/ContentView.swift`](https://github.com/jon5307/ios-exitnode/blob/main/gateway/ContentView.swift) (Gateway UI), [`gateway/BackgroundProcessing/SideStoreRepairController.swift`](https://github.com/jon5307/ios-exitnode/blob/main/gateway/BackgroundProcessing/SideStoreRepairController.swift) (Repair Controller), [`gateway/WireGuardPeerManager.swift`](https://github.com/jon5307/ios-exitnode/blob/main/gateway/WireGuardPeerManager.swift) (Peer Manager), [`WireGuardGo/gatewaywg.go`](https://github.com/jon5307/ios-exitnode/blob/main/WireGuardGo/gatewaywg.go) (Gateway Backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["iOS Gateway App"]
  node_app_ui["Gateway UI<br/>[ContentView.swift]"]
  node_peer_manager["Peer Manager"]
  node_provisioning["Client Provisioning"]
  node_config_server["Config Web Server"]
  node_udp_server["UDP Server<br/>[UDPServer.swift]"]
  node_bridge["Go Bridge"]
end

subgraph group_backend["WireGuard Backend"]
  node_go_backend["Gateway Backend<br/>[gatewaywg.go]"]
  node_wg_device["WireGuard Device<br/>[device.go]"]
  node_netstack["TCP/UDP Netstack<br/>[tun.go]"]
end

subgraph group_repair["SideStore Repair"]
  node_repair_controller["Repair Controller"]
  node_compatibility["Compatibility Check"]
  node_ipa_repair["IPA Repair"]
  node_background_tasks["Continued Processing"]
end

subgraph group_zip["ZIP Processing"]
  node_zip_filemanager["ZIP File Operations"]
  node_zip_archive["ZIP Archive<br/>[Archive.swift]"]
  node_zip_writer["ZIP Writing"]
end

node_operator(("Operator"))
node_client(("Client Device"))
node_internet(("Outbound Network"))

node_operator -->|"operates"| node_app_ui
node_app_ui -->|"starts gateway"| node_peer_manager
node_app_ui -->|"controls"| node_udp_server
node_app_ui -->|"presents"| node_provisioning
node_app_ui -->|"starts download"| node_config_server
node_provisioning -->|"creates peer"| node_peer_manager
node_client -.->|"downloads profile"| node_config_server
node_peer_manager -->|"starts backend"| node_bridge
node_bridge -.->|"invokes Go API"| node_go_backend
node_client -->|"connects as peer"| node_go_backend
node_go_backend -->|"runs WireGuard"| node_wg_device
node_wg_device -->|"forwards traffic"| node_netstack
node_netstack -->|"routes TCP/UDP"| node_internet
node_app_ui -->|"opens repair"| node_repair_controller
node_repair_controller -->|"checks compatibility"| node_compatibility
node_repair_controller -->|"creates fixed IPA"| node_ipa_repair
node_app_ui -->|"controls processing"| node_background_tasks
node_ipa_repair -->|"unzips and zips"| node_zip_filemanager
node_zip_filemanager -->|"uses archive"| node_zip_archive
node_zip_archive -->|"adds entries"| node_zip_writer

click node_app_ui "https://github.com/jon5307/ios-exitnode/blob/main/gateway/ContentView.swift"
click node_peer_manager "https://github.com/jon5307/ios-exitnode/blob/main/gateway/WireGuardPeerManager.swift"
click node_provisioning "https://github.com/jon5307/ios-exitnode/blob/main/gateway/ClientProvisioning/ClientProvisioningView.swift"
click node_config_server "https://github.com/jon5307/ios-exitnode/blob/main/gateway/ClientProvisioning/ConfigurationWebServer.swift"
click node_udp_server "https://github.com/jon5307/ios-exitnode/blob/main/gateway/UDPServer.swift"
click node_bridge "https://github.com/jon5307/ios-exitnode/blob/main/gateway/WireGuardGoBridge.swift"
click node_go_backend "https://github.com/jon5307/ios-exitnode/blob/main/WireGuardGo/gatewaywg.go"
click node_wg_device "https://github.com/jon5307/ios-exitnode/blob/main/WireGuardGo/wireguard-go/device/device.go"
click node_netstack "https://github.com/jon5307/ios-exitnode/blob/main/WireGuardGo/wireguard-go/tun/netstack/tun.go"
click node_repair_controller "https://github.com/jon5307/ios-exitnode/blob/main/gateway/BackgroundProcessing/SideStoreRepairController.swift"
click node_compatibility "https://github.com/jon5307/ios-exitnode/blob/main/gateway/BackgroundProcessing/BackgroundCompatibilityService.swift"
click node_ipa_repair "https://github.com/jon5307/ios-exitnode/blob/main/gateway/BackgroundProcessing/IPARepairService.swift"
click node_zip_filemanager "https://github.com/jon5307/ios-exitnode/blob/main/gateway/ThirdParty/ZIPFoundation/FileManager%2BZIP.swift"
click node_zip_archive "https://github.com/jon5307/ios-exitnode/blob/main/gateway/ThirdParty/ZIPFoundation/Archive.swift"
click node_zip_writer "https://github.com/jon5307/ios-exitnode/blob/main/gateway/ThirdParty/ZIPFoundation/Archive%2BWriting.swift"
click node_background_tasks "https://github.com/jon5307/ios-exitnode/blob/main/gateway/BackgroundProcessing/ContinuedProcessingController.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_ui,node_peer_manager,node_provisioning,node_config_server,node_udp_server,node_bridge,node_client toneBlue
class node_go_backend,node_wg_device,node_netstack toneAmber
class node_repair_controller,node_compatibility,node_ipa_repair,node_background_tasks toneMint
class node_zip_filemanager,node_zip_archive,node_zip_writer toneRose
class node_operator,node_internet toneIndigo
```

## Components

### iOS Gateway App

- [Gateway UI](https://github.com/jon5307/ios-exitnode/blob/main/gateway/ContentView.swift): `gateway/ContentView.swift`
- [Peer Manager](https://github.com/jon5307/ios-exitnode/blob/main/gateway/WireGuardPeerManager.swift): `gateway/WireGuardPeerManager.swift`
- [Client Provisioning](https://github.com/jon5307/ios-exitnode/blob/main/gateway/ClientProvisioning/ClientProvisioningView.swift): `gateway/ClientProvisioning/ClientProvisioningView.swift`
- [Config Web Server](https://github.com/jon5307/ios-exitnode/blob/main/gateway/ClientProvisioning/ConfigurationWebServer.swift): `gateway/ClientProvisioning/ConfigurationWebServer.swift`
- [UDP Server](https://github.com/jon5307/ios-exitnode/blob/main/gateway/UDPServer.swift): `gateway/UDPServer.swift`
- [Go Bridge](https://github.com/jon5307/ios-exitnode/blob/main/gateway/WireGuardGoBridge.swift): `gateway/WireGuardGoBridge.swift`

### WireGuard Backend

- [Gateway Backend](https://github.com/jon5307/ios-exitnode/blob/main/WireGuardGo/gatewaywg.go): `WireGuardGo/gatewaywg.go`
- [WireGuard Device](https://github.com/jon5307/ios-exitnode/blob/main/WireGuardGo/wireguard-go/device/device.go): `WireGuardGo/wireguard-go/device/device.go`
- [TCP/UDP Netstack](https://github.com/jon5307/ios-exitnode/blob/main/WireGuardGo/wireguard-go/tun/netstack/tun.go): `WireGuardGo/wireguard-go/tun/netstack/tun.go`

### SideStore Repair

- [Repair Controller](https://github.com/jon5307/ios-exitnode/blob/main/gateway/BackgroundProcessing/SideStoreRepairController.swift): `gateway/BackgroundProcessing/SideStoreRepairController.swift`
- [Compatibility Check](https://github.com/jon5307/ios-exitnode/blob/main/gateway/BackgroundProcessing/BackgroundCompatibilityService.swift): `gateway/BackgroundProcessing/BackgroundCompatibilityService.swift`
- [IPA Repair](https://github.com/jon5307/ios-exitnode/blob/main/gateway/BackgroundProcessing/IPARepairService.swift): `gateway/BackgroundProcessing/IPARepairService.swift`
- [Continued Processing](https://github.com/jon5307/ios-exitnode/blob/main/gateway/BackgroundProcessing/ContinuedProcessingController.swift): `gateway/BackgroundProcessing/ContinuedProcessingController.swift`

### ZIP Processing

- [ZIP File Operations](https://github.com/jon5307/ios-exitnode/blob/main/gateway/ThirdParty/ZIPFoundation/FileManager%2BZIP.swift): `gateway/ThirdParty/ZIPFoundation/FileManager+ZIP.swift`
- [ZIP Archive](https://github.com/jon5307/ios-exitnode/blob/main/gateway/ThirdParty/ZIPFoundation/Archive.swift): `gateway/ThirdParty/ZIPFoundation/Archive.swift`
- [ZIP Writing](https://github.com/jon5307/ios-exitnode/blob/main/gateway/ThirdParty/ZIPFoundation/Archive%2BWriting.swift): `gateway/ThirdParty/ZIPFoundation/Archive+Writing.swift`

### Other components

- **Operator**
- **Client Device**
- **Outbound Network**

## Connections

- Operator → Gateway UI: operates (evidence: `gateway/ContentView.swift`)
- Gateway UI → Peer Manager: starts gateway (evidence: `gateway/ContentView.swift`)
- Gateway UI → UDP Server: controls (evidence: `gateway/ContentView.swift`)
- Gateway UI → Client Provisioning: presents (evidence: `gateway/ContentView.swift`)
- Gateway UI → Config Web Server: starts download (evidence: `gateway/ContentView.swift`)
- Client Provisioning → Peer Manager: creates peer (evidence: `gateway/ClientProvisioning/ClientProvisioningView.swift`)
- Client Device → Config Web Server: downloads profile
- Peer Manager → Go Bridge: starts backend (evidence: `gateway/WireGuardPeerManager.swift`)
- Go Bridge → Gateway Backend: invokes Go API
- Client Device → Gateway Backend: connects as peer (evidence: `README.md`)
- Gateway Backend → WireGuard Device: runs WireGuard (evidence: `README.md`)
- WireGuard Device → TCP/UDP Netstack: forwards traffic (evidence: `README.md`)
- TCP/UDP Netstack → Outbound Network: routes TCP/UDP (evidence: `README.md`)
- Gateway UI → Repair Controller: opens repair (evidence: `gateway/ContentView.swift`)
- Repair Controller → Compatibility Check: checks compatibility (evidence: `gateway/BackgroundProcessing/SideStoreRepairController.swift`)
- Repair Controller → IPA Repair: creates fixed IPA (evidence: `gateway/BackgroundProcessing/SideStoreRepairController.swift`)
- Gateway UI → Continued Processing: controls processing (evidence: `gateway/ContentView.swift`)
- IPA Repair → ZIP File Operations: unzips and zips (evidence: `README.md`)
- ZIP File Operations → ZIP Archive: uses archive (evidence: `gateway/ThirdParty/ZIPFoundation/FileManager+ZIP.swift`)
- ZIP Archive → ZIP Writing: adds entries (evidence: `gateway/ThirdParty/ZIPFoundation/Archive+Writing.swift`)
