Commit 14f0af92 authored by fionera's avatar fionera

Added Codelines from the Shell

parent 8e041efb
......@@ -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");
}
};
\ No newline at end of file
};
......@@ -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", "*");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment