proxy-kaze 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +5 -4
  2. package/pro.js +29 -41
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "proxy-kaze",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "main": "pro.js",
5
5
  "bin": {
6
- "sockproxy": "./pro.js"
7
- }
8
- }
6
+ "pk": "pro.js"
7
+ },
8
+ "preferGlobal": true
9
+ }
package/pro.js CHANGED
@@ -19,13 +19,6 @@ function hasCmd(cmd) {
19
19
  }
20
20
  }
21
21
 
22
- function detectPkgManager() {
23
- if (hasCmd('apt')) return 'apt';
24
- if (hasCmd('pacman')) return 'pacman';
25
- if (hasCmd('dnf')) return 'dnf';
26
- return null;
27
- }
28
-
29
22
  function genAuth(min, max) {
30
23
  const len = Math.floor(Math.random() * (max - min + 1) + min);
31
24
  return crypto.randomBytes(len).toString('hex').slice(0, len);
@@ -38,38 +31,37 @@ const B_PORT = Math.floor(Math.random() * 40000 + 20000);
38
31
  const FULL_PROXY = `socks5://${USER}:${PASS}@bore.pub:${B_PORT}`;
39
32
 
40
33
  // ---------- installers ----------
41
- function installTermux() {
42
- console.log("Detected Termux environment...");
43
34
 
44
- if (!hasCmd('tmux') || !hasCmd('bore') || !hasCmd('gost')) {
45
- execSync(
46
- "pkg update -y && pkg install nodejs-lts bore tmux termux-api gost -y",
47
- { stdio: 'inherit' }
48
- );
35
+ function installTermux() {
36
+ console.log("Detected Termux...");
37
+ if (!hasCmd('bore') || !hasCmd('gost')) {
38
+ execSync("pkg update -y && pkg install bore gost -y", { stdio: 'inherit' });
49
39
  }
50
40
  }
51
41
 
52
- function installLinux(pkg) {
53
- console.log(`Using ${pkg} to install dependencies...`);
42
+ function installLinux() {
43
+ console.log("Installing Linux deps...");
54
44
 
55
45
  if (!hasCmd('curl')) {
56
- if (pkg === 'apt') execSync('sudo apt install -y curl', { stdio: 'inherit' });
57
- if (pkg === 'pacman') execSync('sudo pacman -Sy curl', { stdio: 'inherit' });
58
- if (pkg === 'dnf') execSync('sudo dnf install -y curl', { stdio: 'inherit' });
46
+ execSync("sudo apt update && sudo apt install -y curl", { stdio: 'inherit' });
59
47
  }
60
48
 
61
49
  if (!hasCmd('bore')) {
62
- execSync(
63
- 'curl -L https://github.com/ekzhang/bore/releases/latest/download/bore-linux-amd64 -o bore && chmod +x bore && sudo mv bore /usr/local/bin/',
64
- { stdio: 'inherit' }
65
- );
50
+ execSync(`
51
+ curl -L https://github.com/ekzhang/bore/releases/download/v0.6.0/bore-v0.6.0-x86_64-unknown-linux-musl.tar.gz -o bore.tar.gz &&
52
+ tar -xzf bore.tar.gz &&
53
+ chmod +x bore &&
54
+ sudo mv bore /usr/local/bin/
55
+ `, { stdio: 'inherit' });
66
56
  }
67
57
 
68
58
  if (!hasCmd('gost')) {
69
- execSync(
70
- 'curl -L https://github.com/go-gost/gost/releases/latest/download/gost-linux-amd64 -o gost && chmod +x gost && sudo mv gost /usr/local/bin/',
71
- { stdio: 'inherit' }
72
- );
59
+ execSync(`
60
+ curl -L https://github.com/go-gost/gost/releases/download/v3.2.6/gost_3.2.6_linux_amd64.tar.gz -o gost.tar.gz &&
61
+ tar -xzf gost.tar.gz &&
62
+ chmod +x gost &&
63
+ sudo mv gost /usr/local/bin/
64
+ `, { stdio: 'inherit' });
73
65
  }
74
66
  }
75
67
 
@@ -77,12 +69,17 @@ function installWindows() {
77
69
  console.log("Detected Windows...");
78
70
 
79
71
  if (!hasCmd('winget')) {
80
- console.log("Winget not found. Install 'App Installer' from Microsoft Store.");
72
+ console.log("Install winget first.");
81
73
  process.exit(1);
82
74
  }
83
75
 
84
- if (!hasCmd('bore')) execSync('winget install --id sharkdp.bore -e', { stdio: 'inherit' });
85
- if (!hasCmd('gost')) execSync('winget install --id gost.gost -e', { stdio: 'inherit' });
76
+ if (!hasCmd('bore')) {
77
+ execSync(`powershell -Command "Invoke-WebRequest -Uri https://github.com/ekzhang/bore/releases/download/v0.6.0/bore-v0.6.0-x86_64-pc-windows-msvc.zip -OutFile bore.zip; Expand-Archive bore.zip -DestinationPath C:\\bore"`, { stdio: 'inherit' });
78
+ }
79
+
80
+ if (!hasCmd('gost')) {
81
+ execSync(`powershell -Command "Invoke-WebRequest -Uri https://github.com/go-gost/gost/releases/download/v3.2.6/gost_3.2.6_windows_amd64.zip -OutFile gost.zip; Expand-Archive gost.zip -DestinationPath C:\\gost"`, { stdio: 'inherit' });
82
+ }
86
83
  }
87
84
 
88
85
  // ---------- dependency setup ----------
@@ -94,20 +91,12 @@ function installDeps() {
94
91
  try {
95
92
  if (IS_TERMUX || PLATFORM === 'android') {
96
93
  installTermux();
97
-
98
94
  } else if (PLATFORM === 'linux') {
99
- const pkg = detectPkgManager();
100
- if (!pkg) {
101
- console.log("No supported package manager found.");
102
- process.exit(1);
103
- }
104
- installLinux(pkg);
105
-
95
+ installLinux();
106
96
  } else if (PLATFORM === 'win32') {
107
97
  installWindows();
108
-
109
98
  } else {
110
- console.log("Unsupported OS.");
99
+ console.log("Unsupported OS");
111
100
  process.exit(1);
112
101
  }
113
102
 
@@ -138,7 +127,6 @@ function start() {
138
127
  if (PLATFORM === 'win32') {
139
128
  spawn('cmd', ['/c', gostCmd], { stdio: 'inherit' });
140
129
  spawn('cmd', ['/c', boreCmd], { stdio: 'inherit' });
141
-
142
130
  } else {
143
131
  spawn('sh', ['-c', gostCmd], { stdio: 'inherit' });
144
132
  spawn('sh', ['-c', boreCmd], { stdio: 'inherit' });