Skip to content

Commit 26d33d5

Browse files
fix(ww): lightly obscure smart dialer config to mitigate app inspection (#441)
* fix(ww): lightly obscure smart dialer config to mitigate app inspection * feedback
1 parent a118f99 commit 26d33d5

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

x/examples/website-wrapper-app/wrapper_app_project/.scripts/build.mjs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ const WRAPPER_APP_TEMPLATE_DIR = path.join(
2828
"wrapper_app_project/template",
2929
);
3030

31-
const DEFAULT_SMART_DIALER_CONFIG = {
31+
const DEFAULT_SMART_DIALER_CONFIG = JSON.stringify({
3232
dns: [{
3333
https: { name: "9.9.9.9" },
3434
}],
3535
tls: ["", "split:1", "split:2", "tlsfrag:1"],
36-
};
36+
});
3737

3838
export default async function main(
3939
{
@@ -172,7 +172,7 @@ function resolveTemplateArguments(
172172
appName,
173173
navigationUrl,
174174
additionalDomains,
175-
smartDialerConfig,
175+
smartDialerConfig = DEFAULT_SMART_DIALER_CONFIG,
176176
},
177177
) {
178178
const result = {
@@ -222,14 +222,7 @@ function resolveTemplateArguments(
222222
result.domainList = [result.entryDomain];
223223
}
224224

225-
if (typeof smartDialerConfig === "string") {
226-
result.smartDialerConfig = smartDialerConfig.replaceAll('"', '\\"');
227-
} else if (typeof smartDialerConfig === "object") {
228-
result.smartDialerConfig = JSON.stringify(smartDialerConfig).replaceAll(
229-
'"',
230-
'\\"',
231-
);
232-
}
225+
result.smartDialerConfig = Buffer.from(smartDialerConfig).toString("base64");
233226

234227
return result;
235228
}
@@ -248,9 +241,6 @@ if (import.meta.url.endsWith(process.argv[1])) {
248241
main({
249242
...args,
250243
additionalDomains: args.additionalDomains?.split(/,\s*/) ?? [],
251-
smartDialerConfig: args.smartDialerConfig
252-
? JSON.parse(args.smartDialerConfig)
253-
: undefined,
254244
})
255245
.catch(console.error);
256246
}

x/examples/website-wrapper-app/wrapper_app_project/template/android/app/src/main/java/org/getoutline/pwa/MainActivity.kt.handlebars

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import com.getcapacitor.BridgeActivity
55

66
import mobileproxy.*
77

8+
import android.util.Base64
9+
import java.nio.charset.StandardCharsets
10+
811
import androidx.webkit.ProxyConfig
912
import androidx.webkit.ProxyController
1013
import androidx.webkit.WebViewFeature
@@ -33,11 +36,13 @@ class MainActivity : BridgeActivity() {
3336

3437
private fun tryProxy(): Boolean {
3538
try {
39+
val smartDialerConfig = Base64.decode(Config.smartDialer, Base64.DEFAULT)
40+
3641
this.proxy = Mobileproxy.runProxy(
3742
"127.0.0.1:0",
3843
Mobileproxy.newSmartStreamDialer(
3944
Mobileproxy.newListFromLines(Config.domainList),
40-
Config.smartDialer,
45+
String(smartDialerConfig, StandardCharsets.UTF_8),
4146
Mobileproxy.newStderrLogWriter()
4247
)
4348
)

x/examples/website-wrapper-app/wrapper_app_project/template/ios/App/App/AppDelegate.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Foundation
12
import Capacitor
23
import Mobileproxy
34
import UIKit
@@ -54,10 +55,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5455

5556
@discardableResult
5657
private func tryProxy() -> Bool {
58+
guard let smartDialerConfig = Data(base64Encoded: Config.smartDialer) else {
59+
return false
60+
}
61+
5762
var error: NSError?
5863
if let dialer = MobileproxyNewSmartStreamDialer(
5964
MobileproxyNewListFromLines(Config.domainList),
60-
Config.smartDialer,
65+
String(data: smartDialerConfig, encoding: .utf8),
6166
MobileproxyNewStderrLogWriter(),
6267
&error
6368
) {

0 commit comments

Comments
 (0)