1require('dotenv').config({ path: '../.env' });
2require('dotenv').config();
4const https = require('https');
6const MESHCENTRAL_URL = 'https://rmm-psa-meshcentral-aq48h.ondigitalocean.app';
7const username = process.env.MESHCENTRAL_USERNAME;
8const password = process.env.MESHCENTRAL_PASSWORD;
10// Login and get mesh list
14async function getMeshes() {
15 return new Promise((resolve, reject) => {
17 const loginData = `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`;
20 hostname: 'rmm-psa-meshcentral-aq48h.ondigitalocean.app',
25 'Content-Type': 'application/x-www-form-urlencoded',
26 'Content-Length': loginData.length
28 rejectUnauthorized: false
31 const req = https.request(options, (res) => {
33 if (res.headers['set-cookie']) {
34 cookie = res.headers['set-cookie'][0].split(';')[0];
38 res.on('data', chunk => body += chunk);
40 console.log('Login response:', res.statusCode);
41 console.log('Cookie:', cookie);
43 // Step 2: Get mesh list
45 hostname: 'rmm-psa-meshcentral-aq48h.ondigitalocean.app',
52 rejectUnauthorized: false
55 const meshReq = https.request(meshOptions, (meshRes) => {
57 meshRes.on('data', chunk => meshBody += chunk);
58 meshRes.on('end', () => {
59 console.log('\nMesh list response:', meshRes.statusCode);
60 console.log('Body:', meshBody.substring(0, 500));
65 meshReq.on('error', reject);
70 req.on('error', reject);
76getMeshes().catch(console.error);