summaryrefslogtreecommitdiffstats
path: root/notFinishedCode
diff options
context:
space:
mode:
authorRefik Hadzialic2011-08-02 16:46:50 +0200
committerRefik Hadzialic2011-08-02 16:46:50 +0200
commit278ef1c0413972da5dae342a17beb226bd776b99 (patch)
treeb56ba828be0738c50ef8e15f5b01c3111d87df95 /notFinishedCode
parentNo changes! (diff)
downloadgsm-selftest-278ef1c0413972da5dae342a17beb226bd776b99.tar.gz
gsm-selftest-278ef1c0413972da5dae342a17beb226bd776b99.tar.xz
gsm-selftest-278ef1c0413972da5dae342a17beb226bd776b99.zip
Modiefied the code to work with ssh tunneling
Diffstat (limited to 'notFinishedCode')
-rw-r--r--notFinishedCode/ServerClass.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/notFinishedCode/ServerClass.py b/notFinishedCode/ServerClass.py
index 93c2f8e..635e395 100644
--- a/notFinishedCode/ServerClass.py
+++ b/notFinishedCode/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