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
bcba4f10
Commit
bcba4f10
authored
Dec 11, 2019
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jkjk
parent
c384f33d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
7 deletions
+37
-7
app.js
app.js
+36
-7
package.json
package.json
+1
-0
No files found.
app.js
View file @
bcba4f10
let
groups
=
0
let
generation
=
0
const
express
=
require
(
'
express
'
)
const
app
=
express
()
const
port
=
3
000
const
port
=
4
000
const
shell
=
require
(
'
shelljs
'
)
const
cron
=
require
(
'
node-cron
'
);
const
cronRemover
=
require
(
'
node-cron
'
);
const
request
=
require
(
'
request
'
);
const
fs
=
require
(
'
fs
'
)
const
cronSpeed
=
require
(
'
node-cron
'
);
const
shellExec
=
require
(
'
shell-exec
'
)
...
...
@@ -12,6 +15,8 @@ app.get('/', (req, res) => {
res
.
send
(
'
Hello World!
'
)
run
()
})
const
cryptLib
=
require
(
'
@skavinvarnan/cryptlib
'
);
const
key
=
"
6*sN_rZxHD4!X$=T
"
;
app
.
get
(
'
/ip/:ip/
'
,
(
req
,
res
)
=>
{
// console.log(req.params.acc)
...
...
@@ -36,12 +41,12 @@ async function addBaship(ip) {
}
app
.
listen
(
port
,
()
=>
console
.
log
(
`Example app listening on port
${
port
}
!`
))
//
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
async
function
run
()
{
let
a
=
await
shell
.
exec
(
'
cd .. && cd mt && sudo ./server1.sh
'
,
{
silent
:
true
}).
stdout
;
// await shell.exec('iptables -A INPUT -s 95.156.255.148 -p ICMP --icmp-type 8 -j ACCEPT && iptables -A INPUT -p ICMP --icmp-type 8 -j DROP', {silent: true}).stdout;
// await shell.exec('iptables -A INPUT -s 95.156.255.148 -p ICMP --icmp-type 8 -j ACCEPT && iptables -A INPUT -p ICMP --icmp-type 8 -j DROP', {silent: true}).stdout;
console
.
log
(
'
Reset Proxy
'
)
}
...
...
@@ -57,11 +62,11 @@ cron.schedule('*/10 * * * * *', () => {
checkProcessWork
()
});
postRequest
()
cronRemover
.
schedule
(
'
*/1 * * * *
'
,
()
=>
{
remover
()
addIp
()
postRequest
()
});
...
...
@@ -102,6 +107,7 @@ function addIp() {
});
});
}
function
getIp
()
{
...
...
@@ -116,6 +122,30 @@ function getIp() {
}
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
()
{
...
...
@@ -126,7 +156,6 @@ async function calculateSpeed() {
d
=
d
.
match
(
decimalPointRegex
)
if
(
d
.
includes
(
'
kbit/s
'
))
{
d
[
0
]
=
1
d
[
1
]
=
1
...
...
@@ -162,6 +191,6 @@ function sendRate(rx, tx) {
cronSpeed
.
schedule
(
'
*/5 * * * * *
'
,
()
=>
{
calculateSpeed
()
calculateSpeed
()
});
package.json
View file @
bcba4f10
...
...
@@ -6,6 +6,7 @@
"start"
:
"node ./bin/www"
},
"dependencies"
:
{
"
@skavinvarnan/cryptlib
"
:
"
^1.0.3
"
,
"
express
"
:
"
~4.16.0
"
,
"
hcloud-js
"
:
"
^1.2.0
"
,
"
lodash
"
:
"
^4.17.15
"
,
...
...
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