From a53a40fb4f2c76797287a38ff799f752688645d4 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Mon, 22 Aug 2022 16:18:31 -0700 Subject: [PATCH] Add success alert to selfhosted client apps --- docker-compose.yml | 2 +- frontend/src/components/UnsafeAlert.js | 103 ++++++++++++++++--------- nodeapp/Dockerfile | 2 + nodeapp/selfhosted | 0 4 files changed, 68 insertions(+), 39 deletions(-) create mode 100644 nodeapp/selfhosted diff --git a/docker-compose.yml b/docker-compose.yml index 78700ee7..854f62e0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -51,7 +51,7 @@ services: restart: always environment: TOR_PROXY_IP: 127.0.0.1 - TOP_PROXY_PORT: 9050 + TOR_PROXY_PORT: 9050 ROBOSATS_ONION: robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion network_mode: service:tor diff --git a/frontend/src/components/UnsafeAlert.js b/frontend/src/components/UnsafeAlert.js index f1e7e6d1..109d7dc5 100644 --- a/frontend/src/components/UnsafeAlert.js +++ b/frontend/src/components/UnsafeAlert.js @@ -6,16 +6,25 @@ import MediaQuery from 'react-responsive' class UnsafeAlert extends Component { constructor(props) { super(props); + this.state = { + show: true, + isSelfhosted: this.isSelfhosted(), + }; } - state = { - show: true, - }; + getHost(){ var url = (window.location != window.parent.location) ? this.getHost(document.referrer) : document.location.href; return url.split('/')[2] } + isSelfhosted(){ + var http = new XMLHttpRequest(); + http.open('HEAD', '/selfhosted', false); + http.send(); + return http.status!=404; + } + safe_urls = [ 'robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion', 'robotestagw3dcxmd66r4rgksb4nmmr43fh77bzn2ia2eucduyeafnyd.onion', @@ -25,44 +34,62 @@ class UnsafeAlert extends Component { ] render() { + console.log('1111') const { t, i18n} = this.props; - return ( - (!this.safe_urls.includes(this.getHost()) & this.state.show) ? -
- - - this.setState({show:false})}>{t("Hide")}} - > - {t("You are not using RoboSats privately")} - - Some features are disabled for your protection (e.g. chat) and you will not be able to complete a - trade without them. To protect your privacy and fully enable RoboSats, use Tor Browser and visit the Onion site. - - - - + + // Show selfhosted notice + if (this.state.isSelfhosted){ + return( +
+ + this.setState({show:false})}>{t("Hide")}} + > + {t("You are self-hosting RoboSats")} + {t("RoboSats is served from your own node granting you the strongest security and privacy.")} + + +
+ ) + } - - - - {t("You are not using RoboSats privately")} - - You will not be able to complete a - trade. Use Tor Browser and visit the Onion site. - -
+ // Show unsafe alert + if (!this.safe_urls.includes(this.getHost()) & this.state.show & !this.state.isSelfhosted){ + return( +
+ + + this.setState({show:false})}>{t("Hide")}} + > + {t("You are not using RoboSats privately")} + + Some features are disabled for your protection (e.g. chat) and you will not be able to complete a + trade without them. To protect your privacy and fully enable RoboSats, use Tor Browser and visit the Onion site. + + + + + + + + + {t("You are not using RoboSats privately")} + + You will not be able to complete a + trade. Use Tor Browser and visit the Onion site. + +
+
+
+ +
+
+
+
-
- -
- - - -
- : - null - ) + ) + } } } diff --git a/nodeapp/Dockerfile b/nodeapp/Dockerfile index 6afdcb2c..9f1ec021 100644 --- a/nodeapp/Dockerfile +++ b/nodeapp/Dockerfile @@ -9,6 +9,8 @@ RUN apt-get update RUN apt-get install -y socat RUN npm install http-server +RUN echo 'true' > static/selfhosted + EXPOSE 12596 CMD npm exec http-server -- . -p 12596 -P http://127.0.0.1:81 -i false -d false & nohup socat tcp4-LISTEN:81,reuseaddr,fork,keepalive,bind=127.0.0.1 SOCKS4A:${TOR_PROXY_IP:-127.0.0.1}:${ROBOSATS_ONION:-robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion}:80,socksport=${TOR_PROXY_PORT:-9050} \ No newline at end of file diff --git a/nodeapp/selfhosted b/nodeapp/selfhosted new file mode 100644 index 00000000..e69de29b