Commit 2dd5799a authored by Bernd Paysan's avatar Bernd Paysan

Send first packet to open DHT both to IPv4 and IPv6

parent ee0dee24
......@@ -190,7 +190,7 @@ Defer gen-table
: cmd@ ( -- u ) buf-state 2@ over + >r p@+ r> over - buf-state 2! 64>n ;
standard:field
-5 cells 0 +field net2o.name
-6 cells 0 +field net2o.name
drop
: >net2o-name ( addr -- addr' u )
......@@ -570,7 +570,7 @@ compsem: ['] net2o-code0 compile, also net2o-base ;
cmd( <info> ." send: " outflag .dest-addr dup buf# net2o:see <default> cr )
max-size^2 1+ 0 DO
buf# min-size I lshift u<= IF
I outflag @ stateless# and IF send-cX ?punch-cmds
I outflag @ stateless# and IF send0-xt ?punch-cmds
ELSE
send-reply >r over buf# r@ 2! r> send-xt
THEN
......
......@@ -235,7 +235,11 @@ Sema id-sema
push-cmd ;
+net2o: gen-reply ( -- ) \g generate a key request reply
own-crypt? IF ['] reply-key IS expect-reply? THEN ;
own-crypt? IF
['] reply-key IS expect-reply?
['] send-cX IS send0-xt
return-addr return-address $10 move
THEN ;
+net2o: gen-punch-reply ( -- ) ( obsolete dummy ) ;
\ one-shot packets
......
......@@ -57,19 +57,22 @@ require dhtroot.fs
dhtroot-addr$ $off
dhtroot-addr @ ?dup-IF net2o:dispose-addr THEN ;
: make-context ( pk u -- )
ret0 net2o:new-context >o rdrop dest-pk ;
: pk:connect ( code data key u -- )
connect( [: .time ." Connect to: " dup hex. cr ;] $err )
net2o:new-context >o rdrop o to connection setup!
dest-pk \ set our destination key
make-context
o to connection setup!
+resend-cmd net2o:connect
+flow-control +resend
connect( [: .time ." Connected, o=" o hex. cr ;] $err ) ;
: pk-addr:connect ( code data key u addr -- )
connect( [: .time ." Connect to: " dup hex. cr ;] $err )
net2o:new-context >o rdrop o to connection setup!
['] dests is send0-xt dest-addrs >stack
dest-pk \ set our destination key
>r make-context r> dest-addrs >stack
o to connection setup!
['] dests is send0-xt
+resend-cmd net2o:connect
+flow-control +resend
connect( [: .time ." Connected, o=" o hex. cr ;] $err ) ;
......@@ -295,9 +298,6 @@ User hostc$ \ check for this hostname
check-host? IF insert-host ELSE 2drop false THEN
rot or swap ;
: make-context ( pk u -- )
ret0 net2o:new-context >o rdrop dest-pk ;
in net2o : pklookup? ( pkaddr u -- flag )
2dup keysize2 safe/string hostc$ $! key2| 2dup pkc over str= to ?myself
2dup >d#id { id }
......
......@@ -459,6 +459,19 @@ defer new-msg ' new-tmsg is new-msg
recv-tick 64@ 64swap 64-
rtd( ." rtdelay: " 64dup 64>f .ns cr ) rtdelay 64! ;
User outflag outflag off
: set-flags ( -- )
0 outflag !@ outbuf hdrtags c!
outbuf hdrflags le-uw@ dest-flags le-w! ;
: >send ( addr n -- )
>r r@ [ 64bit# qos3# or ]L or outbuf c! set-flags
outbuf packet-body min-size r> lshift move ;
forward send-code-packet
: send-cX ( addr n -- ) +sendX2 >send send-code-packet ;
in net2o : new-context ( -- o )
context-class new >o timeout( ." new context: " o hex. cr )
my-key-default to my-key \ set default key
......@@ -470,6 +483,7 @@ in net2o : new-context ( -- o )
['] no-timeout is timeout-xt ['] .iperr is setip-xt
['] noop is punch-done-xt ['] noop is sync-done-xt
['] noop is sync-none-xt ['] noop is ack-xt
['] send-cX is send0-xt
-flow-control
-1 blocksize !
1 blockalign !
......@@ -970,12 +984,6 @@ Forward sockaddr+return
: set-dest# ( resend# -- )
n>64 dest-addr 64+! dest-addr 64@ outbuf mapaddr le-64! ;
User outflag outflag off
: set-flags ( -- )
0 outflag !@ outbuf hdrtags c!
outbuf hdrflags le-uw@ dest-flags le-w! ;
#90 Constant EMSGSIZE
: ?msgsize ( ior -- )
......@@ -1002,18 +1010,12 @@ User outflag outflag off
data-map outbuf-encrypt
ret-addr >dest packet-to ;
: >send ( addr n -- )
>r r@ [ 64bit# qos3# or ]L or outbuf c! set-flags
outbuf packet-body min-size r> lshift move ;
: bandwidth+ ( -- )
ns/burst 64@ 1 tick-init 1+ 64*/ bandwidth-tick 64+! ;
: burst-end ( flag -- flag )
ticker 64@ bandwidth-tick 64@ 64max next-tick 64! drop false ;
: send-cX ( addr n -- ) +sendX2 >send send-code-packet ;
\ !!FIXME!! use ffz>, branchless with floating point
: 64ffz< ( 64b -- u / -1 )
......@@ -1067,7 +1069,7 @@ Forward new-addr
temp-addr ret-addr $10 move
insert-address ret-addr ins-dest
nat( ticks .ticks ." send punch to: " ret-addr .addr-path cr )
2dup send-cX ;
outflag @ >r 2dup send-cX r> outflag ! ;
in net2o : punch ( addr u o:connection -- )
o IF
......@@ -1093,7 +1095,8 @@ in net2o : punch ( addr u o:connection -- )
: dests ( addr u o:connection -- )
\G send a reply to all addresses
dest-addrs ['] send-punch addrs-loop 2drop ;
dest-addrs ['] send-punch addrs-loop 2drop
outflag off ;
\ send chunk
......
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