feat: bypass internet censorship - #44
Merged
Merged
Conversation
tks https://github.com/UsagiApp/Usagi Co-authored-by: OpenAI Codex <codex@openai.com>
There was a problem hiding this comment.
Pull request overview
Adds a new “DPI bypass” network mode (toggleable from Advanced Settings) and wires it through the React Native TurboModule to an Android OkHttp socket-layer implementation intended to evade DPI filtering, along with supporting localization strings.
Changes:
- Adds new Advanced Settings UI + strings for a “Bypass internet censorship” (DPI bypass) toggle.
- Introduces
NativeNetwork.getNetworkMode/setNetworkModeand a small JS service wrapper for the setting. - Implements Android-side mode persistence and a routing
SocketFactorywith DPI-bypass socket/output-stream behavior, plus local address/hostname classification updates.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| strings/types/index.ts | Adds new string keys for the DPI-bypass setting label/description. |
| strings/languages/en/strings.json | Adds English strings for the DPI-bypass setting. |
| strings/languages/vi_VN/strings.json | Adds Vietnamese strings for the DPI-bypass setting. |
| src/services/network/settings.ts | Adds JS wrapper for getNetworkMode / setNetworkMode. |
| src/screens/settings/SettingsAdvancedScreen.tsx | Adds Advanced Settings toggle wired to the native network mode. |
| specs/NativeNetwork.ts | Extends the TurboModule spec with getNetworkMode/setNetworkMode. |
| android/app/src/main/java/com/rajarsheechatterjee/NativeNetwork/NetworkMode.kt | Adds persisted network mode enum + preference read helper. |
| android/app/src/main/java/com/rajarsheechatterjee/NativeNetwork/NetworkClientFactory.kt | Routes sockets via a mode-aware SocketFactory and adjusts DoH bootstrap client construction. |
| android/app/src/main/java/com/rajarsheechatterjee/NativeNetwork/NativeNetworkModule.kt | Adds native setters/getters for network mode and connection pool eviction on mode change. |
| android/app/src/main/java/com/rajarsheechatterjee/NativeNetwork/LocalAwareDns.kt | Switches local-host detection to the shared classifier. |
| android/app/src/main/java/com/rajarsheechatterjee/NativeNetwork/LocalAddressClassifier.kt | Introduces shared local hostname / IP-literal / local-address classification logic. |
| android/app/src/main/java/com/rajarsheechatterjee/NativeNetwork/DpiBypass.kt | Implements the DPI-bypass socket/output-stream behavior (TLS/HTTP first-write splitting). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+228
to
+246
| private fun flushFirstWriteIfReady() { | ||
| val data = buffer.toByteArray() | ||
| when { | ||
| looksLikeTlsRecord(data) && data.size < 9 -> Unit | ||
|
|
||
| isTlsClientHello(data) -> { | ||
| val recordSize = if (data.size >= 5) unsignedShort(data, 3) + 5 else Int.MAX_VALUE | ||
| if (data.size >= recordSize || data.size >= MAX_FIRST_WRITE) processFirstWrite() | ||
| } | ||
|
|
||
| looksLikeHttpRequest(data) -> { | ||
| if (data.indexOf(HTTP_HEADERS_END) >= 0 || data.size >= MAX_FIRST_WRITE) { | ||
| processFirstWrite() | ||
| } | ||
| } | ||
|
|
||
| data.size >= TLS_HEADER_SIZE -> processFirstWrite() | ||
| } | ||
| } |
Comment on lines
70
to
72
| "allowCloudflareBypass": "Allow plugins to use Cloudflare bypass API", | ||
| "allowCloudflareBypassDesc": "Enables the Cloudflare Turnstile bypass API for plugins. Requires app restart.", | ||
| "allowCloudflareBypassDesc": "Enables the Cloudflare Turnstile bypass API for plugins.", | ||
| "hideCloudflareOverlay": "Hide WebView overlay when bypassing CF", |
Comment on lines
69
to
72
| "developer": "Nhà phát triển", | ||
| "allowCloudflareBypass": "Cho phép plugin sử dụng API bypass Cloudflare", | ||
| "allowCloudflareBypassDesc": "Bật tính năng vượt qua Cloudflare Turnstile cho các plugin. Yêu cầu khởi động lại ứng dụng.", | ||
| "allowCloudflareBypassDesc": "Bật tính năng vượt qua Cloudflare Turnstile cho các plugin.", | ||
| "hideCloudflareOverlay": "Ẩn overlay WebView khi bypass CF", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://github.com/UsagiApp/Usagi