From 52824d5bc8051acc49134c98f376f2ebf83a7b58 Mon Sep 17 00:00:00 2001 From: gsmselftest Date: Wed, 9 Nov 2011 19:08:11 +0100 Subject: add README text --- Code/Box1-Code/READ ME.txt | 3 +++ Code/Box1-Code/ServerClass.py | 12 +++++++++++- Code/Box2-Code/READ ME.txt | 4 ++++ Code/Box2-Code/ServerClass.py | 12 +++++++++++- 4 files changed, 29 insertions(+), 2 deletions(-) (limited to 'Code') diff --git a/Code/Box1-Code/READ ME.txt b/Code/Box1-Code/READ ME.txt index d5db13f..65be275 100644 --- a/Code/Box1-Code/READ ME.txt +++ b/Code/Box1-Code/READ ME.txt @@ -14,3 +14,6 @@ Handler files: - serverHandler.py +How to start the server Handler: + - you can use SSH connection to the box and type: + - $ sudo python serverHandler.py $ diff --git a/Code/Box1-Code/ServerClass.py b/Code/Box1-Code/ServerClass.py index 8687629..088a2ae 100644 --- a/Code/Box1-Code/ServerClass.py +++ b/Code/Box1-Code/ServerClass.py @@ -3,6 +3,8 @@ import sys import os import string import signal +import fcntl +import struct class TimeoutException(Exception): pass @@ -11,7 +13,15 @@ class ServerHandler: def __init__(self,p): self.port = p - self.host = None #symbolic name meaning all available interfaces + ifname = 'eth0' #define here the interface you want to find the ip address + + #code for getting our public addresss so I can make the SSH tunneling work + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + publicAddress = socket.inet_ntoa(fcntl.ioctl( + s.fileno(),0x8915, # SIOCGIFADDR + struct.pack('256s', ifname[:15]))[20:24]) + + self.host = publicAddress #None #'127.0.0.1' #symbolic name meaning all available interfaces self.s = None self.connected = 0 self.address = "127.0.0.1" #address of the main controller diff --git a/Code/Box2-Code/READ ME.txt b/Code/Box2-Code/READ ME.txt index d5db13f..654b1f2 100644 --- a/Code/Box2-Code/READ ME.txt +++ b/Code/Box2-Code/READ ME.txt @@ -14,3 +14,7 @@ Handler files: - serverHandler.py +How to start the server Handler: + - you can use SSH connection to the box and type: + - $ sudo python serverHandler.py $ + diff --git a/Code/Box2-Code/ServerClass.py b/Code/Box2-Code/ServerClass.py index 8687629..088a2ae 100644 --- a/Code/Box2-Code/ServerClass.py +++ b/Code/Box2-Code/ServerClass.py @@ -3,6 +3,8 @@ import sys import os import string import signal +import fcntl +import struct class TimeoutException(Exception): pass @@ -11,7 +13,15 @@ class ServerHandler: def __init__(self,p): self.port = p - self.host = None #symbolic name meaning all available interfaces + ifname = 'eth0' #define here the interface you want to find the ip address + + #code for getting our public addresss so I can make the SSH tunneling work + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + publicAddress = socket.inet_ntoa(fcntl.ioctl( + s.fileno(),0x8915, # SIOCGIFADDR + struct.pack('256s', ifname[:15]))[20:24]) + + self.host = publicAddress #None #'127.0.0.1' #symbolic name meaning all available interfaces self.s = None self.connected = 0 self.address = "127.0.0.1" #address of the main controller -- cgit v1.2.3-55-g7522