Loading client-tests.fs +1 −1 Original line number Diff line number Diff line Loading @@ -166,7 +166,7 @@ event: ->throw dup DoError throw ; \ lookup for other users : nat:connect ( addr u -- ) $A $E 2swap nick-connect : nat:connect ( addr u -- ) $A $E nick-connect ." Connected!" cr ; \ some more helpers Loading n2o +7 −3 Original line number Diff line number Diff line Loading @@ -171,6 +171,10 @@ get-current net2o-cmds definitions \G usage: n2o server get-me init-server announce-me server-loop ; : peer ( -- ) \G usage: n2o server get-me init-client announce-me server-loop ; \ chat mode : -root ( -- ) Loading @@ -184,7 +188,7 @@ get-current net2o-cmds definitions get-me init-client announce-me ?@nextarg IF ." press key to connect to " 2dup type key drop $A $A 2swap nick-connect do-chat c:disconnect THEN ; $A $A nick-connect do-chat c:disconnect THEN ; \ script mode Loading Loading @@ -212,10 +216,10 @@ get-current net2o-cmds definitions \G get: get files into current directory get-me init-client ?@nextarg IF $A $E 2swap nick-connect ." connected" cr $A $E nick-connect ." connected" cr net2o-code expect-reply [: 2dup 2dup '/' -scan nip /string n2o:copy ;] arg-loop end-code| n2o:done end-code| n2o:close-all c:disconnect THEN ; synonym bye bye Loading net2o-cmd.fs +1 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ Variable throwcount cmd( dest-flags .dest-addr 64@ $64. 2dup n2o:see ) sp@ >r throwcount off [: BEGIN cmd-dispatch dup 0<= UNTIL ;] catch trace( ." cmd loop done" cr ) dup IF 1 throwcount +! [: ." do-cmd-loop: " dup . .exe cr ;] $err dup DoError nothrow Loading net2o-connect.fs +2 −2 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ net2o-base \ nat traversal functions +net2o: punch ( $:string -- ) \ punch NAT traversal hole $> net2o:punch ; $> buf-state 2@ 2>r net2o:punch 2r> buf-state 2! ; +net2o: punch-load, ( $:string -- ) \ use for punch payload: nest it $> punch-load $! ; +net2o: punch-done ( -- ) \ punch received Loading Loading @@ -140,7 +140,7 @@ net2o-base push-cmd ;] IS expect-reply? ; +net2o: gen-punch-reply ( -- ) o? \ generate a key request reply reply [: crypt( ." Reply key: " tmpkey@ .nnb F cr ) reply-key, gen-punchload gen-punch time-offset! context ]tmpnest reply-key, time-offset! gen-punchload gen-punch context ]tmpnest push-cmd ;] IS expect-reply? ; gen-table $freeze Loading net2o.fs +3 −3 Original line number Diff line number Diff line Loading @@ -2476,12 +2476,12 @@ require net2o-msg.fs : n2o:lookup ( addr u -- ) 2dup nick-id { id } id .dht-host $[]# 0= IF 2dup nick-lookup THEN id .dht-host $[]# 0= IF 2dup nick-lookup 2dup nick-id to id THEN 0 n2o:new-context >o rdrop 2dup dest-key return-addr $10 erase id dup .dht-host ['] insert-host $[]map drop ; : nick-connect ( cmdlen datalen addr u -- ) n2o:lookup : nick-connect ( addr u cmdlen datalen -- ) 2>r n2o:lookup 2r> cmd0( ." trying to connect to: " return-addr $10 xtype cr ) n2o:connect +flow-control +resend ; Loading Loading
client-tests.fs +1 −1 Original line number Diff line number Diff line Loading @@ -166,7 +166,7 @@ event: ->throw dup DoError throw ; \ lookup for other users : nat:connect ( addr u -- ) $A $E 2swap nick-connect : nat:connect ( addr u -- ) $A $E nick-connect ." Connected!" cr ; \ some more helpers Loading
n2o +7 −3 Original line number Diff line number Diff line Loading @@ -171,6 +171,10 @@ get-current net2o-cmds definitions \G usage: n2o server get-me init-server announce-me server-loop ; : peer ( -- ) \G usage: n2o server get-me init-client announce-me server-loop ; \ chat mode : -root ( -- ) Loading @@ -184,7 +188,7 @@ get-current net2o-cmds definitions get-me init-client announce-me ?@nextarg IF ." press key to connect to " 2dup type key drop $A $A 2swap nick-connect do-chat c:disconnect THEN ; $A $A nick-connect do-chat c:disconnect THEN ; \ script mode Loading Loading @@ -212,10 +216,10 @@ get-current net2o-cmds definitions \G get: get files into current directory get-me init-client ?@nextarg IF $A $E 2swap nick-connect ." connected" cr $A $E nick-connect ." connected" cr net2o-code expect-reply [: 2dup 2dup '/' -scan nip /string n2o:copy ;] arg-loop end-code| n2o:done end-code| n2o:close-all c:disconnect THEN ; synonym bye bye Loading
net2o-cmd.fs +1 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ Variable throwcount cmd( dest-flags .dest-addr 64@ $64. 2dup n2o:see ) sp@ >r throwcount off [: BEGIN cmd-dispatch dup 0<= UNTIL ;] catch trace( ." cmd loop done" cr ) dup IF 1 throwcount +! [: ." do-cmd-loop: " dup . .exe cr ;] $err dup DoError nothrow Loading
net2o-connect.fs +2 −2 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ net2o-base \ nat traversal functions +net2o: punch ( $:string -- ) \ punch NAT traversal hole $> net2o:punch ; $> buf-state 2@ 2>r net2o:punch 2r> buf-state 2! ; +net2o: punch-load, ( $:string -- ) \ use for punch payload: nest it $> punch-load $! ; +net2o: punch-done ( -- ) \ punch received Loading Loading @@ -140,7 +140,7 @@ net2o-base push-cmd ;] IS expect-reply? ; +net2o: gen-punch-reply ( -- ) o? \ generate a key request reply reply [: crypt( ." Reply key: " tmpkey@ .nnb F cr ) reply-key, gen-punchload gen-punch time-offset! context ]tmpnest reply-key, time-offset! gen-punchload gen-punch context ]tmpnest push-cmd ;] IS expect-reply? ; gen-table $freeze Loading
net2o.fs +3 −3 Original line number Diff line number Diff line Loading @@ -2476,12 +2476,12 @@ require net2o-msg.fs : n2o:lookup ( addr u -- ) 2dup nick-id { id } id .dht-host $[]# 0= IF 2dup nick-lookup THEN id .dht-host $[]# 0= IF 2dup nick-lookup 2dup nick-id to id THEN 0 n2o:new-context >o rdrop 2dup dest-key return-addr $10 erase id dup .dht-host ['] insert-host $[]map drop ; : nick-connect ( cmdlen datalen addr u -- ) n2o:lookup : nick-connect ( addr u cmdlen datalen -- ) 2>r n2o:lookup 2r> cmd0( ." trying to connect to: " return-addr $10 xtype cr ) n2o:connect +flow-control +resend ; Loading