mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-05-12 17:48:49 +08:00
Merge pull request #300 from zbrdge/freebsd-platform
Freebsd 10 platform
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user