python test script fixed

This commit is contained in:
KusakabeSi 2021-10-06 09:45:01 +00:00
parent bfd76ff76a
commit dcd82f9893
3 changed files with 27 additions and 30 deletions

View File

@ -19,21 +19,18 @@ 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()
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()
os.write(fd,text)
time.sleep(1)
tr = threading.Thread(target = read_loop, args=(pr,))
@ -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)

View File

@ -19,21 +19,18 @@ 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()
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()
os.write(fd,text)
time.sleep(1)
tr = threading.Thread(target = read_loop, args=(er,))

View File

@ -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