Merge pull request #300 from zbrdge/freebsd-platform

Freebsd 10 platform
This commit is contained in:
Maximilian Hils
2014-07-03 02:24:00 +02:00
5 changed files with 25 additions and 6 deletions

View File

@@ -7,3 +7,6 @@ if sys.platform == "linux2":
elif sys.platform == "darwin":
import osx
resolver = osx.Resolver
elif sys.platform == "freebsd10":
import osx
resolver = osx.Resolver

View File

@@ -7,6 +7,10 @@ import pf
structures returned, and compiling userspace tools to test and work with
this turns out to be a pain in the ass. Parsing pfctl output is short,
simple, and works.
Note: Also Tested with FreeBSD 10 pkgng Python 2.7.x.
Should work almost exactly as on Mac OS X and except with some changes to
the output processing of pfctl (see pf.py).
"""
class Resolver:

View File

@@ -1,3 +1,4 @@
import sys
def lookup(address, port, s):
"""
@@ -11,6 +12,11 @@ def lookup(address, port, s):
if "ESTABLISHED:ESTABLISHED" in i and spec in i:
s = i.split()
if len(s) > 4:
s = s[4].split(":")
if sys.platform == "freebsd10":
# strip parentheses for FreeBSD pfctl
s = s[3][1:-1].split(":")
else:
s = s[4].split(":")
if len(s) == 2:
return s[0], int(s[1])