Post Syndicated from Anonymous original http://deliantech.blogspot.com/2017/04/unificli-cli-tool-to-manage-ubiquitis.html
npm start connectSSH 00:01:02:03:04:05 -l unifikeylocation
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2017/04/unificli-cli-tool-to-manage-ubiquitis.html
npm start connectSSH 00:01:02:03:04:05 -l unifikeylocation
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2017/03/node-unifiapi-nodejs-api-to-access.html
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2017/01/private-properties-with-javascript.html
The current ES6 standard have classes, but they are essentially a wrapper on top of prototype. So this technique still apply. Additionally with Object.defineProperty you could apply extra protection on top of a property.
There is another approach to the problem. Without prototypes.
function F1() {
if (!this instanceof F1) return; // Protect against global scope polution
var XXX = ‘yyy’; // Private property
this.YYY = ‘xxx’; // Public property
function PrivateMethod() {
return XXX + this.YYY;
}
this.method1 = function() {
return PrivateMethod();
}
}
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2015/10/passport-http-digest-authentication-and.html
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2015/09/embeddedjs-async-reimplementation.html
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2015/08/javascript-private-methods-and-variables.html
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2015/03/nodejs-module-to-access-cisco-ios-xr.html
npm install node-ciscoxml
var cxml = require('node-ciscoxml');
var c = cxml( { ...connect options.. });
var cxml = require('node-ciscoxml');
var c = cxml( {
host: '10.10.1.1',
port: 5000,
username: 'xmlapi',
password: 'xmlpass'
});
var cxml = require('node-ciscoxml');
var c = cxml();
c.connect( {
host: '10.10.1.1',
port: 5000,
username: 'xmlapi',
password: 'xmlpass'
});
var cxml = require('node-ciscoxml');
cxml().connect( {
host: '10.10.1.1',
port: 5000,
username: 'xmlapi',
password: 'xmlpass'
}, function(err) {
if (!err)
console.log('Successful connection');
});
var cxml = require('node-ciscoxml');
cxml({
host: '10.10.1.1',
port: 5000,
username: 'xmlapi',
password: 'xmlpass'
}).connect(function(err) {
if (!err)
console.log('Successful connection');
});
var cxml = require('node-ciscoxml');
var fs = require('fs');
cxml({
host: '10.10.1.1',
port: 38752,
username: 'xmlapi',
password: 'xmlpass',
ssl: {
// These are necessary only if using the client certificate authentication
key: fs.readFileSync('client-key.pem'),
cert: fs.readFileSync('client-cert.pem'),
// This is necessary only if the server uses the self-signed certificate
ca: [ fs.readFileSync('server-cert.pem') ]
}
}).connect(function(err) {
if (!err)
console.log('Successful connection');
});
var cxml = require('node-ciscoxml');
var c = cxml({
host: '10.10.1.1',
port: 5000,
username: 'xmlapi',
password: 'xmlpass'
});
c.sendRaw('<Request><GetDataSpaceInfo/></Request>',function(err,data) {
console.log('Received',err,data);
});
var cxml = require('node-ciscoxml');
var c = cxml({
host: '10.10.1.1',
port: 5000,
username: 'xmlapi',
password: 'xmlpass'
});
c.sendRawObj({ GetDataSpaceInfo: '' },function(err,data) {
console.log('Received',err,data);
});
var cxml = require('node-ciscoxml');
var c = cxml({
host: '10.10.1.1',
port: 5000,
username: 'xmlapi',
password: 'xmlpass'
});
c.sendRawObj({ Get: { Configuration: {} } },function(err,data) {
console.log('Received',err,data);
if ((!err) && data && data.Response.$.IteratorID) {
return c.getNext(data.Response.$.IteratorID,function(err,nextData) {
// .. code to merge data with nextData
});
}
// .. code
});
var cxml = require('node-ciscoxml');
var c = cxml({
host: '10.10.1.1',
port: 5000,
username: 'xmlapi',
password: 'xmlpass'
});
c.sendRequest({ GetDataSpaceInfo: '' },function(err,data) {
console.log('Received',err,data);
});
var cxml = require('node-ciscoxml');
var c = cxml({
host: '10.10.1.1',
port: 5000,
username: 'xmlapi',
password: 'xmlpass'
});
c.requestPath('Get.Configuration.Hostname',function(err,data) {
console.log('Received',err,data);
});
var cxml = require('node-ciscoxml');
var c = cxml({
host: '10.10.1.1',
port: 5000,
username: 'xmlapi',
password: 'xmlpass'
});
c.reqPathPath('Get.Configuration.Hostname',/Hostname/,function(err,data) {
console.log('Received',data[0]);
// The output should be something like
// [ 'Response("MajorVersion"="1","MinorVersion"="0").Get.Configuration.Hostname("MajorVersion"="1","MinorVersion"="0")',
'asr9k-router' ]
});
c.getConfig(function(err,config) {
console.log(err,config);
});
c.cliConfig('username testuser\ngroup operator\n',function(err,data) {
console.log(err,data);
c.commit();
});
c.cliExec('show interfaces',function(err,data) {
console.log(err,data?data.Response.CLI[0].Exec[0]);
});
c.commit(function(err,data) {
console.log(err,data);
});
c.lock(function(err,data) {
console.log(err,data);
});
c.unlock(function(err,data) {
console.log(err,data);
});
xml agent
vrf default
ipv4 access-list SECUREACCESS
!
ipv6 enable
session timeout 10
iteration on size 100000
!
require('debug').enable('ciscoxml');
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2015/03/extjs-short-highlight-of-gridrow-in.html
Ext.ComponentQuery.query(‘#mytableview’).on(‘itemupdate’, function(record, index, node) {
node.className = node.className + ‘ x-grid-item-alt’;
setTimeout(function() {
node.className = node.className.replace(/x-grid-item-alt/, ”);
}, 500);
});
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2015/03/nodejs-module-implementing-eventemitter.html
npm install node-mongotailableevents
var ev = require('node-mongotailableevents');
var e = ev( { ...options ... }, callback );
e.on('event',callback);
e.emit('event',data);
var ev = require('node-mongotailableevents');
var e = ev();
var ev = require('node-mongotailableevents');
var e = ev({
mongoUrl: 'mongodb://127.0.0.1/mydb',
name: 'myEventCollection'
});
var ev = require('node-mongotailableevents');
ev({
mongoUrl: 'mongodb://127.0.0.1/mydb',
name: 'myEventCollection'
}, function(err, e) {
console.log('EventEmitter',e);
});
ev(function(err, e) {
console.log('EventEmitter',e);
});
ev(function(err, e) {
if (err) throw err;
e.on('myevent',function(data) {
console.log('We have received',data);
});
e.emit('myevent','my data');
});
var ev = require('node-mongotailableevents');
ev(function(err, e) {
if (err) throw err;
e.on('myevent',function(data) {
console.log('We have received',data);
});
setInterval(function() {
e.emit('myevent','my data'+parseInt(Math.random()*1000000));
},5000);
});
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2015/03/node-netflowv9-nodejs-module-for.html
My node-netflowv9 library has been updated to version 0.2.5
There are few new things –
var Collector = require('node-netflowv9');
Collector(function(flow) {
console.log(flow);
}).listen(3000);
Collector({port: 3000}).on('data',function(flow) {
console.log(flow);
});
{ header:
{ version: 9,
count: 25,
uptime: 2452864139,
seconds: 1401951592,
sequence: 254138992,
sourceId: 2081 },
rinfo:
{ address: '15.21.21.13',
family: 'IPv4',
port: 29471,
size: 1452 },
packet: Buffer <00 00 00 00 ....>
flow: [
{ in_pkts: 3,
in_bytes: 144,
ipv4_src_addr: '15.23.23.37',
ipv4_dst_addr: '16.16.19.165',
input_snmp: 27,
output_snmp: 16,
last_switched: 2452753808,
first_switched: 2452744429,
l4_src_port: 61538,
l4_dst_port: 62348,
out_as: 0,
in_as: 0,
bgp_ipv4_next_hop: '16.16.1.1',
src_mask: 32,
dst_mask: 24,
protocol: 17,
tcp_flags: 0,
src_tos: 0,
direction: 1,
fw_status: 64,
flow_sampler_id: 2 } } ]
var netflowPktDecoder = require('node-netflowv9').nfPktDecode;
....
console.log(netflowPktDecoder(buffer))
Collector({ port: 5000, cb: function (flow) { console.log(flow) } })
Collector(function (flow) { console.log(flow) }).listen(port)
Collector({ cb: function (flow) { console.log(flow) } }).listen(5000)
Collector({ ipv4num: true, cb: function (flow) { console.log(flow) } }).listen(5000)
Collector({ socketType: 'udp6', cb: function (flow) { console.log(flow) } }).listen(5000)
{ name: 'property-name', compileRule: compileRuleObject }
{
length: 'javascript code as a string that decode this value',
...
}
{
4: 'code used to decode this netflow type with length of 4',
8: 'code used to decode this netflow type with length of 8',
0: 'code used to decode ANY OTHER length'
}
{
0: 'o["$name"] = buf.toString("utf8",$pos,$pos+$len)'
}
Collector({
port: 5000,
nfTypes: {
4444: { // 4444 is the NetFlow Type ID which decoding we want to replace
name: 'my_vendor_type4444', // This will be the property name, that will contain the decoded value, it will be also the value of the $name
compileRule: {
1: "o['$name']=buf.readUInt8($pos);", // This is how we decode type of length 1 to a number
2: "o['$name']=buf.readUInt16BE($pos);", // This is how we decode type of length 2 to a number
3: "o['$name']=buf.readUInt8($pos)*65536+buf.readUInt16BE($pos+1);", // This is how we decode type of length 3 to a number
4: "o['$name']=buf.readUInt32BE($pos);", // This is how we decode type of length 4 to a number
5: "o['$name']=buf.readUInt8($pos)*4294967296+buf.readUInt32BE($pos+1);", // This is how we decode type of length 5 to a number
6: "o['$name']=buf.readUInt16BE($pos)*4294967296+buf.readUInt32BE($pos+2);", // This is how we decode type of length 6 to a number
8: "o['$name']=buf.readUInt32BE($pos)*4294967296+buf.readUInt32BE($pos+4);", // This is how we decode type of length 8 to a number
0: "o['$name']='Unsupported Length of $len'"
}
}
},
cb: function (flow) {
console.log(flow)
}
});
var colObj = Collector(function (flow) {
console.log(flow)
});
colObj.listen(5000);
colObj.nfTypes[6789] = {
name: 'vendor_string',
compileRule: {
0: 'o["$name"] = buf.toString("utf8",$pos,$pos+$len)'
}
}
var colObj = Collector(function (flow) {
console.log(flow)
});
colObj.listen(5000);
colObj.nfTypes[14].name = 'outputInterface';
colObj.nfTypes[10].name = 'inputInterface';
require('debug').enable('NetFlowV9');
var Collector = require('node-netflowv9');
Collector(function(flow) {
console.log(flow);
}).listen(5555);
var Collector = require('node-netflowv9');
Collector(function(flow) { // Collector 1 listening on port 5555
console.log(flow);
}).listen(5555);
Collector(function(flow) { // Collector 2 listening on port 6666
console.log(flow);
}).listen(6666);
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2014/11/node-netflowv9-is-updated-to-support.html
Collector({port: 3000}).on('data',function(flow) {
console.log(flow);
});
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2014/10/sencha-extjs-grid-update-in-real-time.html
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2014/06/fun-with-javascript-inheritance.html
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2014/06/operator-overloading-with-javascript.html
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2014/06/new-improved-version-of-node-netflowv9.html
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2014/06/simple-example-for-nodejs-sflow.html
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2014/06/rtmp-api-for-nodejs-to-ease.html
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2014/06/amf03-encodingdecoding-in-nodejs.html
It is easy to use this module. You just have to do something like this:
var amfUtils = require('node-amfutils');
var buffer = amfUtils.amf0Encode([{ a: "xxx"},b: null]);
Post Syndicated from Anonymous original http://deliantech.blogspot.com/2014/06/sflow-version-5-module-for-nodejs.html
var Collector = require('node-sflow');
Collector(function(flow) {
console.log(flow);
}).listen(3000);
However, the SFlow support in the agents – the networking equipment is usually extremely simplified – far from the richness and complexity the SFlow protocol may provide. Most of the vendors just do packet sampling and send them over SFlow as raw packet/frame header with an associated unclear counter.
In case of you having the issue specified above, this module cannot help much. You will just get the raw packet header (usually Ethernet + IP header) as a Node.JS buffer and then you have to decode it on your own. I want to keep the node-sflow module simple and I don’t plan to decode raw packet headers there as this feature is not a feature of the SFlow itself.
If you need to decode the raw packet header I can suggest one easy solution for you. You can use the pcap module from the npm repository and decode the raw header with it:
var Collector = require('node-sflow');
var pcap = require('pcap');
Collector(function(flow) {
if (flow && flow.flow.records && flow.flow.records.length>0) {
flow.flow.records.forEach(function(n) {
if (n.type == 'raw') {
if (n.protocolText == 'ethernet') {
try {
var pkt = pcap.decode.ethernet(n.header, 0);
if (pkt.ethertype!=2048) return;
console.log('VLAN',pkt.vlan?pkt.vlan.id:'none','Packet',pkt.ip.protocol_name,pkt.ip.saddr,':',pkt.ip.tcp?pkt.ip.tcp.sport:pkt.ip.udp.sport,'->',pkt.ip.daddr,':',pkt.ip.tcp?pkt.ip.tcp.dport:pkt.ip.udp.dport)
} catch(e) { console.log(e); }
}
}
});
}
}).listen(3000);