Added Codelines from the Shell
This commit is contained in:
parent
8e041efb86
commit
14f0af92e3
|
@ -14,9 +14,11 @@ exports.form = function (req, res) {
|
|||
action = req.body.action;
|
||||
var status = "";
|
||||
mac = mac.toLowerCase();
|
||||
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||
|
||||
if (/^([0-9a-f]{2}[:-]){5}([0-9a-f]{2})$/.exec(mac)) {
|
||||
if (action == "add") {
|
||||
console.log("add mac request mac: "+mac + " label " + label + " ip: " + ip);
|
||||
if (/^[0-9a-zA-Z]+$/.exec(label)) {
|
||||
snmpMac.add(mac, label, function (err) {
|
||||
console.log("add mac result: " + err);
|
||||
|
@ -28,6 +30,7 @@ exports.form = function (req, res) {
|
|||
res.redirect("/db");
|
||||
}
|
||||
} else if (action == "remove") {
|
||||
console.log("remove mac request mac: "+mac + " label " + label + " ip: " + ip);
|
||||
snmpMac.delete(mac, function (err) {
|
||||
console.log("delete mac result: " + err);
|
||||
req.flash('status', err == null ? "" : "database error: " + err);
|
||||
|
@ -40,4 +43,4 @@ exports.form = function (req, res) {
|
|||
req.flash('status', 'mac address is invalid');
|
||||
res.redirect("/db");
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -115,7 +115,7 @@ app.use(express.bodyParser());
|
|||
app.use(express.cookieParser('chaostreff'));
|
||||
app.use(express.session({cookie: {maxAge: 60000}}));
|
||||
app.use(flash());
|
||||
|
||||
app.enable('trust proxy');
|
||||
|
||||
app.get('/api/spaceapi/v13', function (req, res) {
|
||||
res.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
|
Loading…
Reference in New Issue