Commit c9968c8e authored by bernd's avatar bernd

Move connection messages into connect( debug switch

parent 8cc60cff
......@@ -70,6 +70,7 @@ debug: sendto(
debug: avalanche( \ distribution tree
debug: adjust-timer( \ adjust timer
debug: reply( \ test replies
debug: connect( \ connect debugging messages
-db profile( \ )
......
......@@ -105,7 +105,7 @@ Variable chat-keys
: wait-chat ( -- )
." press key to connect to "
chat-keys [: 2dup keysize2 /string tuck <info> type IF '.' emit THEN
.key-id space ;] $[]map
.key-id space ;] $[]map cr
[: 0 to connection -56 throw ;] is do-disconnect
[: false chat-keys [: keysize umin pubkey $@ str= or ;] $[]map
IF bl inskey THEN up@ wait-task ! ;] is do-connect
......
......@@ -140,7 +140,8 @@ net2o-base
+net2o: >time-offset ( n -- ) \g set time offset
o IF ack@ .time-offset 64! ELSE 64drop THEN ;
+net2o: context ( -- ) \g make context active
o IF context! ELSE ." Can't " THEN ." establish a context!" forth:cr ;
o IF context! ELSE connect( ." Can't " ) THEN
connect( ." establish a context!" forth:cr ) ;
: time-offset! ( -- ) ticks 64dup lit, >time-offset ack@ .time-offset 64! ;
: reply-key, ( -- )
......
......@@ -25,12 +25,12 @@ Variable dhtnick "net2o-dhtroot" dhtnick $!
net2o-host $@ net2o-port insert-ip6 ;
: pk:connect ( code data key u ret -- )
[: .time ." Connect to: " dup hex. cr ;] $err
connect( [: .time ." Connect to: " dup hex. cr ;] $err )
n2o:new-context >o rdrop o to connection setup!
dest-pk \ set our destination key
n2o:connect
+flow-control +resend
[: .time ." Connected, o=" o hex. cr ;] $err ;
connect( [: .time ." Connected, o=" o hex. cr ;] $err ) ;
: dht-connect ( -- )
$8 $8 dhtnick $@ nick>pk ins-ip pk:connect ;
......@@ -38,8 +38,8 @@ Variable dhtnick "net2o-dhtroot" dhtnick $!
: subme ( -- )
pub-addr$ $[]# 0= ?EXIT dht-connect sub-me disconnect-me ;
: c:disconnect ( -- ) [: ." Disconnecting..." cr ;] $err
disconnect-me [: .packets profile( .times ) ;] $err ;
: c:disconnect ( -- ) connect( [: ." Disconnecting..." cr ;] $err )
disconnect-me connect( [: .packets profile( .times ) ;] $err ) ;
: c:fetch-id ( pubkey u -- )
net2o-code
......@@ -74,10 +74,10 @@ User host$ \ check for this hostname
2 pick >o host>$ o> IF
new-addr dup .host-id $@
host$ $@ str= host$ $@len 0= or IF
." check addr: " dup .addr cr dup >r
connect( ." check addr: " dup .addr cr ) dup >r
[: check-addr1 0= IF 2drop EXIT THEN
insert-address temp-addr ins-dest
." insert host: " temp-addr .addr-path cr
connect( ." insert host: " temp-addr .addr-path cr )
return-addr $10 0 skip nip 0= IF
temp-addr return-addr $10 move
THEN ;] addr>sock r>
......@@ -130,6 +130,16 @@ User search-key$
search-key$ $off search-key$ $+[]!
search-keys insert-keys save-pubkeys ; is dht-nick?
\ connect, disconnect debug
: dbg-connect ( -- ) connect( <info>
." connected from: " pubkey $@ .key-id <default> cr ) ;
: dbg-disconnect ( -- ) connect( <info>
." disconnecting: " pubkey $@ .key-id <default> cr ) ;
' dbg-connect IS do-connect
' dbg-disconnect IS do-disconnect
0 [IF]
Local Variables:
forth-local-words:
......
......@@ -105,7 +105,8 @@ User ip6:#
Defer .addr$
: .iperr ( addr len -- )
[: <info> .time ." connected from: " .addr$ <default> cr ;] $err ;
connect( [: <info> .time ." connected from: " .addr$ <default> cr ;] $err
)else( 2drop ) ;
: ipv4! ( ipv4 sockaddr -- )
>r r@ sin6_addr 12 + be-l!
......
......@@ -281,13 +281,13 @@ event: ->search-key key| over >r dht-nick? r> free throw ;
." got : " 2dup 85type cr ;] $err
true !!wrong-key!!
THEN
.key# EXIT
connect( .key# )else( 2drop ) EXIT
THEN THEN
2dup key-exist? 0= IF
strict-keys @ !!unknown-key!!
." Unknown key " 85type cr
ELSE
.key#
connect( .key# )else( 2drop )
THEN ; IS check-key
:noname ( pkc -- skc )
......
......@@ -477,13 +477,8 @@ require net2o-classes.fs
\ events for context-oriented behavior
: dbg-connect ( -- ) <info>
." connected from: " pubkey $@ 85type <default> cr ;
: dbg-disconnect ( -- ) <info>
." disconnecting: " pubkey $@ 85type <default> cr ;
Defer do-connect ' dbg-connect IS do-connect
Defer do-disconnect ' dbg-disconnect IS do-disconnect
Defer do-connect
Defer do-disconnect
event: ->connect ( connection -- ) .do-connect ;
......@@ -1881,7 +1876,7 @@ Variable cookies
fdup 1e f< IF 1e3 f* 10 6 0 f.rdp ." ms" EXIT THEN
10 6 0 f.rdp 's' emit ;
: rtdelay! ( time -- ) recv-tick 64@ 64swap 64-
64dup ." rtdelay: " 64>f .ns cr
connect( 64dup ." rtdelay: " 64>f .ns cr )
rtdelay 64! ;
: adjust-ticks ( time -- ) o 0= IF 64drop EXIT THEN
recv-tick 64@ 64- rtdelay 64@ 64dup 64-0<> >r 64-2/
......
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