Closed fraxken closed 7 years ago
This is not how it is supposed to be used. The collector should be accessed with
const Collector = require('node-netflowv9');
It would be hard to access a particular function the way they are exported (may be I have to put some thoughts on it). However, you could still do it by doing:
const netflowPktDecoder = require('node-netflowv9').prototype.nfPktDecode;
Delian
On Wed, Oct 12, 2016 at 8:20 PM, Gentilhomme notifications@github.com wrote:
Hi,
When i try to require nfPktDecode like in your readme.md that does'nt work. (The decoder is equal to undefined). And all of decoder prototype seems to be not linked to the Collector Object.
const netflowPktDecoder = require('node-netflowv9').nfPktDecode;console.log(netflowPktDecoder) // undefined
Same result with : nf9PktDecode
Can you look why ? I'm working on NodeJS V6.
Best Regards, Thomas
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/delian/node-netflowv9/issues/15, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7ZiL-o5QNPbZMKrO_5taRY7kycDSsks5qzSTegaJpZM4KVD4P .
No he say to me : this.nf9PktDecode is not a function when i use :
const netflowPktDecoder = require('node-netflowv9').prototype.nfPktDecode;
And with nf9PktDecode he say to me this.nfInfoTemplates is not a function (i use Netflow V9)
Yes, looks like the new method leaves the whole space private. Let me think of how to export it properly
On Wed, 12 Oct 2016 at 20:43, Gentilhomme notifications@github.com wrote:
No he say to me : this.nf9PktDecode is not a function when i use :
const netflowPktDecoder = require('node-netflowv9').prototype.nfPktDecode;
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/delian/node-netflowv9/issues/15#issuecomment-253301602, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7Zl9tfLyhYZFdKYW6MAUBMbuJOj_gks5qzSo-gaJpZM4KVD4P .
Hi,
Maybe if you bind directly your sub-class to this context in the Netflow constructor like
this.nf9PktDecode = nf9PktDecode;
And you move the nfPktDecode function into the class too. I'm not at home right now, but if you want i can made a pull-request to fix that later.
Best Regards, Thomas
Ok i success to fix on my side (but i see a lot of problem). So i have to dev and test a full fixed version on my side.
I see no documentation to make a template. I dont understand your little example for template argument. 235 is the sourceId or the buffer.byteLength or ???
Do you have a real example ?
Ok i see how it's work now :) (First time :D)
Sorry, I was a little sick those days, and I was not following the github mails. Tell me what you mean by template? Decoding a new option type? Or Cisco Option Template?
Delian
On Mon, Oct 17, 2016 at 12:21 AM, Gentilhomme notifications@github.com wrote:
Ok i see how it's work now :) (First time :D)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/delian/node-netflowv9/issues/15#issuecomment-254079420, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7ZhkV11BJ1N7VdNcdVIVO8zQ5WfXUks5q0qNsgaJpZM4KVD4P .
What do you mean? How did you fix it? "Ok i success to fix on my side (but i see a lot of problem). So i have to dev and test a full fixed version on my side. "
Delian
On Sun, Oct 16, 2016 at 11:24 PM, Gentilhomme notifications@github.com wrote:
Ok i success to fix on my side (but i see a lot of problem). So i have to dev and test a full fixed version on my side.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/delian/node-netflowv9/issues/15#issuecomment-254076082, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7Ztb2EaqbCeiTT6aus370Nakakieiks5q0pYbgaJpZM4KVD4P .
Yes i try to add the template when i get it (to nf9PktDecode.templates). But when i decode the flow.packet to see packet header etc... But sometime i have no flows in my array, or i have my flows but with unreadable values...
For the fix i merge nfoTemplates to the nf9PktDecode module. (And i use the prototype on NetflowV9). But the NetflowV9 class have a lot of scope problem.
I'm not at home these last days (i prepare my master degree).
Give me example of what you wish to achieve and how it is affected by the current scope issue? Generally, each of the submodules are supposed to share the scope of the NetFlowV9 class. The reason is, to be able to access this.template, which is not global in order to allow the module to be instantiated multiple times without poisoning the template cache.
It is interesting why the prototypes are not visible outside the module, I have to check what is the behavior of the new Node versions there. In any case, even to access them directly you shall first instantiate the class (or you will not have a template which is the issue you are having).
The rest of the methods of accessing the module are still working, so you could try some of them.
Generating a decoder for a new option with NF9 is relatively easy (as long as you know how to decode it, you shall never receive undefined, you shall receive it in HEX format).
However, it is possible that the scoping rules has been changed in the newer versions of the Node, so I am going to try to find potential issues and to fix it, but it will be great if you can provide me with example where it breaks?
Delian
On Mon, Oct 17, 2016 at 11:41 AM, Gentilhomme notifications@github.com wrote:
Yes i try to add the template when i get it (to nf9PktDecode.templates). But when i decode the flow.packet to see packet header etc... But sometime i have no flows in my array, or i have my flows but with unreadable values...
For the fix i merge nfoTemplates to the nf9PktDecode module. (And i use the prototype on NetflowV9). But the NetflowV9 class have a lot of scope problem.
I'm not at home these last days (i prepare my master degree).
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/delian/node-netflowv9/issues/15#issuecomment-254160931, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7ZpoBmzvBCZdILjan3zP-IVmb7nYLks5q00LHgaJpZM4KVD4P .
For my NodeJS code i have something like that :
const Collector = require('node-netflowv9');
const Decoder = Collector.prototype.nf9PktDecode;
Decoder.templates = {};
Collector({port: 9995})
.on('data',function(flow) {
console.log("Flow incomming");
console.log(Decoder(flow.packet,flow.rinfo);
// I want my flows information here!
})
.on('template',function(data) {
console.log("template incomming");
console.log(data);
var id = data.rinfo.address + ':' + data.rinfo.port;
// Add template to the nf9PktDecode templates list!
if(Decoder.templates[id] === undefined) {
Decoder.templates[id] = data.templates;
}
});
I dont have my computer with the project and the Wireshark. But with this code i have an empty flow array.
So i dont know if i have to made a nfTypes or something like that or if the template is wrong (if i have to use a specific function of your class etc..)
Screenshot of my wireshark : http://imgur.com/a/c7aPN
So i try to get data from flowset, but the flow array on my program is empty. Or one time with wrong values (when Buffer fail to decode correctly i suppose).
I have something like that :
I think i have to create a new nfTypes to match my profile correctly no ? I work on that but it's hard.
the NetFlow Type ID is the sourceId ?
If you want to see my full template :
Okay i read all the code to understood when you use compile,readOptions etc ... (So i see how you made the compiled function) So my last chance is the nfTypes. After that no idea... -_-'
I made a ES6 update : http://pastebin.com/SG5awZRt
It's a first prototype but i work on it (replace all var). I found a problem with template scope between main class and decoder function.
The best solution for maintenable project is still TypeScript to get clear code with typings and possibility to compile to ES6,ES5,ES3 etc..
I am traveling at the moment. As soon as I get back I will look at it
Delian
On Tue, Oct 18, 2016 at 2:40 PM, Gentilhomme notifications@github.com wrote:
I made a ES6 update : http://pastebin.com/SG5awZRt
It's a first prototype but i work on it (replace all var). I found a problem with template scope between main class and decoder function.
The best solution for maintenable project is still TypeScript to get clear code with typings and possibility to compile to ES6,ES5,ES3 etc..
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/delian/node-netflowv9/issues/15#issuecomment-254494720, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7ZiAv_R9JFZ_K4PYrD3PnehvT2tCNks5q1L4xgaJpZM4KVD4P .
i'm working on a fork (you can find on the fork list). When i have something complete i make a Pull-request (but my package contain a lot of breaking change i think).
Maybe with better unit-testing to prevent this kind of problem.
If you want to see : https://github.com/fraxken/node-netflowv9 (i fix my bug with my version)
Hi,
When i try to require nfPktDecode like in your readme.md that does'nt work. (The decoder is equal to undefined). And all of decoder prototype seems to be not linked to the Collector Object.
Same result with : nf9PktDecode
Can you look why ? I'm working on NodeJS V6.
Best Regards, Thomas