Socket and family numbers are differs from OS to OS

This commit is contained in:
Oleksii Shevchuk 2017-03-16 22:04:58 +02:00
parent decb45f52b
commit 4cd1825690
3 changed files with 20 additions and 18 deletions

View File

@ -23,16 +23,12 @@ class IPModule(PupyModule):
def run(self, args):
try:
data = obtain(self.client.conn.modules.pupyps.interfaces())
rpupyps = self.client.conn.modules.pupyps
data = obtain(rpupyps.interfaces())
families = { int(x):y for x,y in obtain(rpupyps.families).iteritems() }
addrlen = max([len(x) for x in data['addrs']])+1
families = {
v:k[3:] for k,v in socket.__dict__.iteritems() if k.startswith('AF_')
}
families.update({-1: 'LINK'})
familylen = max([len(v)-3 for v in families.itervalues()])+1
for addr, addresses in data['addrs'].iteritems():

View File

@ -29,15 +29,10 @@ class NetStatModule(PupyModule):
def run(self, args):
try:
data = obtain(self.client.conn.modules.pupyps.connections())
families = {
v:k for k,v in socket.__dict__.iteritems() if k.startswith('AF_')
}
sock = {
v:k for k,v in socket.__dict__.iteritems() if k.startswith('SOCK_')
}
rpupyps = self.client.conn.modules.pupyps
data = obtain(rpupyps.connections())
sock = { int(x):y for x,y in obtain(rpupyps.socktypes).iteritems() }
families = { int(x):y for x,y in obtain(rpupyps.families).iteritems() }
limit = []
@ -55,8 +50,8 @@ class NetStatModule(PupyModule):
continue
color = ""
family = families[connection['family']][3:]
stype = sock[connection['type']][5:]
family = families[connection['family']]
stype = sock[connection['type']]
if limit and not stype in limit:
continue

View File

@ -6,6 +6,17 @@ import collections
import sys
import os
import time
import socket
families = {
v:k[3:] for k,v in socket.__dict__.iteritems() if k.startswith('AF_')
}
families.update({-1: 'LINK'})
socktypes = {
v:k[5:] for k,v in socket.__dict__.iteritems() if k.startswith('SOCK_')
}
def pstree():
data = {}