@edgible-team/cli 1.0.1
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/LICENSE +136 -0
- package/README.md +450 -0
- package/dist/client/api-client.js +1057 -0
- package/dist/client/index.js +21 -0
- package/dist/commands/agent.js +1280 -0
- package/dist/commands/ai.js +608 -0
- package/dist/commands/application.js +885 -0
- package/dist/commands/auth.js +570 -0
- package/dist/commands/base/BaseCommand.js +93 -0
- package/dist/commands/base/CommandHandler.js +7 -0
- package/dist/commands/base/command-wrapper.js +58 -0
- package/dist/commands/base/middleware.js +77 -0
- package/dist/commands/config.js +116 -0
- package/dist/commands/connectivity.js +59 -0
- package/dist/commands/debug.js +98 -0
- package/dist/commands/discover.js +144 -0
- package/dist/commands/examples/migrated-command-example.js +180 -0
- package/dist/commands/gateway.js +494 -0
- package/dist/commands/managedGateway.js +787 -0
- package/dist/commands/utils/config-validator.js +76 -0
- package/dist/commands/utils/gateway-prompt.js +79 -0
- package/dist/commands/utils/input-parser.js +120 -0
- package/dist/commands/utils/output-formatter.js +109 -0
- package/dist/config/app-config.js +99 -0
- package/dist/detection/SystemCapabilityDetector.js +1244 -0
- package/dist/detection/ToolDetector.js +305 -0
- package/dist/detection/WorkloadDetector.js +314 -0
- package/dist/di/bindings.js +99 -0
- package/dist/di/container.js +88 -0
- package/dist/di/types.js +32 -0
- package/dist/index.js +52 -0
- package/dist/interfaces/IDaemonManager.js +3 -0
- package/dist/repositories/config-repository.js +62 -0
- package/dist/repositories/gateway-repository.js +35 -0
- package/dist/scripts/postinstall.js +101 -0
- package/dist/services/AgentStatusManager.js +299 -0
- package/dist/services/ConnectivityTester.js +271 -0
- package/dist/services/DependencyInstaller.js +475 -0
- package/dist/services/LocalAgentManager.js +2216 -0
- package/dist/services/application/ApplicationService.js +299 -0
- package/dist/services/auth/AuthService.js +214 -0
- package/dist/services/aws.js +644 -0
- package/dist/services/daemon/DaemonManagerFactory.js +65 -0
- package/dist/services/daemon/DockerDaemonManager.js +395 -0
- package/dist/services/daemon/LaunchdDaemonManager.js +257 -0
- package/dist/services/daemon/PodmanDaemonManager.js +369 -0
- package/dist/services/daemon/SystemdDaemonManager.js +221 -0
- package/dist/services/daemon/WindowsServiceDaemonManager.js +210 -0
- package/dist/services/daemon/index.js +16 -0
- package/dist/services/edgible.js +3060 -0
- package/dist/services/gateway/GatewayService.js +334 -0
- package/dist/state/config.js +146 -0
- package/dist/types/AgentConfig.js +5 -0
- package/dist/types/AgentStatus.js +5 -0
- package/dist/types/ApiClient.js +5 -0
- package/dist/types/ApiRequests.js +5 -0
- package/dist/types/ApiResponses.js +5 -0
- package/dist/types/Application.js +5 -0
- package/dist/types/CaddyJson.js +5 -0
- package/dist/types/UnifiedAgentStatus.js +56 -0
- package/dist/types/WireGuard.js +5 -0
- package/dist/types/Workload.js +5 -0
- package/dist/types/agent.js +5 -0
- package/dist/types/command-options.js +5 -0
- package/dist/types/connectivity.js +5 -0
- package/dist/types/errors.js +250 -0
- package/dist/types/gateway-types.js +5 -0
- package/dist/types/index.js +48 -0
- package/dist/types/models/ApplicationData.js +5 -0
- package/dist/types/models/CertificateData.js +5 -0
- package/dist/types/models/DeviceData.js +5 -0
- package/dist/types/models/DevicePoolData.js +5 -0
- package/dist/types/models/OrganizationData.js +5 -0
- package/dist/types/models/OrganizationInviteData.js +5 -0
- package/dist/types/models/ProviderConfiguration.js +5 -0
- package/dist/types/models/ResourceData.js +5 -0
- package/dist/types/models/ServiceResourceData.js +5 -0
- package/dist/types/models/UserData.js +5 -0
- package/dist/types/route.js +5 -0
- package/dist/types/validation/schemas.js +218 -0
- package/dist/types/validation.js +5 -0
- package/dist/utils/FileIntegrityManager.js +256 -0
- package/dist/utils/PathMigration.js +219 -0
- package/dist/utils/PathResolver.js +235 -0
- package/dist/utils/PlatformDetector.js +277 -0
- package/dist/utils/console-logger.js +130 -0
- package/dist/utils/docker-compose-parser.js +179 -0
- package/dist/utils/errors.js +130 -0
- package/dist/utils/health-checker.js +155 -0
- package/dist/utils/json-logger.js +72 -0
- package/dist/utils/log-formatter.js +293 -0
- package/dist/utils/logger.js +59 -0
- package/dist/utils/network-utils.js +217 -0
- package/dist/utils/output.js +182 -0
- package/dist/utils/passwordValidation.js +91 -0
- package/dist/utils/progress.js +167 -0
- package/dist/utils/sudo-checker.js +22 -0
- package/dist/utils/urls.js +32 -0
- package/dist/utils/validation.js +31 -0
- package/dist/validation/schemas.js +175 -0
- package/dist/validation/validator.js +67 -0
- package/package.json +83 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.DependencyInstaller = void 0;
|
|
40
|
+
const child_process_1 = require("child_process");
|
|
41
|
+
const os = __importStar(require("os"));
|
|
42
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
43
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
44
|
+
class DependencyInstaller {
|
|
45
|
+
/**
|
|
46
|
+
* Get the original user when running under sudo
|
|
47
|
+
* @returns The SUDO_USER if running as root via sudo, otherwise undefined
|
|
48
|
+
*/
|
|
49
|
+
getSudoUser() {
|
|
50
|
+
const uid = process.getuid ? process.getuid() : undefined;
|
|
51
|
+
const sudoUser = process.env['SUDO_USER'];
|
|
52
|
+
// Only return SUDO_USER if we're actually running as root (uid 0)
|
|
53
|
+
if (uid === 0 && sudoUser) {
|
|
54
|
+
return sudoUser;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Execute a command, running as the original user if executed via sudo
|
|
60
|
+
* This is particularly important for Homebrew, which refuses to run as root
|
|
61
|
+
* @param command The command to execute
|
|
62
|
+
* @returns The stdout from execSync
|
|
63
|
+
*/
|
|
64
|
+
execAsRealUser(command) {
|
|
65
|
+
const sudoUser = this.getSudoUser();
|
|
66
|
+
if (sudoUser) {
|
|
67
|
+
// Running under sudo - execute as the original user
|
|
68
|
+
// Use 'sudo -u' to run the command as the original user
|
|
69
|
+
// Pass through the HOME environment variable to ensure Homebrew works correctly
|
|
70
|
+
const wrappedCommand = `sudo -u ${sudoUser} HOME=$(eval echo ~${sudoUser}) ${command}`;
|
|
71
|
+
return (0, child_process_1.execSync)(wrappedCommand);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// Not running under sudo - execute normally
|
|
75
|
+
return (0, child_process_1.execSync)(command);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async checkAndInstallDependencies(options = {}) {
|
|
79
|
+
console.log('Checking dependencies...');
|
|
80
|
+
const sudoUser = this.getSudoUser();
|
|
81
|
+
if (sudoUser) {
|
|
82
|
+
console.log(chalk_1.default.gray(`Running under sudo - package manager commands will execute as user: ${sudoUser}`));
|
|
83
|
+
}
|
|
84
|
+
const platform = os.platform();
|
|
85
|
+
const packageManager = await this.detectPackageManager(platform);
|
|
86
|
+
const dependencies = [
|
|
87
|
+
{ name: 'WireGuard', check: this.isWireGuardInstalled.bind(this), install: this.installWireGuard.bind(this) },
|
|
88
|
+
{ name: 'Caddy', check: this.isCaddyInstalled.bind(this), install: this.installCaddy.bind(this) },
|
|
89
|
+
{ name: 'HAProxy', check: this.isHAProxyInstalled.bind(this), install: this.installHAProxy.bind(this) },
|
|
90
|
+
];
|
|
91
|
+
if (options.includeIptables) {
|
|
92
|
+
dependencies.push({ name: 'iptables', check: this.isIptablesInstalled.bind(this), install: this.installIptables.bind(this) });
|
|
93
|
+
}
|
|
94
|
+
if (options.includeWireGuardGo) {
|
|
95
|
+
dependencies.push({ name: 'wireguard-go', check: this.isWireGuardGoInstalled.bind(this), install: this.installWireGuardGo.bind(this) });
|
|
96
|
+
}
|
|
97
|
+
for (const dep of dependencies) {
|
|
98
|
+
if (!(await dep.check(platform))) {
|
|
99
|
+
let install = false;
|
|
100
|
+
if (options.autoInstall) {
|
|
101
|
+
install = true;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
install = await this.promptForInstallation(dep.name);
|
|
105
|
+
}
|
|
106
|
+
if (install) {
|
|
107
|
+
console.log(chalk_1.default.yellow(`${dep.name} is not installed. Attempting to install...`));
|
|
108
|
+
await dep.install(platform, packageManager);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
console.log(chalk_1.default.green(`✓ ${dep.name} is already installed.`));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async promptForInstallation(dependencyName) {
|
|
117
|
+
const { install } = await inquirer_1.default.prompt([
|
|
118
|
+
{
|
|
119
|
+
type: 'confirm',
|
|
120
|
+
name: 'install',
|
|
121
|
+
message: `Would you like to install ${dependencyName}?`,
|
|
122
|
+
default: true,
|
|
123
|
+
},
|
|
124
|
+
]);
|
|
125
|
+
return install;
|
|
126
|
+
}
|
|
127
|
+
async detectPackageManager(platform) {
|
|
128
|
+
if (platform === 'darwin') {
|
|
129
|
+
try {
|
|
130
|
+
this.execAsRealUser('which brew');
|
|
131
|
+
return 'brew';
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
return 'unknown';
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (platform === 'linux') {
|
|
138
|
+
try {
|
|
139
|
+
(0, child_process_1.execSync)('which apt-get');
|
|
140
|
+
return 'apt-get';
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
// apt-get not found, check for dnf
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
(0, child_process_1.execSync)('which dnf');
|
|
147
|
+
return 'dnf';
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
// dnf not found, check for yum
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
(0, child_process_1.execSync)('which yum');
|
|
154
|
+
return 'yum';
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
return 'unknown';
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (platform === 'win32') {
|
|
161
|
+
try {
|
|
162
|
+
(0, child_process_1.execSync)('winget --version');
|
|
163
|
+
return 'winget';
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
return 'unknown';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return 'unknown';
|
|
170
|
+
}
|
|
171
|
+
async isWireGuardInstalled(platform) {
|
|
172
|
+
try {
|
|
173
|
+
switch (platform) {
|
|
174
|
+
case 'linux':
|
|
175
|
+
case 'darwin':
|
|
176
|
+
(0, child_process_1.execSync)('which wg');
|
|
177
|
+
return true;
|
|
178
|
+
case 'win32':
|
|
179
|
+
(0, child_process_1.execSync)('where wg');
|
|
180
|
+
return true;
|
|
181
|
+
default:
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
async isCaddyInstalled(platform) {
|
|
190
|
+
try {
|
|
191
|
+
switch (platform) {
|
|
192
|
+
case 'linux':
|
|
193
|
+
case 'darwin':
|
|
194
|
+
(0, child_process_1.execSync)('which caddy');
|
|
195
|
+
return true;
|
|
196
|
+
case 'win32':
|
|
197
|
+
(0, child_process_1.execSync)('where caddy');
|
|
198
|
+
return true;
|
|
199
|
+
default:
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
async installWireGuard(platform, packageManager) {
|
|
208
|
+
console.log(`Installing WireGuard for ${platform} using ${packageManager}...`);
|
|
209
|
+
try {
|
|
210
|
+
switch (platform) {
|
|
211
|
+
case 'linux':
|
|
212
|
+
if (packageManager === 'apt-get') {
|
|
213
|
+
(0, child_process_1.execSync)('sudo apt-get update && sudo apt-get install -y wireguard');
|
|
214
|
+
}
|
|
215
|
+
else if (packageManager === 'dnf') {
|
|
216
|
+
(0, child_process_1.execSync)('sudo dnf install -y wireguard-tools');
|
|
217
|
+
}
|
|
218
|
+
else if (packageManager === 'yum') {
|
|
219
|
+
(0, child_process_1.execSync)('sudo yum install -y elrepo-release epel-release && sudo yum install -y kmod-wireguard wireguard-tools');
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
console.log(chalk_1.default.red('Unsupported package manager for Linux. Please install WireGuard manually.'));
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
case 'darwin':
|
|
226
|
+
if (packageManager === 'brew') {
|
|
227
|
+
this.execAsRealUser('brew install wireguard-tools');
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
console.log(chalk_1.default.red('Homebrew not found. Please install Homebrew and try again, or install WireGuard manually.'));
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
case 'win32':
|
|
234
|
+
if (packageManager === 'winget') {
|
|
235
|
+
(0, child_process_1.execSync)('winget install -e --id WireGuard.WireGuard');
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
console.log(chalk_1.default.red('winget not found. Please install winget and try again, or install WireGuard manually.'));
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
default:
|
|
242
|
+
console.log(chalk_1.default.red(`Unsupported platform: ${platform}`));
|
|
243
|
+
}
|
|
244
|
+
console.log(chalk_1.default.green('WireGuard installed successfully.'));
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
console.error(chalk_1.default.red('Failed to install WireGuard:'), error);
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
async installCaddy(platform, packageManager) {
|
|
252
|
+
console.log(`Installing Caddy for ${platform} using ${packageManager}...`);
|
|
253
|
+
try {
|
|
254
|
+
switch (platform) {
|
|
255
|
+
case 'linux':
|
|
256
|
+
if (packageManager === 'apt-get') {
|
|
257
|
+
(0, child_process_1.execSync)('sudo apt-get update && sudo apt-get install -y caddy');
|
|
258
|
+
}
|
|
259
|
+
else if (packageManager === 'dnf') {
|
|
260
|
+
(0, child_process_1.execSync)('sudo dnf install -y caddy');
|
|
261
|
+
}
|
|
262
|
+
else if (packageManager === 'yum') {
|
|
263
|
+
(0, child_process_1.execSync)('sudo yum install -y caddy');
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
console.log(chalk_1.default.red('Unsupported package manager for Linux. Please install Caddy manually.'));
|
|
267
|
+
}
|
|
268
|
+
break;
|
|
269
|
+
case 'darwin':
|
|
270
|
+
if (packageManager === 'brew') {
|
|
271
|
+
this.execAsRealUser('brew install caddy');
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
console.log(chalk_1.default.red('Homebrew not found. Please install Homebrew and try again, or install Caddy manually.'));
|
|
275
|
+
}
|
|
276
|
+
break;
|
|
277
|
+
case 'win32':
|
|
278
|
+
if (packageManager === 'winget') {
|
|
279
|
+
(0, child_process_1.execSync)('winget install -e --id Caddy.Caddy');
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
console.log(chalk_1.default.red('winget not found. Please install winget and try again, or install Caddy manually.'));
|
|
283
|
+
}
|
|
284
|
+
break;
|
|
285
|
+
default:
|
|
286
|
+
console.log(chalk_1.default.red(`Unsupported platform: ${platform}`));
|
|
287
|
+
}
|
|
288
|
+
console.log(chalk_1.default.green('Caddy installed successfully.'));
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
console.error(chalk_1.default.red('Failed to install Caddy:'), error);
|
|
292
|
+
throw error;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
async isHAProxyInstalled(platform) {
|
|
296
|
+
try {
|
|
297
|
+
switch (platform) {
|
|
298
|
+
case 'linux':
|
|
299
|
+
case 'darwin':
|
|
300
|
+
(0, child_process_1.execSync)('which haproxy');
|
|
301
|
+
return true;
|
|
302
|
+
case 'win32':
|
|
303
|
+
(0, child_process_1.execSync)('where haproxy');
|
|
304
|
+
return true;
|
|
305
|
+
default:
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
async installHAProxy(platform, packageManager) {
|
|
314
|
+
console.log(`Installing HAProxy for ${platform} using ${packageManager}...`);
|
|
315
|
+
try {
|
|
316
|
+
switch (platform) {
|
|
317
|
+
case 'linux':
|
|
318
|
+
if (packageManager === 'apt-get') {
|
|
319
|
+
(0, child_process_1.execSync)('sudo apt-get update && sudo apt-get install -y haproxy');
|
|
320
|
+
}
|
|
321
|
+
else if (packageManager === 'dnf') {
|
|
322
|
+
(0, child_process_1.execSync)('sudo dnf install -y haproxy');
|
|
323
|
+
}
|
|
324
|
+
else if (packageManager === 'yum') {
|
|
325
|
+
(0, child_process_1.execSync)('sudo yum install -y haproxy');
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
console.log(chalk_1.default.red('Unsupported package manager for Linux. Please install HAProxy manually.'));
|
|
329
|
+
}
|
|
330
|
+
break;
|
|
331
|
+
case 'darwin':
|
|
332
|
+
if (packageManager === 'brew') {
|
|
333
|
+
this.execAsRealUser('brew install haproxy');
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
console.log(chalk_1.default.red('Homebrew not found. Please install Homebrew and try again, or install HAProxy manually.'));
|
|
337
|
+
}
|
|
338
|
+
break;
|
|
339
|
+
case 'win32':
|
|
340
|
+
console.log(chalk_1.default.yellow('HAProxy installation on Windows is not supported via this installer. Please install HAProxy manually.'));
|
|
341
|
+
break;
|
|
342
|
+
default:
|
|
343
|
+
console.log(chalk_1.default.red(`Unsupported platform: ${platform}`));
|
|
344
|
+
}
|
|
345
|
+
console.log(chalk_1.default.green('HAProxy installed successfully.'));
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
console.error(chalk_1.default.red('Failed to install HAProxy:'), error);
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
async isWireGuardGoInstalled(platform) {
|
|
353
|
+
try {
|
|
354
|
+
switch (platform) {
|
|
355
|
+
case 'linux':
|
|
356
|
+
case 'darwin':
|
|
357
|
+
(0, child_process_1.execSync)('which wireguard-go');
|
|
358
|
+
return true;
|
|
359
|
+
case 'win32':
|
|
360
|
+
(0, child_process_1.execSync)('where wireguard-go');
|
|
361
|
+
return true;
|
|
362
|
+
default:
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
async installWireGuardGo(platform, packageManager) {
|
|
371
|
+
console.log(`Installing wireguard-go for ${platform} using ${packageManager}...`);
|
|
372
|
+
try {
|
|
373
|
+
switch (platform) {
|
|
374
|
+
case 'linux':
|
|
375
|
+
if (packageManager === 'apt-get') {
|
|
376
|
+
(0, child_process_1.execSync)('sudo apt-get update && sudo apt-get install -y wireguard-go');
|
|
377
|
+
}
|
|
378
|
+
else if (packageManager === 'dnf') {
|
|
379
|
+
(0, child_process_1.execSync)('sudo dnf install -y wireguard-tools');
|
|
380
|
+
// wireguard-go might be in a separate package or need to be built from source
|
|
381
|
+
console.log(chalk_1.default.yellow('Note: wireguard-go may need to be installed from source on some distributions.'));
|
|
382
|
+
console.log(chalk_1.default.yellow('See: https://git.zx2c4.com/wireguard-go/about/'));
|
|
383
|
+
}
|
|
384
|
+
else if (packageManager === 'yum') {
|
|
385
|
+
(0, child_process_1.execSync)('sudo yum install -y wireguard-tools');
|
|
386
|
+
console.log(chalk_1.default.yellow('Note: wireguard-go may need to be installed from source on some distributions.'));
|
|
387
|
+
console.log(chalk_1.default.yellow('See: https://git.zx2c4.com/wireguard-go/about/'));
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
console.log(chalk_1.default.red('Unsupported package manager for Linux. Please install wireguard-go manually.'));
|
|
391
|
+
console.log(chalk_1.default.yellow('See: https://git.zx2c4.com/wireguard-go/about/'));
|
|
392
|
+
}
|
|
393
|
+
break;
|
|
394
|
+
case 'darwin':
|
|
395
|
+
if (packageManager === 'brew') {
|
|
396
|
+
this.execAsRealUser('brew install wireguard-go');
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
console.log(chalk_1.default.red('Homebrew not found. Please install Homebrew and try again, or install wireguard-go manually.'));
|
|
400
|
+
}
|
|
401
|
+
break;
|
|
402
|
+
case 'win32':
|
|
403
|
+
console.log(chalk_1.default.yellow('wireguard-go installation on Windows is not supported via this installer. Please install wireguard-go manually.'));
|
|
404
|
+
break;
|
|
405
|
+
default:
|
|
406
|
+
console.log(chalk_1.default.red(`Unsupported platform: ${platform}`));
|
|
407
|
+
}
|
|
408
|
+
console.log(chalk_1.default.green('wireguard-go installed successfully.'));
|
|
409
|
+
}
|
|
410
|
+
catch (error) {
|
|
411
|
+
console.error(chalk_1.default.red('Failed to install wireguard-go:'), error);
|
|
412
|
+
console.log(chalk_1.default.yellow('You may need to install wireguard-go manually.'));
|
|
413
|
+
console.log(chalk_1.default.yellow('See: https://git.zx2c4.com/wireguard-go/about/'));
|
|
414
|
+
throw error;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
async isIptablesInstalled(platform) {
|
|
418
|
+
try {
|
|
419
|
+
switch (platform) {
|
|
420
|
+
case 'linux':
|
|
421
|
+
(0, child_process_1.execSync)('which iptables');
|
|
422
|
+
return true;
|
|
423
|
+
case 'darwin':
|
|
424
|
+
// macOS uses pfctl, not iptables
|
|
425
|
+
return false;
|
|
426
|
+
case 'win32':
|
|
427
|
+
// Windows doesn't use iptables
|
|
428
|
+
return false;
|
|
429
|
+
default:
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
catch (error) {
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
async installIptables(platform, packageManager) {
|
|
438
|
+
console.log(`Installing iptables for ${platform} using ${packageManager}...`);
|
|
439
|
+
try {
|
|
440
|
+
switch (platform) {
|
|
441
|
+
case 'linux':
|
|
442
|
+
if (packageManager === 'apt-get') {
|
|
443
|
+
(0, child_process_1.execSync)('sudo apt-get update && sudo apt-get install -y iptables');
|
|
444
|
+
}
|
|
445
|
+
else if (packageManager === 'dnf') {
|
|
446
|
+
(0, child_process_1.execSync)('sudo dnf install -y iptables');
|
|
447
|
+
}
|
|
448
|
+
else if (packageManager === 'yum') {
|
|
449
|
+
(0, child_process_1.execSync)('sudo yum install -y iptables');
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
console.log(chalk_1.default.red('Unsupported package manager for Linux. Please install iptables manually.'));
|
|
453
|
+
}
|
|
454
|
+
break;
|
|
455
|
+
case 'darwin':
|
|
456
|
+
console.log(chalk_1.default.yellow('macOS uses pfctl instead of iptables. Firewall management may not work as expected.'));
|
|
457
|
+
break;
|
|
458
|
+
case 'win32':
|
|
459
|
+
console.log(chalk_1.default.yellow('Windows uses Windows Firewall instead of iptables. Firewall management may not work as expected.'));
|
|
460
|
+
break;
|
|
461
|
+
default:
|
|
462
|
+
console.log(chalk_1.default.red(`Unsupported platform: ${platform}`));
|
|
463
|
+
}
|
|
464
|
+
if (platform === 'linux') {
|
|
465
|
+
console.log(chalk_1.default.green('iptables installed successfully.'));
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
catch (error) {
|
|
469
|
+
console.error(chalk_1.default.red('Failed to install iptables:'), error);
|
|
470
|
+
throw error;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
exports.DependencyInstaller = DependencyInstaller;
|
|
475
|
+
//# sourceMappingURL=DependencyInstaller.js.map
|