Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test and debug channel's Forward behaviour #13

Open
mschatten opened this issue Mar 30, 2021 · 0 comments
Open

Test and debug channel's Forward behaviour #13

mschatten opened this issue Mar 30, 2021 · 0 comments

Comments

@mschatten
Copy link
Member

Channel's Forward behaviour seems to be working sporadically. It works with the first data sent to it, but the Netcat server seems to not accept subsequent messages. Also the embedded iterator and socket connections need to be validated.

APi/channel.py

Lines 236 to 270 in e1208c0

class Forward( CyclicBehaviour ):
'''Receive inputs, map them to outputs and send to subscribers'''
# TODO: Test this behaviour
async def run( self ):
def iter_clients( srv ):
try:
c, a = srv.sock.accept()
client = nclib.Netcat( sock=c, server=a )
yield client
for client in srv:
yield client
except Exception as e:
return
if self.agent.attach_servers:
for srv in self.agent.attach_servers:
srv.sock.settimeout( 0.1 )
for client in iter_clients( srv ):
self.agent.say( 'CLIENT', client, srv.addr )
result = client.recv_until( self.agent.delimiter, timeout=0.1 )
self.agent.say( 'RESULT', result, srv.addr )
if result:
self.agent.say( 'MAPPING RESULT', result.decode(), srv.addr )
msg = self.agent.map( result.decode() )
self.agent.say( 'MSG', msg, srv.addr )
self.agent.say( 'SERVER LIST 1', self.agent.subscribe_servers )
if self.agent.subscribe_servers:
self.agent.say( 'SERVER LIST 2', self.agent.subscribe_servers )
for srv_out in self.agent.subscribe_servers:
self.agent.say( 'OUT SERVER', srv_out, srv_out.addr )
for client_out in srv_out:
self.agent.say( 'SENDING MSG TO', client_out, client_out.peer )
client_out.sendline( msg.encode() )
self.agent.say( 'DONE SENDING MSG' )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant