Skip to content

feat: bypass internet censorship - #44

Merged
aiko-chan-ai merged 2 commits into
masterfrom
bypass-dpi
Jul 12, 2026
Merged

feat: bypass internet censorship#44
aiko-chan-ai merged 2 commits into
masterfrom
bypass-dpi

Conversation

@aiko-chan-ai

Copy link
Copy Markdown

tks https://github.com/UsagiApp/Usagi

Co-authored-by: OpenAI Codex <codex@openai.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/setNetworkMode and a small JS service wrapper for the setting.
  • Implements Android-side mode persistence and a routing SocketFactory with 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()
}
}

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

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",
@aiko-chan-ai
aiko-chan-ai merged commit 1accb7b into master Jul 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants