Ich erstelle snmp Sitzung alles funktioniert wie erwartet, ich werde dynamische Wert von host
zu Sitzung erstellen, ich möchte nur wenn Bedingung, Ip-Adresse zu überprüfen ist richtig oder nicht, gibt es Weg, IP-Adresse in Javascript zu validieren ?Wie überprüfe ich, ob die IP-Adresse korrekt ist?
main.js
var host = "135.01.01.01";
var sessionOptions = {
port: 161,
retries: 1,
timeout: 5000,
transport: "udp4",
trapPort: msg.event.body.trapPort,
version: snmpVersion
};
//Create snmp Session
var session = snmp.createSession(host, "public", sessionOptions);
try {
if (!host) {
console.log("Could not find host");
} else {
session.trap(trapOid, varbinds, options, function(error) {
if (error)
console.log(error);
else
console.log('SNMP successfully delivered');
});
}
} catch (e) {
console.log("SNMP processing error: " + e);
}
Was meinst du mit "richtig"? Wie in, ist es richtig formatiert? –
http://stackoverflow.com/questions/10006459/regular-expression-for-ip-address-validation –