From 5dd1b14c1b73a8cbe6484e8f86069b81edec5021 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 16 May 2023 11:10:03 +0300 Subject: [PATCH] Fix RPC link checking: it must starts with protocol (like ws or https), not includes, because because in this case, RPC sites that have these characters in name or in domain don't work correctly --- cli.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli.js b/cli.js index abe6e27..6ee2ae2 100755 --- a/cli.js +++ b/cli.js @@ -1374,7 +1374,7 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100', balanceC if (noteNetId && !rpc) rpc = config.deployments[`netId${noteNetId}`].defaultRpc; - if (torPort && rpc.includes('https')) { + if (torPort && rpc.startsWith('https')) { console.log('Using tor network'); web3Options = { agent: { https: new SocksProxyAgent('socks5h://127.0.0.1:' + torPort) }, timeout: 60000 }; // Use forked web3-providers-http from local file to modify user-agent header value which improves privacy. @@ -1383,7 +1383,7 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100', balanceC httpsAgent: new SocksProxyAgent('socks5h://127.0.0.1:' + torPort), headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0' } }; - } else if (torPort && rpc.includes('http')) { + } else if (torPort && rpc.startsWith('http')) { console.log('Using tor network'); web3Options = { agent: { http: new SocksProxyAgent('socks5h://127.0.0.1:' + torPort) }, timeout: 60000 }; // Use forked web3-providers-http from local file to modify user-agent header value which improves privacy. @@ -1395,7 +1395,7 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100', balanceC } else if (rpc.includes('ipc')) { console.log('Using ipc connection'); web3 = new Web3(new Web3.providers.IpcProvider(rpc, net), null, { transactionConfirmationBlocks: 1 }); - } else if (rpc.includes('ws') || rpc.includes('wss')) { + } else if (rpc.startsWith('ws') || rpc.startsWith('wss')) { console.log('Using websocket connection (Note: Tor is not supported for Websocket providers)'); web3Options = { clientConfig: { keepalive: true, keepaliveInterval: -1 },