Skip to content

Commit 4a4208f

Browse files
committed
update
1 parent d5b145a commit 4a4208f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+278
-99
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@conet.project/conet-proxy",
33

4-
"version": "0.5.0",
4+
"version": "0.5.1",
55

66
"license": "UNLICENSED",
77
"files": [

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const launchDaemon = (port: number, path: string) => {
3636
new Daemon ( port, path )
3737
}
3838

39-
export const proxyServer = (post: string, entryNode: nodes_info, _egressNode: nodes_info, profile: profile) => new proxyServer_class(post, [entryNode], [_egressNode], profile, false, '')
39+
export const proxyServer = (post: string, entryNode: nodes_info, _egressNode: nodes_info, privateKey: string) => new proxyServer_class(post, [entryNode], [_egressNode], privateKey, false, '')
4040

4141
if (argv.port || argv.path) {
4242
PATH = argv.path

src/localServer/localServer.ts

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,12 @@ const joinMetadata = (metadata: any ) => {
178178

179179
let _proxyServer: proxyServer
180180

181-
const changeRegion = (selectedCountry: string) => {
182181

183-
const result = miningClass.changeUsedNodes (selectedCountry)
184-
if (!result || !result.length) {
185-
return false
186-
}
187-
188-
const activeNodes = result.slice(0, result.length/2)
189-
const egressNodes = result.slice(result.length/2)
190-
191-
if (_proxyServer) {
192-
_proxyServer.restart(profile, activeNodes, egressNodes)
193-
} else {
194-
_proxyServer = new proxyServer((3002).toString(), activeNodes, egressNodes, profile, true, '')
195-
}
182+
const startSilentPass = (vpnObj: Native_StartVPNObj) => {
183+
logger(inspect(vpnObj, false, 3, true))
196184

197-
return result
185+
new proxyServer((3002).toString(), vpnObj.entryNodes, vpnObj.exitNode, vpnObj.privateKey, true, '')
186+
return true
198187
}
199188

200189

@@ -221,6 +210,13 @@ export const return404 = () => {
221210
}
222211

223212

213+
type Native_StartVPNObj = {
214+
entryNodes: nodes_info[]
215+
privateKey: string
216+
exitNode: nodes_info[]
217+
}
218+
219+
224220
export class Daemon {
225221
private logsPool: proxyLogs[] = []
226222

@@ -454,20 +450,16 @@ export class Daemon {
454450

455451

456452
app.post('/startSilentPass', async (req: any, res: any) => {
457-
const selectedCountry = req.body.selectedCountry;
453+
const vpnObj: Native_StartVPNObj = req.body.vpnInfo
458454

459-
console.log('selectedCountry', selectedCountry)
460455

461-
if (!selectedCountry) {
456+
if (!vpnObj) {
462457
return res.status(400).send({ error: "No country selected" })
463458
}
464-
const ret = changeRegion (selectedCountry)
465459

466-
if (!ret) {
467-
return res.status(400).send({ error: `No nodes find in region ${selectedCountry}` })
468-
}
460+
startSilentPass (vpnObj)
469461

470-
res.json(ret).end()
462+
res.status(200).json({}).end()
471463

472464
})
473465

src/localServer/proxyServer.ts

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type {RequestOptions} from 'node:https'
1313
import * as openpgp from 'openpgp'
1414
import { TransformCallback } from 'stream'
1515
import { ethers } from 'ethers'
16-
import EthCrypto from 'eth-crypto'
1716
import * as Crypto from 'crypto'
1817
import IP from 'ip'
1918
import {resolve4} from 'node:dns'
@@ -160,11 +159,8 @@ const encrypt_Message = async (encryptionKeys, message: any) => {
160159
}
161160

162161

163-
const createSock5ConnectCmd = async (currentProfile: profile, SaaSnode: nodes_info, requestData: any[]) => {
164-
if (!currentProfile.pgpKey|| !SaaSnode.armoredPublicKey ) {
165-
logger (Colors.red(`currentProfile?.pgpKey[${currentProfile?.pgpKey}]|| !SaaSnode?.armoredPublicKey[${SaaSnode?.armoredPublicKey}] Error`))
166-
return null
167-
}
162+
const createSock5ConnectCmd = async (wallet: ethers.Wallet, SaaSnode: nodes_info, requestData: any[]) => {
163+
168164

169165
if (!SaaSnode?.publicKeyObj) {
170166
SaaSnode.publicKeyObj = await openpgp.readKey ({ armoredKey: SaaSnode.armoredPublicKey })
@@ -177,19 +173,18 @@ const createSock5ConnectCmd = async (currentProfile: profile, SaaSnode: nodes_in
177173
algorithm: 'aes-256-cbc',
178174
Securitykey: key,
179175
requestData,
180-
walletAddress: currentProfile.keyID.toLowerCase()
176+
walletAddress: wallet.address.toLowerCase()
181177
}
182178

183179

184180
logger(Colors.blue(`createSock5ConnectCmd data = ${inspect(requestData, false, 3, true)}`))
185181
logger(Colors.blue(`createSock5ConnectCmd data length = ${requestData[0].buffer.length}`))
186182

187183
const message =JSON.stringify(command)
188-
const messageHash = ethers.id(message)
189-
const signMessage = EthCrypto.sign(currentProfile.privateKeyArmor, messageHash)
190-
184+
const signMessage = await wallet.signMessage(message)
191185

192186
const encryptedCommand = await encrypt_Message( SaaSnode.publicKeyObj, {message, signMessage})
187+
logger(inspect({message, signMessage}, false, 3, true))
193188
command.requestData = [encryptedCommand, '', key]
194189
return (command)
195190
}
@@ -297,6 +292,7 @@ export class proxyServer {
297292
public connectHostTimeOut = 1000 * 5
298293
public useGatWay = true
299294
public clientSockets: Set<Net.Socket> = new Set()
295+
public currentWallet: ethers.Wallet
300296

301297
private startLocalProxy = async () => {
302298

@@ -363,16 +359,6 @@ export class proxyServer {
363359
this.server.listen ( this.proxyPort, () => {
364360
return logger ( Colors.blue(`Proxy SERVER success on port : [${ this.proxyPort }] entry nodes length =[${this._egressNodes?.length}] SaaS nodes = [${this._egressNodes?.length}]`))
365361
})
366-
367-
if (!this.currentProfile?.keyObj) {
368-
this.currentProfile.keyObj = {
369-
privateKeyObj: null,
370-
publicKeyObj: null
371-
}
372-
}
373-
if (this.currentProfile.pgpKey?.privateKeyArmor) {
374-
this.currentProfile.keyObj.privateKeyObj = await makePrivateKeyObj (this.currentProfile.pgpKey.privateKeyArmor)
375-
}
376362

377363
}
378364

@@ -387,7 +373,7 @@ export class proxyServer {
387373

388374

389375

390-
const cmd = await createSock5ConnectCmd (this.currentProfile, upChannel_SaaS_node, [uuuu])
376+
const cmd = await createSock5ConnectCmd (this.currentWallet, upChannel_SaaS_node, [uuuu])
391377
if (!cmd) {
392378
return logger (Colors.red(`requestGetWay createSock5Connect return Null Error!`))
393379
}
@@ -403,8 +389,8 @@ export class proxyServer {
403389
ConnectToProxyNode (cmd, upChannel_SaaS_node, entryNode, socket, uuuu, this)
404390
}
405391

406-
public restart = (currentProfile: profile, entryNodes: nodes_info[], egressNodes: nodes_info[]) => {
407-
this.currentProfile = currentProfile
392+
public restart = (privateKey: string, entryNodes: nodes_info[], egressNodes: nodes_info[]) => {
393+
this.privateKey = privateKey
408394
this._entryNodes = entryNodes
409395
this._egressNodes = egressNodes
410396
}
@@ -413,7 +399,7 @@ export class proxyServer {
413399
public proxyPort: string, // Proxy server listening port number
414400
private _entryNodes: nodes_info[], // gateway nodes information
415401
private _egressNodes: nodes_info[],
416-
private currentProfile: profile,
402+
private privateKey: string,
417403
public debug = false,
418404
public logStream: string
419405

@@ -422,7 +408,7 @@ export class proxyServer {
422408

423409
logger(Colors.magenta(`${proxyPort} Entry Nodes\n${_entryNodes.map(n => [n.ip_addr, n.region])}`))
424410
logger(Colors.magenta(`${proxyPort} Egress Nodes\n${ _egressNodes.map(n =>[n.ip_addr, n.region])}`))
425-
411+
this.currentWallet = new ethers.Wallet(privateKey)
426412
this.startLocalProxy()
427413
}
428414

@@ -435,4 +421,4 @@ export class proxyServer {
435421
})
436422
}
437423

438-
// curl -v -x http://10.0.0.252:3002 "https://www.google.com"
424+
// curl -v -x http://127.0.0.1:3002 "https://www.google.com"
Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,45 @@
11
{
22
"files": {
3-
"main.css": "/static/css/main.673e4c55.css",
4-
"main.js": "/static/js/main.f4bf2749.js",
3+
"main.css": "/static/css/main.455a79af.css",
4+
"main.js": "/static/js/main.f6ddc4ce.js",
55
"static/js/453.9af89cb1.chunk.js": "/static/js/453.9af89cb1.chunk.js",
6+
"static/media/silent-pass-benefits-table.svg": "/static/media/silent-pass-benefits-table.db3e4d9038c74e4db61d77082607294a.svg",
7+
"static/media/silent-pass-service-table.svg": "/static/media/silent-pass-service-table.21f5b4345d1ad5863f9b8ca55363555a.svg",
8+
"static/media/solana-token.svg": "/static/media/solana-token.b77c9030d92aee4550b3ce4f4e946c93.svg",
9+
"static/media/sp-token.svg": "/static/media/sp-token.01da7809f36c2002dfb6fd98f3827a44.svg",
10+
"static/media/conet-token.svg": "/static/media/conet-token.bfd058b390550a59eb001c3a061be91e.svg",
11+
"static/media/support-icon-blue.svg": "/static/media/support-icon-blue.fc618a7a2e712f8d06452a587b8c3c58.svg",
12+
"static/media/support-icon-grey.svg": "/static/media/support-icon-grey.ce648861de23558a27a367d4c1b1f552.svg",
13+
"static/media/visibility-off.svg": "/static/media/visibility-off.12c2f0679ae08f45f758744e3ed0fce8.svg",
14+
"static/media/settings-icon-blue.svg": "/static/media/settings-icon-blue.a9f308f21753ac8e4c79a4692e266781.svg",
15+
"static/media/settings-icon-grey.svg": "/static/media/settings-icon-grey.4efb1fee571c250dac8b77a075c77a71.svg",
16+
"static/media/extra-reward.svg": "/static/media/extra-reward.25c85d3bfc3b9df10349de5fbcecf30e.svg",
17+
"static/media/proxy-information.svg": "/static/media/proxy-information.a87fdb94d52988a7fd427524bea13837.svg",
18+
"static/media/faq-icon.svg": "/static/media/faq-icon.e84a33a3a76e89bf3daf58baf1189fe8.svg",
19+
"static/media/help.svg": "/static/media/help.e84a33a3a76e89bf3daf58baf1189fe8.svg",
20+
"static/media/visibility-on.svg": "/static/media/visibility-on.f5df4f90160c7c5a31897a7432ef7c6a.svg",
21+
"static/media/application.svg": "/static/media/application.43d120a2e74e3c4818090a317f997652.svg",
22+
"static/media/language.svg": "/static/media/language.43d120a2e74e3c4818090a317f997652.svg",
23+
"static/media/progress-activity.svg": "/static/media/progress-activity.9abf838e0c87127f49cc95fa63508d0f.svg",
24+
"static/media/lock-icon.svg": "/static/media/lock-icon.5792ac0be414f7efee34e8ab32edf1b2.svg",
25+
"static/media/usdt-icon.svg": "/static/media/usdt-icon.863996f3459b58076acd013b84f66f57.svg",
26+
"static/media/eth-token.svg": "/static/media/eth-token.a01de1155563ab3775bad55ce05a7957.svg",
27+
"static/media/right-chevron.svg": "/static/media/right-chevron.c19265445e3b2c1f01ac246a3bd9f75a.svg",
628
"index.html": "/index.html",
7-
"main.673e4c55.css.map": "/static/css/main.673e4c55.css.map",
8-
"main.f4bf2749.js.map": "/static/js/main.f4bf2749.js.map",
29+
"static/media/quotes-icon.svg": "/static/media/quotes-icon.73e155d019de520a603406dff24a2a34.svg",
30+
"static/media/wallet-icon-blue.svg": "/static/media/wallet-icon-blue.254e02dcba55c027e5c692f8df78c573.svg",
31+
"static/media/wallet-icon-grey.svg": "/static/media/wallet-icon-grey.a9ec9c11f1a47711d8b76924c4961495.svg",
32+
"static/media/ads-block.svg": "/static/media/ads-block.47d4110dcba7c665d18aca0342e609ad.svg",
33+
"static/media/wallet-icon.svg": "/static/media/wallet-icon.74ec366fac4e5645a70e6276346e9413.svg",
34+
"static/media/home-icon-blue.svg": "/static/media/home-icon-blue.45c1c9a5a853e7916aead3e3f6609425.svg",
35+
"static/media/home-icon-grey.svg": "/static/media/home-icon-grey.4aa751c909129f6c3b4ba9fa19c15715.svg",
36+
"static/media/split-tunneling.svg": "/static/media/split-tunneling.9e6f6574614b30a8fa5483b6e26b49af.svg",
37+
"main.455a79af.css.map": "/static/css/main.455a79af.css.map",
38+
"main.f6ddc4ce.js.map": "/static/js/main.f6ddc4ce.js.map",
939
"453.9af89cb1.chunk.js.map": "/static/js/453.9af89cb1.chunk.js.map"
1040
},
1141
"entrypoints": [
12-
"static/css/main.673e4c55.css",
13-
"static/js/main.f4bf2749.js"
42+
"static/css/main.455a79af.css",
43+
"static/js/main.f6ddc4ce.js"
1444
]
1545
}
Lines changed: 7 additions & 0 deletions
Loading
1.58 KB
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)