Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Ovh-NewGeneration
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
Ovh-NewGeneration
Commits
dbe6f6e5
Commit
dbe6f6e5
authored
Feb 04, 2020
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
cde34922
Pipeline
#46
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
72 deletions
+5
-72
app.js
app.js
+5
-72
No files found.
app.js
View file @
dbe6f6e5
...
...
@@ -30,16 +30,9 @@ app.get('/test', (req, res) => {
})
async
function
addNewIp
(
req
,
res
)
{
res
.
send
(
'
Hello World!
'
)
console
.
log
(
req
.
params
.
ip
)
addBaship
(
req
.
params
.
ip
)
}
async
function
addBaship
(
ip
)
{
return
await
shell
.
exec
(
'
ip addr add
'
+
ip
+
'
dev eth0
'
).
stderr
;
}
app
.
listen
(
port
,
()
=>
console
.
log
(
`Example app listening on port
${
port
}
!`
))
...
...
@@ -65,95 +58,35 @@ cron.schedule('*/10 * * * * *', () => {
postRequest
()
cronRemover
.
schedule
(
'
*/1 * * * *
'
,
()
=>
{
remover
()
postRequest
()
});
async
function
remover
()
{
let
work
=
await
getWork
()
if
(
work
===
'
false
'
)
{
let
ip
=
await
getIp
()
console
.
log
(
ip
)
var
contents
=
await
fs
.
readFileSync
(
'
./token.txt
'
,
'
utf8
'
);
let
Hetzner
=
require
(
'
./Hetzner
'
)
let
het
=
new
Hetzner
(
contents
)
await
het
.
removeByIp
(
ip
)
}
return
true
}
function
getWork
()
{
const
request
=
require
(
'
request
'
);
let
url
=
'
http://admin.fcfglobal.co:3000/work/
'
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/
'
return
new
Promise
(
function
(
resolve
,
reject
)
{
request
(
url
,
{
timeout
:
15000
},
function
(
error
,
res
,
body
)
{
resolve
(
body
)
});
});
}
function
postRequest
()
{
function
getIp
()
{
const
request
=
require
(
'
request
'
);
let
url
=
'
http://admin.fcfglobal.co:3000/
get
Ip/
'
let
url
=
'
http://admin.fcfglobal.co:3000/
addOvh
Ip/
'
return
new
Promise
(
function
(
resolve
,
reject
)
{
request
(
url
,
{
timeout
:
15000
},
function
(
error
,
res
,
body
)
{
resolve
(
body
)
});
});
}
function
postRequest
()
{
let
data
=
{
generation
:
generation
,
groups
:
groups
}
data
=
JSON
.
stringify
(
data
)
data
=
cryptLib
.
encryptPlainTextWithRandomIV
(
data
,
key
)
var
options
=
{
method
:
'
POST
'
,
url
:
'
http://admin.fcfglobal.co:3000/addIp
'
,
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
)
});
});
}
async
function
calculateSpeed
()
{
let
d
=
await
shellExec
(
'
vnstat -tr
'
)
let
d
=
await
shellExec
(
'
vnstat -
i ens3 -
tr
'
)
d
=
d
.
stdout
d
=
d
.
match
(
decimalPointRegex
)
...
...
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