refine loop
This commit is contained in:
parent
5e19fdc66b
commit
0c8a8ef23f
5 changed files with 120 additions and 136 deletions
|
@ -24,8 +24,9 @@
|
|||
import sys
|
||||
import os
|
||||
import logging
|
||||
import encrypt
|
||||
import utils
|
||||
import encrypt
|
||||
import eventloop
|
||||
import tcprelay
|
||||
import udprelay
|
||||
|
||||
|
@ -49,11 +50,12 @@ def main():
|
|||
logging.info("starting local at %s:%d" %
|
||||
(config['local_address'], config['local_port']))
|
||||
|
||||
# TODO combine the two threads into one loop on a single thread
|
||||
udprelay.UDPRelay(config, True).start()
|
||||
tcprelay.TCPRelay(config, True).start()
|
||||
while sys.stdin.read():
|
||||
pass
|
||||
tcp_server = tcprelay.TCPRelay(config, True)
|
||||
udp_server = udprelay.UDPRelay(config, True)
|
||||
loop = eventloop.EventLoop()
|
||||
tcp_server.add_to_loop(loop)
|
||||
udp_server.add_to_loop(loop)
|
||||
loop.run()
|
||||
except (KeyboardInterrupt, IOError, OSError) as e:
|
||||
logging.error(e)
|
||||
os._exit(0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue