-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpn.js
60 lines (46 loc) · 1.48 KB
/
vpn.js
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
//*********************************************//
//** INSERT SERVER IP AND CREDENTIALS HERE BEFORE EXECUTING SCRIPT **//
var server = "<INSERT ASA LOCAL IP ADDRESS>";
var username = "<INSERT USERNAME>";
var password = "<INSERT PASSWORD>";
//*********************************************//
var https = require('https');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var data = {};
var api_path = "/api/cli"; // param
var data = {
"commands": [
// REMOVE COMMENTS BELOW FOR THE SPECIFIC COMMAND YOU WANT TO RUN
// SHOW ALL VPN SESSIONS
"show vpn-sessiondb anyconnect | inc name|IP|Group|Time|Duration"
// LOGOFF SESSION FOR SINGLE USER
//"vpn-sessiondb logoff name chance.whittaker noconfirm"
// LOGOFF SESSION FOR ALL USERS
//"vpn-sessiondb logoff all noconfirm"
]
};
var dataString = JSON.stringify(data);
var options = {
host: server,
path: api_path,
method:"POST",
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic ' + new Buffer(username + ':' + password).toString('base64'),
'Content-Length': dataString.length,
'User-Agent': 'REST API Agent'
}
}
var req = https.request(options, function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(d) {
process.stdout.write(d);
//console.log(d)
});
});
req.write(dataString);
req.end();
req.on('error', function(e) {
console.error(e);
});