mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2024-11-21 23:03:08 +01:00
python test script fixed
This commit is contained in:
parent
bfd76ff76a
commit
dcd82f9893
@ -19,22 +19,19 @@ def signal_handler(sig, frame):
|
||||
|
||||
def read_loop(fd):
|
||||
print("Main Start read fd:",fd)
|
||||
with os.fdopen(fd, 'rb') as fdfile:
|
||||
while True:
|
||||
text = fdfile.read()
|
||||
if len(text) == 0:
|
||||
print("EOF!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
break
|
||||
print("Main: RECEIVED:",text)
|
||||
while True:
|
||||
text = os.read(fd, 65535)
|
||||
if len(text) == 0:
|
||||
print("EOF!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
break
|
||||
print("Main: RECEIVED:",text)
|
||||
|
||||
def write_loop(fd):
|
||||
with os.fdopen(fd, 'wb') as fdfile:
|
||||
while True:
|
||||
print("Main Write fd:",fd)
|
||||
text = b'\xff\xff\xff\xff\xff\xff\xaa\xaa\xaa\xaa\xaa\xaa' + b'm'*88
|
||||
fdfile.write(text)
|
||||
fdfile.flush()
|
||||
time.sleep(1)
|
||||
while True:
|
||||
print("Main Write fd:",fd)
|
||||
text = b'\xff\xff\xff\xff\xff\xff\xaa\xaa\xaa\xaa\xaa\xaa' + b'm'*88
|
||||
os.write(fd,text)
|
||||
time.sleep(1)
|
||||
|
||||
tr = threading.Thread(target = read_loop, args=(pr,))
|
||||
tr.start()
|
||||
@ -48,8 +45,8 @@ os.environ["EG_FD_TX"] = str(ew)
|
||||
print(str(er), str(ew))
|
||||
|
||||
#p = subprocess.Popen('./etherguard-go -config example_config/super_mode/n1_fd.yaml -mode edge'.split(" "),pass_fds=[er,ew])
|
||||
#p = subprocess.Popen('python3 example_config/super_mode/n1_test_fd_mode2.py'.split(" "),pass_fds=[er,ew])
|
||||
p = subprocess.Popen('example_config/super_mode/n1_test_fd_mode2'.split(" "),pass_fds=[er,ew])
|
||||
p = subprocess.Popen('python3 example_config/super_mode/n1_test_fd_mode2.py'.split(" "),pass_fds=[er,ew])
|
||||
#p = subprocess.Popen('example_config/super_mode/n1_test_fd_mode2'.split(" "),pass_fds=[er,ew])
|
||||
|
||||
os.close(er)
|
||||
os.close(ew)
|
||||
|
@ -19,22 +19,19 @@ def signal_handler(sig, frame):
|
||||
|
||||
def read_loop(fd):
|
||||
print("Sub: Start read fd:",fd)
|
||||
with os.fdopen(fd, 'rb') as fdfile:
|
||||
while True:
|
||||
text = fdfile.read()
|
||||
if len(text) == 0:
|
||||
print("EOF!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
break
|
||||
print("Sub RECEIVED:",text)
|
||||
while True:
|
||||
text = os.read(fd, 65535)
|
||||
if len(text) == 0:
|
||||
print("EOF!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
break
|
||||
print("Sub RECEIVED:",text)
|
||||
|
||||
def write_loop(fd):
|
||||
with os.fdopen(fd, 'wb') as fdfile:
|
||||
while True:
|
||||
print("Sub: Write fd:",fd)
|
||||
text = b'\xff\xff\xff\xff\xff\xff\xaa\xaa\xaa\xaa\xaa\xaa' + b's'*88
|
||||
fdfile.write(text)
|
||||
fdfile.flush()
|
||||
time.sleep(1)
|
||||
while True:
|
||||
print("Sub: Write fd:",fd)
|
||||
text = b'\xff\xff\xff\xff\xff\xff\xaa\xaa\xaa\xaa\xaa\xaa' + b's'*88
|
||||
os.write(fd,text)
|
||||
time.sleep(1)
|
||||
|
||||
tr = threading.Thread(target = read_loop, args=(er,))
|
||||
tr.start()
|
||||
|
@ -53,6 +53,9 @@ func CreateSockTAP(iconfig config.InterfaceConf, protocol string, NodeID config.
|
||||
if iconfig.SendAddr != "" {
|
||||
client, err := net.Dial(protocol, iconfig.SendAddr)
|
||||
if err != nil {
|
||||
if tap.server != nil {
|
||||
(*tap.server).Close()
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
tap.connTx = &client
|
||||
|
Loading…
Reference in New Issue
Block a user