-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp.js
More file actions
99 lines (85 loc) · 2.12 KB
/
Copy pathhttp.js
File metadata and controls
99 lines (85 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// HTTP
function httpCfgUpd(j) {
let i = 0;
try {
cS("httpEn", j.Enable);
cS("httpIPv4", j.EnIPv4);
cS("httpIPv6", j.EnIPv6);
vS("httpPort", j.Port);
if (j.AuthMode == "Srv")
i = 1;
siS("httpAuth", i);
if (j.CertId != 255) {
vS("httpCrtId", j.CertId);
cS("httpCrtEn", true);
}
if (j.CaId != 255) {
vS("httpCaId", j.CaId);
cS("httpCaEn", true);
}
if (j.PkId != 255) {
vS("httpPkId", j.PkId);
cS("httpPkEn", true);
}
} catch(e) {
console.log(e);
}
}
async function httpCfgGet() {
let rq = {Cmd:"HttpCfgGet", SessionId:sIdG()};
return await rqp(rq, httpCfgUpd);
}
async function httpCfgSet() {
let rq = {Cmd:"HttpCfgSet", SessionId:sIdG(),
Port:vG("httpPort"),
Enable:cG("httpEn"),
EnIPv4:cG("httpIPv4"),
EnIPv6:cG("httpIPv6")};
if (siG("httpAuth") == 1)
rq["AuthMode"] = "Srv";
else
rq["AuthMode"] = "Disable";
if (cG("httpCrtEn") == true)
rq["CertId"] = vG("httpCrtId");
else
rq["CertId"] = 255;
if (cG("httpCaEn") == true)
rq["CaId"] = vG("httpCaId");
else
rq["CaId"] = 255;
if (cG("httpPkEn") == true)
rq["PkId"] = vG("httpPkId");
else
rq["PkId"] = 255;
return await rqp(rq, null);
}
function httpStateUpd(j) {
try {
hS("httpStSvc", j.SvcState);
hS("httpStMod", j.ModState);
hS("httpStRst", j.Reset);
} catch(e) {
console.log(e);
}
}
async function httpStateGet() {
let rq = {Cmd:"HttpStateGet", SessionId:sIdG()};
return await rqp(rq, httpStateUpd);
}
async function httpInit() {
btnEvAdd("httpBtCfg", async() => {
await httpCfgSet().then(() => {
}).catch((m) => {
alert(m);
})
});
return new Promise(async(res, rej) => {
await httpStateGet()
.then(async() => {await httpCfgGet()})
.then(() => {
res();
}).catch((m) => {
rej(m);
})
});
}