mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 12:11:35 +00:00
Add success alert to selfhosted client apps
This commit is contained in:
parent
45fd82430e
commit
a53a40fb4f
@ -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
|
||||
|
||||
|
@ -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) ?
|
||||
<div>
|
||||
<MediaQuery minWidth={800}>
|
||||
<Paper elevation={6} className="alertUnsafe">
|
||||
<Alert severity="warning" sx={{maxHeight:"100px"}}
|
||||
action={<Button onClick={() => this.setState({show:false})}>{t("Hide")}</Button>}
|
||||
>
|
||||
<AlertTitle>{t("You are not using RoboSats privately")}</AlertTitle>
|
||||
<Trans i18nKey="desktop_unsafe_alert">
|
||||
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 <Link href='https://www.torproject.org/download/' target="_blank">Tor Browser</Link> and visit the <Link href='http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion' target="_blank">Onion</Link> site.
|
||||
</Trans>
|
||||
</Alert>
|
||||
</Paper>
|
||||
</MediaQuery>
|
||||
|
||||
// Show selfhosted notice
|
||||
if (this.state.isSelfhosted){
|
||||
return(
|
||||
<div>
|
||||
<Paper elevation={6} className="alertUnsafe">
|
||||
<Alert severity="success" sx={{maxHeight:"100px"}}
|
||||
action={<Button onClick={() => this.setState({show:false})}>{t("Hide")}</Button>}
|
||||
>
|
||||
<AlertTitle>{t("You are self-hosting RoboSats")}</AlertTitle>
|
||||
{t("RoboSats is served from your own node granting you the strongest security and privacy.")}
|
||||
</Alert>
|
||||
</Paper>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
<MediaQuery maxWidth={799}>
|
||||
<Paper elevation={6} className="alertUnsafe">
|
||||
<Alert severity="warning" sx={{maxHeight:"120px"}}>
|
||||
<AlertTitle>{t("You are not using RoboSats privately")}</AlertTitle>
|
||||
<Trans i18nKey="phone_unsafe_alert">
|
||||
You will not be able to complete a
|
||||
trade. Use <Link href='https://www.torproject.org/download/' target="_blank">Tor Browser</Link> and visit the <Link href='http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion' target="_blank">Onion</Link> site.
|
||||
</Trans>
|
||||
<div style={{width: '100%'}}>
|
||||
// Show unsafe alert
|
||||
if (!this.safe_urls.includes(this.getHost()) & this.state.show & !this.state.isSelfhosted){
|
||||
return(
|
||||
<div>
|
||||
<MediaQuery minWidth={800}>
|
||||
<Paper elevation={6} className="alertUnsafe">
|
||||
<Alert severity="warning" sx={{maxHeight:"100px"}}
|
||||
action={<Button onClick={() => this.setState({show:false})}>{t("Hide")}</Button>}
|
||||
>
|
||||
<AlertTitle>{t("You are not using RoboSats privately")}</AlertTitle>
|
||||
<Trans i18nKey="desktop_unsafe_alert">
|
||||
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 <Link href='https://www.torproject.org/download/' target="_blank">Tor Browser</Link> and visit the <Link href='http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion' target="_blank">Onion</Link> site.
|
||||
</Trans>
|
||||
</Alert>
|
||||
</Paper>
|
||||
</MediaQuery>
|
||||
|
||||
<MediaQuery maxWidth={799}>
|
||||
<Paper elevation={6} className="alertUnsafe">
|
||||
<Alert severity="warning" sx={{maxHeight:"120px"}}>
|
||||
<AlertTitle>{t("You are not using RoboSats privately")}</AlertTitle>
|
||||
<Trans i18nKey="phone_unsafe_alert">
|
||||
You will not be able to complete a
|
||||
trade. Use <Link href='https://www.torproject.org/download/' target="_blank">Tor Browser</Link> and visit the <Link href='http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion' target="_blank">Onion</Link> site.
|
||||
</Trans>
|
||||
<div style={{width: '100%'}}>
|
||||
</div>
|
||||
<div align="center">
|
||||
<Button className="hideAlertButton" onClick={() => this.setState({show:false})}>{t("Hide")}</Button>
|
||||
</div>
|
||||
</Alert>
|
||||
</Paper>
|
||||
</MediaQuery>
|
||||
</div>
|
||||
<div align="center">
|
||||
<Button className="hideAlertButton" onClick={() => this.setState({show:false})}>{t("Hide")}</Button>
|
||||
</div>
|
||||
</Alert>
|
||||
</Paper>
|
||||
</MediaQuery>
|
||||
</div>
|
||||
:
|
||||
null
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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}
|
0
nodeapp/selfhosted
Normal file
0
nodeapp/selfhosted
Normal file
Loading…
Reference in New Issue
Block a user