断线重连
This commit is contained in:
parent
bc6936def1
commit
f10fe2843e
11
index.ts
11
index.ts
@ -138,8 +138,9 @@ async function connectAPI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getDHCPList(addr: string | null) {
|
async function getDHCPList(addr: string | null) {
|
||||||
const result = await api.write('/ip/dhcp-server/lease/print');
|
|
||||||
list = [];
|
list = [];
|
||||||
|
try {
|
||||||
|
const result = await api.write('/ip/dhcp-server/lease/print');
|
||||||
for (let eq in result) {
|
for (let eq in result) {
|
||||||
let format = {
|
let format = {
|
||||||
id: result[eq]['.id'],
|
id: result[eq]['.id'],
|
||||||
@ -161,6 +162,14 @@ async function getDHCPList(addr: string | null) {
|
|||||||
}
|
}
|
||||||
list.push(format);
|
list.push(format);
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
api = new RouterOSAPI({
|
||||||
|
host: cfg.host,
|
||||||
|
user: cfg.user,
|
||||||
|
password: cfg.password,
|
||||||
|
});
|
||||||
|
api.connect();
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user