Skip to content

Commit

Permalink
Cleaned up unused dstaddr from TUN code
Browse files Browse the repository at this point in the history
* No need for a python-pytun `dstaddr` since it's not what we thought it
was. It's for point to point and we really don't want that. Per FaradayRF#21
* Added mtu parameter to Monitor class
* Updated all unit tests to pass with new dstaddr removal and mtu
addition.
* Added a `develop` branch per FaradayRF#24
  • Loading branch information
kb1lqc committed Jan 25, 2018
1 parent 89a7b61 commit 730b1b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions faradayio/faraday.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,11 @@ def receive(self, length):

class TunnelServer(object):
def __init__(self, addr='10.0.0.1',
dstaddr='10.0.0.2',
netmask='255.255.255.0',
mtu=1500,
name="Faraday"):
self._tun = pytun.TunTapDevice(name=name)
self._tun.addr = addr
self._tun.dstaddr = dstaddr
self._tun.netmask = netmask
self._tun.mtu = mtu
self._tun.persist(True)
Expand All @@ -103,13 +101,13 @@ def __del__(self):


class Monitor(threading.Thread):
def __init__(self, serialPort, name, addr, dstaddr):
def __init__(self, serialPort, name, addr, mtu):
super().__init__()
self._isRunning = threading.Event()
self._serialPort = serialPort

# Start a TUN adapter
self._TUN = TunnelServer(name=name, addr=addr, dstaddr=dstaddr)
self._TUN = TunnelServer(name=name, addr=addr, mtu=mtu)

# Create a Faraday instance
self._faraday = Faraday(serialPort=serialPort)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_tun.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_tunSend():
faradayTUN = faraday.TunnelServer()

# Send a string throught the IP
HOST = faradayTUN._tun.dstaddr
HOST = "10.0.0.2"
PORT = 9999 # Anything

# Just send asci lprintable data for now
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_tunSlipSend():
TUNMonitor = faraday.Monitor(serialPort=serialPort,
name="Faraday",
addr=sourceHost,
dstaddr=destHost)
mtu=1500)

srcPacket = (IP(dst=destHost,
src=sourceHost) /
Expand Down Expand Up @@ -146,7 +146,7 @@ def test_serialToTUN():
TUNMonitor = faraday.Monitor(serialPort=serialPort,
name="Faraday",
addr=tunAddress,
dstaddr=sourceAddress)
mtu=1500)

# Open a socket for UDP packets and bind it to the TUN address:port
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
Expand Down

0 comments on commit 730b1b4

Please sign in to comment.