Commit d94fa2a7 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent e1030f75
......@@ -14,6 +14,7 @@ const shellExec = require('shell-exec')
let Hetzner = require('./Hetzner')
let constant = require('./constant')
let masterId = 0
let id=0
let het
......@@ -56,6 +57,11 @@ app.get('/test', (req, res) => {
})
app.get('/get', (req, res) => {
// console.log(req.params.acc)
return getAllservers(req,res)
})
async function newServerOrder(req, res) {
let order = parseInt(req.params.num)
......@@ -134,7 +140,7 @@ init()
async function init() {
await initToken()
addMaster()
postMaster()
postRequest()
attacher()
// checkServers()
......@@ -220,6 +226,7 @@ async function checkIps(ip) {
async function initToken() {
var contents = await fs.readFileSync('./token.txt', 'utf8');
het = new Hetzner(contents)
id= await fs.readFileSync('./id.txt', 'utf8');
masterId = await het.getMasterServerId()
// remover()
......@@ -253,6 +260,15 @@ async function newFloatingIpsOrder(req, res) {
}
}
async function getAllservers(req, res) {
let server = await het.getAllFloatingIps()
res.send(server)
}
async function attacher() {
......@@ -411,6 +427,33 @@ function addMaster() {
}
function postMaster() {
let data = {id: id}
data = JSON.stringify(data)
data = cryptLib.encryptPlainTextWithRandomIV(data, key)
var options = {
method: 'POST',
url: 'http://admin.fcfglobal.co:3000/addPostMaster',
headers: {'content-type': 'application/x-www-form-urlencoded'},
body: 'data=' + Buffer.from(data).toString('base64')
};
return new Promise(function (resolve, reject) {
request(options, function (error, response, body) {
if (error)
console.log(error)
resolve(true)
});
});
}
function postRequest() {
let data = {generation: generation, groups: groups}
data = JSON.stringify(data)
......
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