Hi Everyone.
Can someone point me to the code base for luci connections (as in how it fetches/pulls this data from conntrack)? I would like to export / use this data for a project (with similar format), I figured it uses conntrack, but I like how it gives you the proto/src/dest/transfer. Any help would be greatly appreciated.
I think I may have found it. Let me know if I'm wrong tho
'use strict';
'require view';
'require poll';
'require request';
'require rpc';
var callLuciRealtimeStats = rpc.declare({
object: 'luci',
method: 'getRealtimeStats',
params: [ 'mode', 'device' ],
expect: { result: [] }
});
var callLuciConntrackList = rpc.declare({
object: 'luci',
method: 'getConntrackList',
expect: { result: [] }
});
var callNetworkRrdnsLookup = rpc.declare({
This file has been truncated. show original
And here it reads the details from the OS level:
export function conntrack_list(callback) {
const etcpr = open('/etc/protocols');
const protos = {};
if (etcpr) {
for (let line = etcpr.read('line'); length(line); line = etcpr.read('line')) {
const m = match(line, /^([^# \t\n]+)\s+([0-9]+)\s+/);
if (m)
protos[m[2]] = m[1];
}
etcpr.close();
}
const nfct = open('/proc/net/nf_conntrack', 'r');
let connt;
if (nfct) {
for (let line = nfct.read('line'); length(line); line = nfct.read('line')) {
This file has been truncated. show original
1 Like