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
76b7dd44
Commit
76b7dd44
authored
Dec 21, 2019
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
6d03d0aa
Pipeline
#24
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
4 deletions
+52
-4
app.js
app.js
+52
-4
No files found.
app.js
View file @
76b7dd44
...
...
@@ -35,13 +35,18 @@ app.get('/add/:num/', (req, res) => {
})
app
.
get
(
'
/
test
'
,
(
req
,
res
)
=>
{
app
.
get
(
'
/
add/
'
,
(
req
,
res
)
=>
{
// console.log(req.params.acc)
res
.
sendfile
(
'
jetmtp.png
'
)
res
.
send
(
'
Done
'
)
het
.
removeAllFloatingIps
()
})
app
.
get
(
'
/test
'
,
(
req
,
res
)
=>
{
// console.log(req.params.acc)
res
.
sendfile
(
'
jetmtp.png
'
)
})
async
function
newFloatingIpsOrder
(
req
,
res
)
{
...
...
@@ -54,7 +59,7 @@ async function newFloatingIpsOrder(req, res) {
let
floatNum
=
10
-
ips
.
length
let
location
=
order
===
1
?
constant
.
nuremberg
:
constant
.
falkenstein
let
newIps
=
[]
let
newIps
=
[]
for
(
let
i
=
1
;
i
<=
floatNum
;
i
++
)
{
...
...
@@ -69,7 +74,7 @@ async function newFloatingIpsOrder(req, res) {
}
async
function
addBaship
(
ip
)
{
return
shell
.
exec
(
'
ip addr add
'
+
ip
+
'
dev eth0
'
).
stderr
;
return
shell
.
exec
(
'
ip addr add
'
+
ip
+
'
dev eth0
'
).
stderr
;
}
...
...
@@ -103,6 +108,36 @@ cronRemover.schedule(' */1 * * * *', () => {
async
function
init
()
{
await
initToken
()
postRequest
()
checkIps
()
}
async
function
checkIps
()
{
let
ips
=
await
het
.
getAllFloatingIps
()
for
(
let
i
=
0
;
i
<
ips
.
length
;
i
++
)
{
let
status
=
await
getWorkFloating
(
ips
[
i
].
ip
)
status
=
parseInt
(
status
)
switch
(
status
)
{
case
404
:
await
postFloatingIps
([
ips
[
i
].
ip
])
break
case
400
:
await
postFloatingIps
([
ips
[
i
].
ip
])
break
case
0
:
await
het
.
delFloatingIp
(
ips
[
i
].
id
)
break
case
1
:
break
}
if
(
ip
===
ips
[
i
].
ip
)
{
await
this
.
delFloatingIp
(
ips
[
i
].
id
)
}
}
}
async
function
initToken
()
{
...
...
@@ -169,6 +204,19 @@ function getWork() {
}
function
getWorkFloating
(
ip
)
{
const
request
=
require
(
'
request
'
);
let
url
=
'
http://admin.fcfglobal.co:3000/getIpDetail/
'
+
ip
return
new
Promise
(
function
(
resolve
,
reject
)
{
request
(
url
,
{
timeout
:
15000
},
function
(
error
,
res
,
body
)
{
resolve
(
body
)
});
});
}
function
addIp
()
{
const
request
=
require
(
'
request
'
);
let
url
=
'
http://admin.fcfglobal.co:3000/add/
'
...
...
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