instatunnel 1.0.14 → 1.0.16

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.
package/bin/instatunnel CHANGED
Binary file
Binary file
package/bin/it CHANGED
Binary file
Binary file
package/install.js CHANGED
@@ -21,7 +21,7 @@ const colors = {
21
21
  };
22
22
 
23
23
  function log(message, color = 'reset') {
24
- console.log(`${colors[color]}${message}${colors.reset}`);
24
+ console.log(colors[color] + message + colors.reset);
25
25
  }
26
26
 
27
27
  function detectPlatform() {
@@ -46,9 +46,9 @@ function detectPlatform() {
46
46
  platformSuffix = 'openbsd';
47
47
  break;
48
48
  default:
49
- throw new Error(`Unsupported platform: ${platform}`);
49
+ throw new Error('Unsupported platform: ' + platform);
50
50
  }
51
-
51
+
52
52
  let archSuffix;
53
53
  switch (arch) {
54
54
  case 'x64':
@@ -61,11 +61,11 @@ function detectPlatform() {
61
61
  archSuffix = '386';
62
62
  break;
63
63
  default:
64
- throw new Error(`Unsupported architecture: ${arch}`);
64
+ throw new Error('Unsupported architecture: ' + arch);
65
65
  }
66
-
66
+
67
67
  const extension = platform === 'win32' ? '.exe' : '';
68
- return `${BINARY_NAME}-${platformSuffix}-${archSuffix}${extension}`;
68
+ return { platform: platformSuffix, arch: archSuffix, extension };
69
69
  }
70
70
 
71
71
  function downloadFile(url, outputPath) {
@@ -73,29 +73,20 @@ function downloadFile(url, outputPath) {
73
73
  const file = fs.createWriteStream(outputPath);
74
74
 
75
75
  https.get(url, (response) => {
76
- // Handle redirects
77
- if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
78
- file.close();
79
- fs.unlinkSync(outputPath);
80
- return downloadFile(response.headers.location, outputPath).then(resolve).catch(reject);
81
- }
82
-
83
76
  if (response.statusCode !== 200) {
84
- file.close();
85
- fs.unlinkSync(outputPath);
86
- reject(new Error(`HTTP ${response.statusCode}: ${response.statusMessage}`));
77
+ reject(new Error('Download failed with status: ' + response.statusCode));
87
78
  return;
88
79
  }
89
80
 
90
81
  response.pipe(file);
91
82
 
92
83
  file.on('finish', () => {
93
- file.close(resolve);
84
+ file.close();
85
+ resolve();
94
86
  });
95
87
 
96
88
  file.on('error', (err) => {
97
- file.close();
98
- fs.unlinkSync(outputPath);
89
+ fs.unlink(outputPath, () => {}); // Delete the file on error
99
90
  reject(err);
100
91
  });
101
92
  }).on('error', (err) => {
@@ -105,92 +96,98 @@ function downloadFile(url, outputPath) {
105
96
  }
106
97
 
107
98
  async function downloadBinary() {
108
- const binaryName = detectPlatform();
109
- const binDir = path.join(__dirname, 'bin');
110
- const isWindows = os.platform() === 'win32';
111
- const outputPath = path.join(binDir, isWindows ? 'instatunnel.exe' : 'instatunnel');
112
-
113
- // Create bin directory
114
- if (!fs.existsSync(binDir)) {
115
- fs.mkdirSync(binDir, { recursive: true });
116
- }
117
-
118
- log('🚀 Installing InstaTunnel CLI...', 'blue');
119
- log(`📋 Platform: ${os.platform()}-${os.arch()}`, 'cyan');
120
-
121
- // Try primary URL first
122
- const primaryUrl = `${PRIMARY_URL}/${binaryName}`;
123
- const fallbackUrl = `${FALLBACK_URL}/${binaryName}`;
99
+ log('🚀 Installing InstaTunnel CLI...', 'cyan');
124
100
 
125
101
  try {
126
- log('📥 Downloading from primary source...', 'blue');
127
- await downloadFile(primaryUrl, outputPath);
128
- } catch (primaryError) {
129
- log(`⚠️ Primary download failed: ${primaryError.message}`, 'yellow');
130
- log('📥 Trying fallback source (GitHub)...', 'blue');
102
+ const { platform, arch, extension } = detectPlatform();
103
+ const binDir = path.join(__dirname, 'bin');
104
+
105
+ // Ensure bin directory exists
106
+ if (!fs.existsSync(binDir)) {
107
+ fs.mkdirSync(binDir, { recursive: true });
108
+ }
109
+
110
+ // Use pre-compiled binaries from our package
111
+ const sourceBinaryName = BINARY_NAME + '-' + platform + '-' + arch + extension;
112
+ const sourceBinaryPath = path.join(binDir, sourceBinaryName);
113
+
114
+ if (fs.existsSync(sourceBinaryPath)) {
115
+ log('✅ Using pre-compiled binary: ' + sourceBinaryName, 'green');
116
+
117
+ // Copy to main binary names
118
+ const mainBinaryPath = path.join(binDir, BINARY_NAME + extension);
119
+ const aliasBinaryPath = path.join(binDir, 'it' + extension);
120
+
121
+ fs.copyFileSync(sourceBinaryPath, mainBinaryPath);
122
+ fs.copyFileSync(sourceBinaryPath, aliasBinaryPath);
123
+
124
+ // Make executable on Unix systems
125
+ if (platform !== 'windows') {
126
+ fs.chmodSync(mainBinaryPath, '755');
127
+ fs.chmodSync(aliasBinaryPath, '755');
128
+ }
129
+
130
+ log('✅ InstaTunnel CLI installed successfully!', 'green');
131
+ log('', 'reset');
132
+ log('🎉 Quick start:', 'yellow');
133
+ log(' instatunnel 3000 # Expose port 3000', 'cyan');
134
+ log(' it 3000 # Short alias', 'cyan');
135
+ log(' instatunnel --help # Show all options', 'cyan');
136
+ log('', 'reset');
137
+
138
+ return;
139
+ }
140
+
141
+ // Fallback to download if pre-compiled binary not found
142
+ log('📥 Downloading ' + sourceBinaryName + ' from server...', 'yellow');
143
+ const downloadUrl = PRIMARY_URL + '/' + sourceBinaryName;
131
144
 
132
145
  try {
133
- await downloadFile(fallbackUrl, outputPath);
134
- } catch (fallbackError) {
135
- throw new Error(`Both downloads failed:\n Primary: ${primaryError.message}\n Fallback: ${fallbackError.message}`);
146
+ await downloadFile(downloadUrl, sourceBinaryPath);
147
+ } catch (err) {
148
+ log('⚠️ Primary download failed, trying fallback...', 'yellow');
149
+ const fallbackUrl = FALLBACK_URL + '/' + sourceBinaryName;
150
+ await downloadFile(fallbackUrl, sourceBinaryPath);
136
151
  }
137
- }
138
-
139
- // Verify binary was downloaded and is valid
140
- if (!fs.existsSync(outputPath) || fs.statSync(outputPath).size === 0) {
141
- throw new Error('Downloaded binary is invalid or empty');
142
- }
143
-
144
- // Make executable on Unix systems
145
- if (!isWindows) {
146
- fs.chmodSync(outputPath, 0o755);
147
- }
148
-
149
- // Create 'it' alias and Windows wrappers
150
- const itPath = path.join(binDir, isWindows ? 'it.exe' : 'it');
151
- fs.copyFileSync(outputPath, itPath);
152
-
153
- // Create Windows wrapper scripts to prevent new console window
154
- if (isWindows) {
155
- const instatunnelCmd = path.join(binDir, 'instatunnel.cmd');
156
- const itCmd = path.join(binDir, 'it.cmd');
157
152
 
158
- // Create instatunnel.cmd wrapper
159
- const instatunnelWrapper = '@echo off\r\nsetlocal\r\nset "args=%*"\r\n"%~dp0instatunnel.exe" %args%\r\nendlocal\r\n';
160
- fs.writeFileSync(instatunnelCmd, instatunnelWrapper);
153
+ // Verify download
154
+ const stats = fs.statSync(sourceBinaryPath);
155
+ if (stats.size < 1000000) {
156
+ throw new Error('Downloaded binary appears corrupted (too small)');
157
+ }
158
+
159
+ // Copy to main binary names
160
+ const mainBinaryPath = path.join(binDir, BINARY_NAME + extension);
161
+ const aliasBinaryPath = path.join(binDir, 'it' + extension);
162
+
163
+ fs.copyFileSync(sourceBinaryPath, mainBinaryPath);
164
+ fs.copyFileSync(sourceBinaryPath, aliasBinaryPath);
161
165
 
162
- // Create it.cmd wrapper
163
- const itWrapper = '@echo off\r\nsetlocal\r\nset "args=%*"\r\n"%~dp0it.exe" %args%\r\nendlocal\r\n';
164
- fs.writeFileSync(itCmd, itWrapper);
166
+ // Make executable on Unix systems
167
+ if (platform !== 'windows') {
168
+ fs.chmodSync(sourceBinaryPath, '755');
169
+ fs.chmodSync(mainBinaryPath, '755');
170
+ fs.chmodSync(aliasBinaryPath, '755');
171
+ }
165
172
 
166
- log('✅ Windows wrapper scripts created to prevent new console window', 'green');
173
+ log('✅ InstaTunnel CLI installed successfully!', 'green');
174
+ log('', 'reset');
175
+ log('🎉 Quick start:', 'yellow');
176
+ log(' instatunnel 3000 # Expose port 3000', 'cyan');
177
+ log(' it 3000 # Short alias', 'cyan');
178
+ log(' instatunnel --help # Show all options', 'cyan');
179
+ log('', 'reset');
180
+
181
+ } catch (error) {
182
+ throw new Error('Installation failed: ' + error.message);
167
183
  }
168
184
 
169
- log('✅ InstaTunnel CLI installed successfully!', 'green');
170
- log('', 'reset');
171
- log('🚀 Quick Start:', 'cyan');
172
- log(' instatunnel 3000 # Expose port 3000 instantly (no setup needed!)', 'reset');
173
- log(' it 3000 # Short alias for the same command', 'reset');
174
- log('', 'reset');
175
- log('💡 More examples:', 'cyan');
176
- log(' instatunnel # Auto-detect common ports (3000, 8000, 8080)', 'reset');
177
- log(' instatunnel 8080 --name myapp', 'reset');
178
- log(' instatunnel --help # See all options', 'reset');
179
- log('', 'reset');
180
- log('🌟 Key Benefits:', 'yellow');
181
- log(' ✓ No signup required - works instantly', 'green');
182
- log(' ✓ 24+ hour sessions (vs ngrok\'s 2 hours)', 'green');
183
- log(' ✓ Custom subdomains included free', 'green');
184
- log(' ✓ 40% cheaper than ngrok', 'green');
185
- log('', 'reset');
186
- log('📚 Documentation: https://docs.instatunnel.my', 'yellow');
187
-
188
- // Test installation - skip version test to avoid hanging
185
+ // Test installation
189
186
  try {
190
- // Just verify the file exists and has content
191
- const stats = fs.statSync(outputPath);
187
+ const binaryPath = path.join(__dirname, 'bin', BINARY_NAME + (os.platform() === 'win32' ? '.exe' : ''));
188
+ const stats = fs.statSync(binaryPath);
192
189
  if (stats.size > 1000000) { // Binary should be at least 1MB
193
- log(`🔧 Installation verified! Binary size: ${Math.round(stats.size / 1024 / 1024)}MB`, 'green');
190
+ log('🔧 Installation verified! Binary size: ' + Math.round(stats.size / 1024 / 1024) + 'MB', 'green');
194
191
  } else {
195
192
  log('⚠️ Binary seems too small, but installation completed', 'yellow');
196
193
  }
@@ -202,30 +199,7 @@ async function downloadBinary() {
202
199
  // Create uninstall script
203
200
  function createUninstallScript() {
204
201
  const uninstallPath = path.join(__dirname, 'uninstall.js');
205
- const uninstallScript = `#!/usr/bin/env node
206
-
207
- const fs = require('fs');
208
- const path = require('path');
209
-
210
- function cleanup() {
211
- const binDir = path.join(__dirname, 'bin');
212
-
213
- try {
214
- if (fs.existsSync(binDir)) {
215
- fs.rmSync(binDir, { recursive: true, force: true });
216
- }
217
- console.log('✅ InstaTunnel CLI uninstalled successfully!');
218
- } catch (error) {
219
- console.warn('⚠️ Some cleanup may be incomplete:', error.message);
220
- }
221
- }
222
-
223
- if (require.main === module) {
224
- cleanup();
225
- }
226
-
227
- module.exports = { cleanup };
228
- `;
202
+ const uninstallScript = "#!/usr/bin/env node\n\nconst fs = require('fs');\nconst path = require('path');\n\nfunction cleanup() {\n const binDir = path.join(__dirname, 'bin');\n \n try {\n if (fs.existsSync(binDir)) {\n fs.rmSync(binDir, { recursive: true, force: true });\n }\n console.log('✅ InstaTunnel CLI uninstalled successfully!');\n } catch (error) {\n console.warn('⚠️ Some cleanup may be incomplete:', error.message);\n }\n}\n\nif (require.main === module) {\n cleanup();\n}\n\nmodule.exports = { cleanup };\n";
229
203
 
230
204
  fs.writeFileSync(uninstallPath, uninstallScript);
231
205
  }
@@ -233,42 +207,8 @@ module.exports = { cleanup };
233
207
  // Create test script
234
208
  function createTestScript() {
235
209
  const testPath = path.join(__dirname, 'test.js');
236
- const testScript = `#!/usr/bin/env node
237
-
238
- const { execSync } = require('child_process');
239
- const path = require('path');
240
- const os = require('os');
241
-
242
- function test() {
243
- const binDir = path.join(__dirname, 'bin');
244
- const isWindows = os.platform() === 'win32';
245
- const instatunnelPath = path.join(binDir, isWindows ? 'instatunnel.exe' : 'instatunnel');
246
- const itPath = path.join(binDir, isWindows ? 'it.exe' : 'it');
247
-
248
- try {
249
- // Test main command
250
- const helpOutput = execSync(\`"\${instatunnelPath}" --help\`, { encoding: 'utf8', timeout: 5000 });
251
- console.log('✅ instatunnel command works');
252
-
253
- // Test alias
254
- const itHelpOutput = execSync(\`"\${itPath}" --help\`, { encoding: 'utf8', timeout: 5000 });
255
- console.log('✅ it alias works');
256
-
257
- console.log('✅ All tests passed!');
258
- return true;
259
- } catch (error) {
260
- console.error('❌ Test failed:', error.message);
261
- return false;
262
- }
263
- }
264
-
265
- if (require.main === module) {
266
- const success = test();
267
- process.exit(success ? 0 : 1);
268
- }
269
-
270
- module.exports = { test };
271
- `;
210
+ const extension = os.platform() === 'win32' ? '.exe' : '';
211
+ const testScript = "#!/usr/bin/env node\n\nconst { execSync } = require('child_process');\nconst path = require('path');\nconst os = require('os');\n\nfunction test() {\n const binDir = path.join(__dirname, 'bin');\n const extension = os.platform() === 'win32' ? '.exe' : '';\n const instatunnelPath = path.join(binDir, 'instatunnel' + extension);\n const itPath = path.join(binDir, 'it' + extension);\n \n try {\n // Test main command - execute binary directly, not with node\n const helpOutput = execSync('\"' + instatunnelPath + '\" --help', { encoding: 'utf8', timeout: 5000 });\n console.log('✅ instatunnel command works');\n \n // Test alias - execute binary directly, not with node\n const itHelpOutput = execSync('\"' + itPath + '\" --help', { encoding: 'utf8', timeout: 5000 });\n console.log('✅ it alias works');\n \n console.log('✅ All tests passed!');\n return true;\n } catch (error) {\n console.error('❌ Test failed:', error.message);\n return false;\n }\n}\n\nif (require.main === module) {\n const success = test();\n process.exit(success ? 0 : 1);\n}\n\nmodule.exports = { test };\n";
272
212
 
273
213
  fs.writeFileSync(testPath, testScript);
274
214
  }
@@ -280,7 +220,7 @@ if (require.main === module) {
280
220
  createTestScript();
281
221
  })
282
222
  .catch((err) => {
283
- log(`❌ Installation failed: ${err.message}`, 'red');
223
+ log('❌ Installation failed: ' + err.message, 'red');
284
224
  log('', 'reset');
285
225
  log('🔧 Troubleshooting:', 'yellow');
286
226
  log(' • Check your internet connection', 'reset');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instatunnel",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Expose your localhost to the internet instantly - the ngrok alternative that's 40% cheaper with superior UX",
5
5
  "main": "install.js",
6
6
  "bin": {
@@ -71,10 +71,9 @@
71
71
  "uninstall.js",
72
72
  "test.js",
73
73
  "bin/",
74
- "*.cmd",
75
74
  "README.md"
76
75
  ],
77
76
  "directories": {
78
77
  "bin": "./bin"
79
78
  }
80
- }
79
+ }
package/test.js ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execSync } = require('child_process');
4
+ const path = require('path');
5
+ const os = require('os');
6
+
7
+ function test() {
8
+ const binDir = path.join(__dirname, 'bin');
9
+ const extension = os.platform() === 'win32' ? '.exe' : '';
10
+ const instatunnelPath = path.join(binDir, 'instatunnel' + extension);
11
+ const itPath = path.join(binDir, 'it' + extension);
12
+
13
+ try {
14
+ // Test main command - execute binary directly, not with node
15
+ const helpOutput = execSync('"' + instatunnelPath + '" --help', { encoding: 'utf8', timeout: 5000 });
16
+ console.log('✅ instatunnel command works');
17
+
18
+ // Test alias - execute binary directly, not with node
19
+ const itHelpOutput = execSync('"' + itPath + '" --help', { encoding: 'utf8', timeout: 5000 });
20
+ console.log('✅ it alias works');
21
+
22
+ console.log('✅ All tests passed!');
23
+ return true;
24
+ } catch (error) {
25
+ console.error('❌ Test failed:', error.message);
26
+ return false;
27
+ }
28
+ }
29
+
30
+ if (require.main === module) {
31
+ const success = test();
32
+ process.exit(success ? 0 : 1);
33
+ }
34
+
35
+ module.exports = { test };
package/uninstall.js ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ function cleanup() {
7
+ const binDir = path.join(__dirname, 'bin');
8
+
9
+ try {
10
+ if (fs.existsSync(binDir)) {
11
+ fs.rmSync(binDir, { recursive: true, force: true });
12
+ }
13
+ console.log('✅ InstaTunnel CLI uninstalled successfully!');
14
+ } catch (error) {
15
+ console.warn('⚠️ Some cleanup may be incomplete:', error.message);
16
+ }
17
+ }
18
+
19
+ if (require.main === module) {
20
+ cleanup();
21
+ }
22
+
23
+ module.exports = { cleanup };