Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
Hetzner-Master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Hetzner-Master
Commits
d94fa2a7
Commit
d94fa2a7
authored
Apr 15, 2020
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
e1030f75
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
1 deletion
+44
-1
app.js
app.js
+44
-1
No files found.
app.js
View file @
d94fa2a7
...
@@ -14,6 +14,7 @@ const shellExec = require('shell-exec')
...
@@ -14,6 +14,7 @@ const shellExec = require('shell-exec')
let
Hetzner
=
require
(
'
./Hetzner
'
)
let
Hetzner
=
require
(
'
./Hetzner
'
)
let
constant
=
require
(
'
./constant
'
)
let
constant
=
require
(
'
./constant
'
)
let
masterId
=
0
let
masterId
=
0
let
id
=
0
let
het
let
het
...
@@ -56,6 +57,11 @@ app.get('/test', (req, res) => {
...
@@ -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
)
{
async
function
newServerOrder
(
req
,
res
)
{
let
order
=
parseInt
(
req
.
params
.
num
)
let
order
=
parseInt
(
req
.
params
.
num
)
...
@@ -134,7 +140,7 @@ init()
...
@@ -134,7 +140,7 @@ init()
async
function
init
()
{
async
function
init
()
{
await
initToken
()
await
initToken
()
add
Master
()
post
Master
()
postRequest
()
postRequest
()
attacher
()
attacher
()
// checkServers()
// checkServers()
...
@@ -220,6 +226,7 @@ async function checkIps(ip) {
...
@@ -220,6 +226,7 @@ async function checkIps(ip) {
async
function
initToken
()
{
async
function
initToken
()
{
var
contents
=
await
fs
.
readFileSync
(
'
./token.txt
'
,
'
utf8
'
);
var
contents
=
await
fs
.
readFileSync
(
'
./token.txt
'
,
'
utf8
'
);
het
=
new
Hetzner
(
contents
)
het
=
new
Hetzner
(
contents
)
id
=
await
fs
.
readFileSync
(
'
./id.txt
'
,
'
utf8
'
);
masterId
=
await
het
.
getMasterServerId
()
masterId
=
await
het
.
getMasterServerId
()
// remover()
// remover()
...
@@ -253,6 +260,15 @@ async function newFloatingIpsOrder(req, res) {
...
@@ -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
()
{
async
function
attacher
()
{
...
@@ -411,6 +427,33 @@ function addMaster() {
...
@@ -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
()
{
function
postRequest
()
{
let
data
=
{
generation
:
generation
,
groups
:
groups
}
let
data
=
{
generation
:
generation
,
groups
:
groups
}
data
=
JSON
.
stringify
(
data
)
data
=
JSON
.
stringify
(
data
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment