Commit 46267fba authored by Bernd Paysan's avatar Bernd Paysan

Add time limit to addresses

parent ff2ffdd7
......@@ -139,14 +139,15 @@ previous
)
o> ;
: +my-id ( -- )
config:prio# @ host:pri# !
host$ $@ host:id $!
: +my-0key ( -- )
my-0key @ IF my-0key sec@ host:key sec! THEN
my-ekey-pk @ IF
my-ekey-pk $@ host:ekey $!
my-ekey-to 64@ host:ekey-to 64!
THEN ;
: +my-id ( -- )
config:prio# @ host:pri# !
host$ $@ host:id $! +my-0key ;
: +my-addrs ( port o:addr -- )
+my-id
......
......@@ -20,8 +20,10 @@ $1E0 Constant keypack#
keypack# key-salt# + key-cksum# + Constant keypack-all#
key-salt# key-cksum# + Constant wrapper#
Variable my-0key
Variable old-0key
Variable old-ekey-sk \ only the old secure key is needed
Variable my-0key
Variable my-ekey-sk
Variable my-ekey-pk
64Variable my-ekey-to
......@@ -124,7 +126,9 @@ $20 buffer: dummy-buf
header-key dummy-buf dup $C tf_encrypt_256 ( sets tweaks ) ;
: init-my0key ( -- )
no0key( EXIT ) keysize rng$ my-0key sec! ;
no0key( EXIT )
my-0key sec@ dup IF old-0key sec! ELSE 2drop THEN
keysize rng$ my-0key sec! ;
: init-myekey ( -- )
my-ekey-sk sec@ dup IF old-ekey-sk sec! ELSE 2drop THEN
......
......@@ -329,7 +329,8 @@ false Value add-myip
THEN end-with
nest[ cookie, request-gen @ #request, ]nest
do-expect-reply ;
: addme ( addr u -- ) $>addr { addr } now>never
: addme ( addr u -- ) $>addr { addr }
config:ekey-timeout& 2@ d>64 now+delta
addr .+my-id
nat( ." addme: " addr .addr )
addr .host:route $@len 0= IF
......
......@@ -103,9 +103,11 @@ event: :>disconnect ( addr -- ) .disconnect-me ;
>o o to connection disconnect-me 0 to connection o>
dhtroot-addr off THEN ;
Variable announced
: subme ( -- ) announced @ IF
dht-connect sub-me THEN ;
64Variable announced \ time for next announcement
: announced! ( -- )
ticks config:ekey-timeout& 2@ d>64 64+ announced 64! ;
: announced? ( -- flag ) announced 64@ ticks 64u>= ;
: subme ( -- ) announced? IF dht-connect sub-me THEN ;
: c:disconnect ( -- ) connect( [: ." Disconnecting..." cr ;] $err )
disconnect-me connect( [: .packets profile( .times ) ;] $err ) ;
......@@ -125,7 +127,7 @@ Variable announced
net2o-code
expect-reply get-ip fetch-id, replace-me,
cookie+request
end-code| -setip net2o:send-replace announced on ;
end-code| -setip net2o:send-replace announced! ;
\ NAT retraversal
......@@ -159,7 +161,14 @@ Forward insert-addr ( o -- )
: announce-me ( -- )
\ Check for disconnected state
dht-connect online? IF
replace-me -other announced on THEN ;
replace-me -other announced! THEN ;
: announce? ( -- )
announced 64@ 64-0= ?EXIT
announced? 0= IF
init-my0key init-myekey
my-addr[] ['] +my-0key $[]o-map
announce-me THEN ;
: renat-all ( -- ) beacon( ." remove all beacons" cr )
[IFDEF] renat-complete [: [THEN]
......
......@@ -1857,6 +1857,7 @@ Variable need-beacon# need-beacon# on \ true if needs a hash for the ? beacon
[THEN]
Forward save-msgs?
Forward announce?
Forward next-saved-msg
: >next-ticks ( -- )
......@@ -1873,6 +1874,7 @@ Forward next-saved-msg
>next-ticks !!0depth!!
beacon? !!0depth!!
save-msgs? !!0depth!!
announce? !!0depth!!
request-timeout !!0depth!!
event-send !!0depth!!
last-packet-tos !!0depth!!
......
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