Prohibit access from public instances on certain countries
This commit is contained in:
Tornado Contrib 2024-11-10 21:54:03 +00:00
parent f781f6a935
commit 8e294eddd2
Signed by: tornadocontrib
GPG Key ID: 60B4DF1A076C64B1
2 changed files with 133 additions and 10 deletions

@ -82,7 +82,7 @@
<script>
/*global $, jQuery, bootstrap, ethers, Tornado, TornadoContracts, moment*/
const VERSION = '1.0.3';
const VERSION = '1.0.4';
const DONATION_ADDRESS = '0x40c3d1656a26C9266f4A10fed0D87EFf79F54E64';
const DEFAULT_GAS_LIMIT = 600_000;
@ -93,6 +93,77 @@
const JSDELIVR = 'https://cdn.jsdelivr.net/npm/tornado-cdn@1.0.4';
const IP_ECHO = 'https://tornadowithdraw.com/ip';
// Prohibits United States, United Kingdom, Netherlands, and countries sanctioned by the United Nations Security Council
// https://main.un.org/securitycouncil/en/sanctions/information
const PROHIBITED_COUNTRIES = [
{
country: 'United States',
iso: 'US',
},
{
country: 'United Kingdom',
iso: 'UK',
},
{
country: 'Netherlands',
iso: 'NL',
},
{
country: 'Angola',
iso: 'AO',
},
{
country: 'Liberia',
iso: 'LR',
},
{
country: 'Iraq',
iso: 'IQ',
},
{
country: 'Somalia',
iso: 'SO',
},
{
country: 'Congo (the Democratic Republic of the)',
iso: 'CD',
},
{
country: 'Sudan (the)',
iso: 'SD',
},
{
country: 'Lebanon',
iso: 'LB',
},
{
country: 'Korea (the Democratic People\'s Republic of)',
iso: 'KP',
},
{
country: 'Libya',
iso: 'LY',
},
{
country: 'Central African Republic (the)',
iso: 'CF',
},
{
country: 'Yemen',
iso: 'YE',
},
{
country: 'South Sudan',
iso: 'SS',
},
{
country: 'Mali',
iso: 'ML',
},
];
const hashes = {
'static/bootstrap.css': 'sha384-p8zfDSkYPu7Xu7mMd8DJHdXwh1/mZ2P/aMhahJze550GcUbzNxB841pMCrYaew9I',
'static/bootstrap.css.map': 'sha384-j26wcRYDZq3IKjEVNqnOwbDwbzbuyl21J7osOB66qzfGSQTHCDo6/7ucE8tZL6jL',
@ -278,9 +349,6 @@
<li class="nav-item d-none d-md-block">
<a href="#wallet" class="nav-link bar-link" data-page="wallet">Wallet</a>
</li>
<li class="nav-item d-none d-md-block">
<a href="https://git.tornado.ws/tornadocontrib/tovarish-relayer" target="_blank" rel="noreferrer nofollow" class="nav-link">FAQ</a>
</li>
<li class="nav-item d-none d-md-block">
<a onclick="settings()" class="nav-link"><i class="bi bi-gear-fill"></i></a>
</li>
@ -316,9 +384,6 @@
<li class="nav-item d-md-none">
<a href="#wallet" class="nav-link bar-link" data-page="wallet">Wallet</a>
</li>
<li class="nav-item d-md-none">
<a href="https://git.tornado.ws/tornadocontrib/tovarish-relayer" target="_blank" rel="noreferrer nofollow" class="nav-link">FAQ</a>
</li>
<li class="nav-item d-md-none">
<a onclick="settings()" class="nav-link"><i class="bi bi-gear-fill"></i>&nbsp;Settings</a>
</li>
@ -482,7 +547,9 @@
</div>
</div>
<div class="mt-5">
<div class="form-text">Information of notes, deposits, withdrawals, or private keys is never shared among any other third parties including us, relayers, and RPC providers. You can download and audit the source code of this website by simply saving it to index.html</div>
<div class="form-text pb-2">Information of notes, deposits, withdrawals, or private keys is never shared among any other third parties including us, relayers, and RPC providers. You can download and audit the source code of this website by simply saving it to index.html</div>
<div class="form-text">By using this website you are confirming that you aren't from United States, United Kingdom, Netherlands, sanctioned country by the United Nations Security Council or anywhere where the usage of Tornado Cash is legally prohibited</div>
</div>
</div>
</div>
@ -1021,7 +1088,7 @@
</li>
</ul>
<p class="ms-2 text-muted justify-content-end">Built with <a href="https://git.tornado.ws/tornadocontrib/tornado-core" target="_blank" rel="noreferrer nofollow">@tornado/core</a></p>
<p class="ms-2 text-muted justify-content-end">Built with <a href="https://git.tornado.ws/tornadocontrib/tornado-core" target="_blank" rel="noreferrer nofollow">@tornado/core</a> | <a target="_blank" rel="noreferrer nofollow" class="donation">Donate</a></p>
</footer>
</div>
@ -1101,6 +1168,24 @@
</div>
</div>
<!-- Prohibited Modal -->
<div id="prohibited" class="modal fade" tabindex="-3">
<div class="modal-dialog modal-xl" style="max-width: 950px;">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Access denied</h5>
</div>
<div class="modal-body">
<div id="prohibited-context"></div>
<img src="https://cdn.jsdelivr.net/npm/tornado-cdn@1.0.4/failed.png" class="status">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary " data-bs-dismiss="modal">I am not the citizen of those prohibited countries</button>
</div>
</div>
</div>
</div>
<script>
let settingsDB;
const AllDB = new Map();
@ -1507,6 +1592,43 @@
await loadSettings();
}
async function checkIP() {
try {
// Only check IP on public instances
if (new URL(window.location.href).protocol !== 'https:') {
return;
}
const { ip, iso, tor } = await Tornado.fetchIp(IP_ECHO);
const prohibited = Boolean(PROHIBITED_COUNTRIES.find(c => c.iso === iso)) && !tor;
console.log(`Your IP: ${ip} (${iso}) ${tor ? '(TOR)' : ''} ${prohibited ? '(Prohibited)' : ''}`);
// Show prohibited prompt if it is not TOR and the IP is from one of those countries
if (!prohibited) {
return;
}
$('#prohibited-context').empty();
$('#prohibited-context').append(`
<p>Following countries are denied access to the UI:</p>
<p>${PROHIBITED_COUNTRIES.map(({ country }) => country).join(', ')}</p>
<p>By confirming with the button below you are confirming that you aren't citizen of the countries above</p>
`);
// Toggle Modal
new bootstrap.Modal('#prohibited', { backdrop: 'static', keyboard: false }).toggle();
} catch (err) {
console.log('Failed to check IP');
console.log(err);
}
}
function getStaticRoot() {
const url = new URL(window.location.href);
@ -5827,6 +5949,7 @@
}
await loadSettings();
checkIP();
await getAllRelayers();
displayNetworks();
displayCurrency();

@ -1,6 +1,6 @@
{
"name": "tornado-withdraw",
"version": "1.0.0",
"version": "1.0.4",
"private": true,
"main": "index.js",
"scripts": {