2016-08-13 23:38:31 +08:00
|
|
|
import time
|
2015-10-08 18:39:52 +08:00
|
|
|
from threading import Thread
|
|
|
|
|
2016-08-13 23:38:31 +08:00
|
|
|
g_last_served = None
|
2015-11-30 16:56:20 +08:00
|
|
|
|
2015-10-08 18:39:52 +08:00
|
|
|
class TransportProxyBase(Thread):
|
|
|
|
def __init__(self, local_port, dest_host=None, dest_port=None, local_host=''):
|
2016-08-13 23:38:31 +08:00
|
|
|
global g_last_served
|
|
|
|
|
2015-10-08 18:39:52 +08:00
|
|
|
self.local_host = local_host
|
|
|
|
self.local_port = local_port
|
|
|
|
self.dest_host = dest_host
|
|
|
|
self.dest_port = dest_port
|
|
|
|
self._stopped = False
|
|
|
|
super(TransportProxyBase, self).__init__()
|
2015-10-12 19:56:44 +08:00
|
|
|
self.daemon = True
|
2015-10-08 18:39:52 +08:00
|
|
|
|
|
|
|
def stop(self):
|
2015-11-30 16:56:20 +08:00
|
|
|
self._stopped = True
|
2016-08-13 23:38:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
def update_last_serve_time():
|
|
|
|
global g_last_served
|
|
|
|
g_last_served = time.time()
|
|
|
|
|
|
|
|
|
|
|
|
def get_last_serve_time():
|
|
|
|
global g_last_served
|
|
|
|
return g_last_served
|