Skip to content

Commit

Permalink
feat(android): allow HTTP nodes & create a whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
bludnic committed Oct 22, 2024
1 parent 7108352 commit f704267
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
Expand Down
8 changes: 8 additions & 0 deletions android/app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<!-- Domains below will bypass cleartext (mixed content) policy -->
<domain includeSubdomains="true">54.197.36.175</domain>
<domain includeSubdomains="true">amazonaws.com</domain>
</domain-config>
</network-security-config>
8 changes: 8 additions & 0 deletions capacitor.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ const config: CapacitorConfig = {
SplashScreen: {
androidScaleType: 'CENTER_CROP' // fix logo stretching
}
},
android: {
// This option allows making requests from HTTPS to HTTP.
// Android 9.0 (Pie) introduced restrictions on cleartext (HTTP) traffic, which is enabled by default.
// Even allowing mixed content, the app will still block these requests due to cleartext restrictions.
// To bypass this, we have a whitelist of HTTP domains/IPs.
// See android/app/src/main/res/xml/network_security_config.xml
allowMixedContent: true
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/nodes/abstract.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export abstract class Node<C = unknown> {
this.hostname = new URL(url).hostname
this.minNodeVersion = minNodeVersion
this.version = version
this.hasSupportedProtocol = !(this.protocol === 'http:' && appProtocol === 'https:')
this.hasSupportedProtocol = true // @todo add option: Enable HTTP nodes
this.active = nodesStorage.isActive(url)

this.client = this.buildClient()
Expand Down

0 comments on commit f704267

Please sign in to comment.