Skip to content
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

docs(x): Update Mobile Proxy README #353

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions x/mobileproxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,27 @@ The integration typically consists of the following steps:
1. Configure and run MobileProxy within your app.
1. Update your networking code to proxy traffic through the local MobileProxy.

## Build the Go Mobile binaries with [`go build`](https://pkg.go.dev/cmd/go#hdr-Compile_packages_and_dependencies)

### Flutter Apps

To integrate the MobileProxy into a Flutter app, follow this excellent tutorial by Anash Nouri: [Flutter Embedded VPN](https://blog.stackademic.com/flutter-embedded-vpn-c47144798995). Of note: MobileProxy doesn't actually use VPN apis, and may not even need to use a proxy.

### Web Apps (Experimental)

If you are looking into converting a web site or web app into a censorship-resistant mobile app, look at the [Web App Wrapper](https://github.com/Jigsaw-Code/outline-sdk/tree/main/x/examples/web-wrapper) that we are working on.

## Add the MobileProxy dependency
### Build the MobileProxy libraries for Android and iOS

First, Build the Go Mobile binaries with [`go build`](https://pkg.go.dev/cmd/go#hdr-Compile_packages_and_dependencies)

From the `x/` directory:

```bash
go build -o "$(pwd)/out/" golang.org/x/mobile/cmd/gomobile golang.org/x/mobile/cmd/gobind
```

## Build the iOS and Android libraries with [`gomobile bind`](https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile#hdr-Build_a_library_for_Android_and_iOS)
Then build the iOS and Android libraries with [`gomobile bind`](https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile#hdr-Build_a_library_for_Android_and_iOS)

```bash
PATH="$(pwd)/out:$PATH" gomobile bind -ldflags='-s -w' -target=ios -iosversion=11.0 -o "$(pwd)/out/mobileproxy.xcframework" github.com/Jigsaw-Code/outline-sdk/x/mobileproxy
Expand Down Expand Up @@ -468,11 +480,16 @@ public final class StringList implements Seq.Proxy {

</details>

## Add the library to your mobile project
### Add the library to your mobile project

To add the library to your mobile project, see Go Mobile's [Building and deploying to iOS](https://go.dev/wiki/Mobile#building-and-deploying-to-ios-1) and [Building and deploying to Android](https://go.dev/wiki/Mobile#building-and-deploying-to-android-1).

## Using the basic local proxy forwarder

## Configure and run the local proxy forwarder

You have the option to use a static configuration (which you may fetch dynamically from a remote resource), or use the Smart Proxy, which picks a DNS and TLS strategy for you automatically and doesn't need to tunnel traffic.

### Using static transport configuration

You need to call the `RunProxy` function passing the local address to use, and the transport configuration.

Expand All @@ -488,16 +505,16 @@ val proxy = Mobileproxy.runProxy("localhost:0", dialer)
proxy.stop()
```

## Using the smart local proxy forwarder ("Smart Proxy")
### Using the Smart Proxy

The Smart Proxy can automatically try multiple strategies to unblock access to the test domains you specify.
You need to specify a strategy config in JSON format ([example](../examples/smart-proxy/config.json)).
You need to specify a strategy config in YAML format ([example](../examples/smart-proxy/config.yaml)).

On Android, the Kotlin code would look like this:
```kotlin
// Use port zero to let the system pick an open port for you.
val testDomains = Mobileproxy.newListFromLines("www.youtube.com\ni.ytimg.com")
val strategiesConfig = "..." // Config JSON.
val strategiesConfig = "..." // Config YAML.
val dialer = Mobileproxy.newSmartStreamDialer(testDomains, strategiesConfig, Mobileproxy.newStderrLogWriter())

val proxy = Mobileproxy.runProxy("localhost:0", dialer)
Expand Down
Loading