From 0797a7d1efac065d8f63f246b2b166d136cab0e8 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi <90936742+Reckless-Satoshi@users.noreply.github.com> Date: Thu, 18 May 2023 13:29:49 +0000 Subject: [PATCH] Fix robosats on blixt's react-native-webview (#594) --- frontend/src/services/System/index.ts | 6 +++++- mobile/App.tsx | 2 ++ nodeapp/nginx.conf | 1 + nodeapp/robosats-client.sh | 7 +++++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/frontend/src/services/System/index.ts b/frontend/src/services/System/index.ts index 7ebde6b2..99d401a3 100644 --- a/frontend/src/services/System/index.ts +++ b/frontend/src/services/System/index.ts @@ -13,4 +13,8 @@ export interface SystemClient { } export const systemClient: SystemClient = - window.ReactNativeWebView != null ? new SystemNativeClient() : new SystemWebClient(); + // If userAgent has "RoboSats", we assume the app is running inside of the + // react-native-web view of the RoboSats Android app. + window.navigator.userAgent.includes('robosats') + ? new SystemNativeClient() + : new SystemWebClient(); diff --git a/mobile/App.tsx b/mobile/App.tsx index dac1a058..5291875f 100644 --- a/mobile/App.tsx +++ b/mobile/App.tsx @@ -5,6 +5,7 @@ import TorClient from './services/Tor'; import Clipboard from '@react-native-clipboard/clipboard'; import NetInfo from '@react-native-community/netinfo'; import EncryptedStorage from 'react-native-encrypted-storage'; +import { name as app_name, version as app_version } from './package.json'; const backgroundColors = { light: 'white', @@ -157,6 +158,7 @@ const App = () => { }} onMessage={onMessage} // @ts-expect-error + userAgent={`${app_name} v${app_version} Android`} style={{ backgroundColor: backgroundColors[colorScheme] }} ref={(ref) => (webViewRef.current = ref)} overScrollMode='never' diff --git a/nodeapp/nginx.conf b/nodeapp/nginx.conf index 5ba520d8..2d8d0c5a 100644 --- a/nodeapp/nginx.conf +++ b/nodeapp/nginx.conf @@ -14,6 +14,7 @@ http { include /etc/nginx/mime.types; default_type application/octet-stream; + large_client_header_buffers 4 64K; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' diff --git a/nodeapp/robosats-client.sh b/nodeapp/robosats-client.sh index 146ccae1..033816a6 100644 --- a/nodeapp/robosats-client.sh +++ b/nodeapp/robosats-client.sh @@ -6,8 +6,11 @@ # 2) nginx: does the magic of redirecting every request to either local (the app, static, # languages) or remote (for each coordinator, either API or WS, and static avatar) -# Every robosat coordinators needs a tor bridge. So far only experimental coordinator available. +# Every robosat coordinators needs a tor socat bridge. So far only experimental coordinator available. experimental_onion=robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion -experimental_socat="socat tcp4-LISTEN:81,reuseaddr,fork,keepalive,bind=127.0.0.1 SOCKS4A:${TOR_PROXY_IP:-127.0.0.1}:${experimental_onion}:80,socksport=${TOR_PROXY_PORT:-9050}" +experimental_port=81 +# ... add more + +experimental_socat="socat tcp4-LISTEN:${experimental_port},reuseaddr,fork,keepalive,bind=127.0.0.1 SOCKS4A:${TOR_PROXY_IP:-127.0.0.1}:${experimental_onion}:80,socksport=${TOR_PROXY_PORT:-9050}" $experimental_socat & nginx \ No newline at end of file