Commit 50026490 authored by bernd's avatar bernd

NAT traversal repaired (after other changes broke it)

parent 8a0a781a
......@@ -103,7 +103,9 @@ net2o-base
+net2o: punch-done ( -- ) \g punch received
o 0<> own-crypt? and IF
return-addr return-address $10 move resend0 $off
nat( ." punch done: " return-address .addr-path forth:cr )
nat( ticks .ticks ." punch done: " return-address .addr-path forth:cr )
ELSE
nat( ticks .ticks ." punch not done: " return-addr .addr-path forth:cr )
THEN ;
: cookie, ( -- ) add-cookie lit, set-cookie ;
......@@ -111,7 +113,7 @@ net2o-base
: request, ( -- ) next-request #request, ;
: gen-punch ( -- ) nat( ." gen punches" forth:cr )
my-addr$ [: -sig nat( ." gen punch: " 2dup .addr$ forth:cr ) $, punch ;] $[]map ;
my-addr$ [: -sig nat( ticks .ticks ." gen punch: " 2dup .addr$ forth:cr ) $, punch ;] $[]map ;
: cookie+request ( -- ) request( ." gen cookie" forth:cr )
nest[ cookie, request, ]nest ;
......
......@@ -261,12 +261,12 @@ Defer !my-addr
: check-addr1 ( -- addr u flag )
sockaddr1 sock-rest 2dup try-ip
nat( ." check: " >r 2dup .address
( nat( ." check: " >r 2dup .address
r> dup IF ." ok" ELSE ." ko" THEN cr ) ;
: ping-addr1 ( -- )
check-addr1 0= IF 2drop EXIT THEN
nat( ." ping: " 2dup .address cr )
nat( ticks .ticks ." ping: " 2dup .address cr )
2>r net2o-sock ">" 0 2r> sendto drop ;
: p+ ( addr u -- addr' u' )
......
......@@ -525,9 +525,10 @@ previous
: send-reconnect ( group -- )
dup cell+ $@
case cell of @ >o o to connection +resend-cmd send-leave o> endof
0 of drop endof
>r @ .send-reconnects r>
case
0 of 2drop endof
cell of @ >o o to connection +resend-cmd send-leave o> endof
default: drop @ .send-reconnects
endcase ;
: disconnect-group ( group -- ) >r
r@ cell+ $@ bounds ?DO I @ cell +LOOP
......
......@@ -1138,8 +1138,8 @@ Defer new-addr
: send-punch ( -- )
check-addr1 0= IF 2drop EXIT THEN
insert-address temp-addr ins-dest
temp-addr return-addr $10 move
nat( ." send punch to: " return-addr .addr-path cr )
temp-addr ret-addr $10 move
nat( ticks .ticks ." send punch to: " ret-addr .addr-path cr )
punch-load $@ punch-reply ;
: net2o:punch ( addr u -- )
......@@ -1509,6 +1509,7 @@ Defer handle-beacon
: next-packet ( -- addr u )
sender-task 0= IF send-read-packet ELSE try-read-packet-wait THEN
dup minpacket# u>= IF
( nat( ." packet from: " sockaddr alen @ .address cr )
sockaddr alen @ insert-address inbuf ins-source
over packet-size over <> !!size!! +next
EXIT
......@@ -1770,7 +1771,7 @@ Variable beacons \ destinations to send beacons to
last# $off last# cell+ $off
THEN
THEN ;
: add-beacon ( net2oaddr xt -- ) >r route>address sockaddr alen @ r> +beacon ;
: sub-beacon ( net2oaddr xt -- ) >r route>address sockaddr alen @ r> -beacon ;
: ret+beacon ( -- ) ret-addr be@ ['] 2drop add-beacon ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment