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

Allow HTTP nodes in Android app #670

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
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
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
14 changes: 13 additions & 1 deletion src/config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@
},
{
"url": "https://dschubba.adm.im"
},
{
"url": "http://ec2-54-197-36-175.compute-1.amazonaws.com:36666"
},
{
"url": "http://54.197.36.175:36666"
},
{
"url": "http://54.197.36.175:46666"
},
{
"url": "http://54.197.36.175:56666"
}
],
"healthCheck": {
Expand Down Expand Up @@ -216,4 +228,4 @@
}
}
}
}
}
14 changes: 13 additions & 1 deletion src/config/production.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@
},
{
"url": "https://dschubba.adm.im"
},
{
"url": "http://ec2-54-197-36-175.compute-1.amazonaws.com:36666"
},
{
"url": "http://54.197.36.175:36666"
},
{
"url": "http://54.197.36.175:46666"
},
{
"url": "http://54.197.36.175:56666"
}
],
"healthCheck": {
Expand Down Expand Up @@ -216,4 +228,4 @@
}
}
}
}
}
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
Copy link
Member

Choose a reason for hiding this comment

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

It depends on whether it's Web app or Android app

this.active = nodesStorage.isActive(url)

this.client = this.buildClient()
Expand Down