096a599673
* method for getting current socks5 connection state * prevent shutting down disconnected client (and starting connected client) * fixed ios build * setup additional logging
Socks5-c
Setting up dummy socks5 client in iOS (from scratch)
Based on https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-06-rust-on-ios.html
- Install xcode, iOS simulator, etc. (
xcode-select --install) - add rust targets:
rustup target add aarch64-apple-ios x86_64-apple-ios - get
cargo-lipo:cargo install cargo-lipo - build our library file. From inside
cargoruncargo lipo --release - go to General tab of the xcode project setting and under Linked Frameworks and Libraries import
/cargo/target/universal/release/libsocks5_c.a - link
libresolv.tbd: in Linked Frameworks and Libraries search for and selectlibresolv.tbd - import
socks5_c.hheader file into the project:File -> Add Files to "..." - create bridging header: make new
Socks5-Bridging-Header.hfile and put the following inside:
#ifndef Greetings_Bridging_Header_h
#define Greetings_Bridging_Header_h
#import "socks5_c.h"
#endif
- tell xcode about the bridging header: go to Build Settings tab and set
Objective-C Bridging Headerto$(PROJECT_DIR)/Socks5/Socks5-Bridging-Header.h - tell xcode where to look for libraries for linking: go to Build Settings tab and amend the Library Search Paths option value to
$(PROJECT_DIR)/../../cargo/target/universal/release - create a swift file to actually call our code (
RustSocks5.swift)
// this is an example
class RustSocks5 {
func runForever(serviceProvider: String) {
run_client(serviceProvider)
}
}
- call the new code however you want. I did it by setting
onAppear:
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
}
.padding()
.onAppear{
let rustSocks5 = RustSocks5()
rustSocks5.runForever(serviceProvider: "my-service-provider-address")
}
}
}
- note: the above requires passing a service provider address. The easiest (for testing) would be to just run a local network requester with open proxy and passing that address.
- fix iOS simulator: go to Build Settings and add Any iOS Simulator SDK with value
arm64inside Excluded Architecture. - start the simulator!
- test it by sending some request, like
curl -x socks5h://127.0.0.1:1080 https://nymtech.net