A minimal iOS app demonstrating a local HTTP/HTTPS proxy for SocketZero.
Parent Project: SocketZero - Zero trust connection utility
Status: 🚧 Proof of Concept - Not production ready
- Runs a local HTTP proxy on
localhost:8080 - Handles
CONNECTtunneling for HTTPS (no MITM, just byte forwarding) - Shows connection logs in real-time
- Demonstrates the core concept for SocketZero mobile
-
Create a new Xcode project:
- File → New → Project
- iOS → App
- Product Name:
SocketZeroProxy - Interface: SwiftUI
- Language: Swift
-
Replace the generated files with these:
SocketZeroProxyApp.swiftContentView.swiftSocketZeroProxy.swift
-
Run on iPhone or Simulator (Cmd+R)
On your iPhone:
- Go to Settings
- Tap Wi-Fi
- Tap (i) next to your connected network
- Scroll down to Configure Proxy
- Select Manual
- Enter:
- Server:
127.0.0.1 - Port:
8080
- Server:
- Tap Save
Plain HTTP:
- Open Safari
- Go to
http://example.com - You'll see the demo response from the proxy
HTTPS:
- Go to
https://example.com - The proxy will log the CONNECT request
- (In this demo, it returns 200 OK but doesn't forward - see notes below)
Check Logs:
- Return to the SocketZero Proxy app
- See real-time connection logs at the bottom
This is a proof of concept. To make it production-ready for SocketZero:
Add WebSocket connection to your SocketZero receiver:
private func connectToReceiver() {
var request = URLRequest(url: URL(string: receiverURL)!)
request.addValue("Bearer \(authToken)", forHTTPHeaderField: "Authorization")
let session = URLSession(configuration: .default)
webSocket = session.webSocketTask(with: request)
webSocket?.resume()
receiveMessages()
}In handleCONNECT and handleHTTP, instead of sending demo responses:
// Send request to receiver
let message = [
"type": "tunnel_request",
"target": target,
"data": data.base64EncodedString()
]
sendWebSocketMessage(message)After 200 Connection Established, pipe encrypted bytes:
connection.receive(...) { data, _, _, _ in
// Send bytes to receiver via WebSocket
self.forwardToReceiver(data)
}
// When bytes come back from receiver:
connection.send(content: receiverData, ...)For production, you'd need:
- Network Extension (VPN capability) for background operation
- Or accept foreground-only operation
Add authentication via Universal Links:
// Handle deep link callback
func handleAuthCallback(url: URL) {
// Extract token from socketzero://auth/callback?token=...
let token = extractToken(from: url)
saveToKeychain(token)
connectToReceiver()
}iOS Safari
↓ (HTTP/CONNECT requests)
Local Proxy (localhost:8080)
↓ (WebSocket - TODO)
SocketZero Receiver
↓
Target Services
- Foreground only - proxy stops when app backgrounds
- Manual proxy config - user must configure in Settings
- No receiver integration - demo responses only
- HTTPS works but doesn't forward - needs WebSocket implementation
- Add WebSocket to receiver (reuse Go protocol)
- Implement byte forwarding for CONNECT tunnels
- Add OAuth flow via Universal Links
- Test with real SocketZero receiver
- Consider Network Extension for background operation
SocketZeroProxyApp.swift- App entry pointContentView.swift- SwiftUI interfaceSocketZeroProxy.swift- Proxy server implementation
Same as SocketZero parent project.
Built by Rocky 🦝 for Danny @ Radius Method