Skip to content

Commit a617cda

Browse files
committed
fixing issue from disable secret
1 parent a769a45 commit a617cda

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

routes/v1/ppp/ppp_interface_remove/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ const {
88
router.post('/interface_remove', (req, res) => {
99

1010
let host_params = {
11-
host: req.body.host_string.host,
12-
user: req.body.host_string.user,
13-
password: req.body.host_string.password,
14-
port: req.body.host_string.port || 8728
11+
host: req.body?.host_string?.host,
12+
user: req.body?.host_string?.user,
13+
password: req.body?.host_string?.password,
14+
port: req.body?.host_string?.port || 8728
1515
}
1616
const name = req.body.name
1717

routes/v1/ppp/ppp_secret_disable/index.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,43 @@ const {
88
router.post('/secret_disable', (req, res) => {
99

1010
let host_params = {
11-
host: req.body.host_string.host,
12-
user: req.body.host_string.user,
13-
password: req.body.host_string.password,
14-
port: req.body.host_string.port || 8728
11+
host: req?.body?.host_string?.host,
12+
user: req?.body?.host_string?.user,
13+
password: req?.body?.host_string?.password,
14+
port: req?.body?.host_string.port || 8728
1515
}
1616
const name = req.body.name
1717

1818
try {
1919
const script = '/ppp/secret/disable';
2020
const remove = `=numbers=${name}`;
2121
const peramitter = [remove]
22+
23+
// Interface Removed
24+
const script_interface = '/interface/pppoe-server/remove';
25+
const remove_interface = `=numbers=<pppoe-${name}>`;
26+
const peramitter_interface = [remove_interface]
2227

2328
with_params({
2429
script,
2530
peramitter,
2631
host_params
27-
}).then(retn => {
32+
}).then(async retn => {
2833
console.log("log: ppp secret disable")
2934
retn = Array.isArray(retn) ? retn : [retn]
35+
36+
// Remove Interface
37+
try {
38+
await with_params({
39+
script: script_interface,
40+
peramitter: peramitter_interface,
41+
host_params
42+
})
43+
console.log("log: ppp interface remove")
44+
} catch (error) {
45+
console.log("failed: Interface Not Removed")
46+
}
47+
3048
res.json({
3149
success: true,
3250
message: "done",

utils/mikrotik_cmd.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const connection = require('../function/connection');
1010
*/
1111

1212

13-
const with_params = ({
13+
const with_params = async ({
1414
script,
1515
peramitter = [],
1616
host_params =
@@ -40,24 +40,24 @@ const with_params = ({
4040
resolve(data)
4141
}).catch((err) => {
4242
conn.close();
43-
console.log("with_params -> Server Error")
43+
console.log("with_params -> Server Exec Error")
4444
resolve([])
4545
});
4646
})
4747
.catch(err => {
4848
conn.close();
49-
console.log("with_params -> Server Error")
49+
console.log("with_params -> Server Connect Error")
5050
resolve([])
5151
})
5252
} catch (e) {
53-
console.log("with_params -> catch -> Server Error")
53+
console.log("with_params -> catch -> Server Catch Error")
5454
resolve([])
5555
}
5656
})
5757
}
5858

5959

60-
const without_params = ({
60+
const without_params = async ({
6161
script,
6262
host_params =
6363
{
@@ -84,16 +84,16 @@ const without_params = ({
8484
resolver(get)
8585
}).catch((err) => {
8686
conn.close();
87-
console.log("without_params -> Server Error")
87+
console.log("without_params -> Server Exec Error")
8888
resolver([])
8989
});
9090
}).catch(err => {
9191
conn.close();
92-
console.log("without_params -> Server Error")
92+
console.log("without_params -> Server Connect Error")
9393
resolver([])
9494
})
9595
} catch (e) {
96-
console.log("without_params -> catch -> Server Error")
96+
console.log("without_params -> catch -> Server Catch Error")
9797
resolver([])
9898
}
9999
})

0 commit comments

Comments
 (0)