Commit 0bd693bf authored by bernd's avatar bernd
Browse files

Use error-id to pass on errors to the waiting task on connection-less tasks

parent 7b6cec4c
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -150,8 +150,6 @@ Variable connect-nick "test" connect-nick $!
    init-cache'
    $a $e connect-nick $@ nick>pk ins-ip pk:connect c:test-rest ;

event: ->throw dup DoError throw ;

: c:test& ( n -- ) \ in background
    up@ 2 stacksize4 NewTask4 pass >r
    alloc-io ['] c:test catch ?dup-IF
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ gen-table $freeze
    host-revoke $off ;
:noname ( -- )
    punch-addrs $@ bounds ?DO  I @ .n2o:dispose-addr  cell +LOOP
    punch-addrs $off ; is punch-dispose
    punch-addrs $off  defers extra-dispose ; is extra-dispose

:noname ( addr u -- o ) \G create a new address object from string
    n2o:new-addr n:>o nest-cmd-loop o n:o> ; is new-addr
+1 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ cmd-class class
    field: mpubkey       \ our side official pubkey
    field: punch-addrs
    field: rqd-xts       \ callbacks for request done (array)
    field: my-error-id
    0 +field end-strings
    field: request-gen   \ pre-generated request number
    field: perm-mask
+3 −3
Original line number Diff line number Diff line
@@ -222,9 +222,9 @@ drop
	.net2o-name
	0 endcase ]hex ;

Variable show-offset  show-offset on
User show-offset  show-offset on

sema see-sema
Sema see-sema

: cmd-see ( addr u -- addr' u' )
    dup show-offset @ = IF  ." <<< "  THEN
@@ -292,7 +292,7 @@ code-buf
:noname ( n -- )  cmdbuf# +! ; to -cmdbuf
:noname ( -- 64dest ) code-vdest 64dup 64-0= !!no-dest!! ; to cmddest

sema cmd0lock
Sema cmd0lock

cmd-buf-c class
    maxdata uvar cmd0buf
+24 −4
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ $20 net2o: request-done ( ureq -- ) 64>n \g signal request is completed
+net2o: punch-load, ( $:string -- ) \g use for punch payload: nest it
    $> $, nest  o IF
	['] punchs code-reply send-xt !
	punch-dispose o-beacon  THEN ;
	extra-dispose  THEN ;
+net2o: punch ( $:string -- ) \g punch NAT traversal hole
    $> net2o:punch ;
+net2o: punch-done ( -- ) \g punch received
@@ -172,13 +172,33 @@ net2o-base
    connect( ." establish a context!" forth:cr ) ;

: time-offset! ( -- )  ticks 64dup lit, >time-offset ack@ .time-offset 64! ;

\ error ID handling

Variable id-hash
: gen-id ( -- addr u )
    $10 rng$ o { w^ idcon } idcon cell 2over id-hash #! ; 
Sema id-sema

: new-error-id ( -- addr u )
    $10 rng$ o { w^ idcon } idcon cell 2over
    [: id-hash #! ;] id-sema c-section
    2dup my-error-id $! ;
: error-id>o ( addr u -- o/0 )
    $error-id $@ ?dup-IF
	id-hash #@ cell = IF
	    @  EXIT  THEN  THEN
    drop 0 ;
: error-id$off ( -- )
    [: my-error-id $@ ?dup-IF  id-hash #off  ELSE  drop  THEN
      my-error-id $off ;] id-sema c-section ;

:noname  error-id$off defers extra-dispose ; IS extra-dispose

\ compile a reply key

: reply-key, ( -- )
    key-setup? @ !!doublekey!!
    nest[
        gen-id $, error-id
        new-error-id $, error-id
        pkc keysize $, pubkey $@len 0> keypad$ nip keysize u<= and IF
	    pubkey $@ key| $, keypair
	    pubkey $@ drop skc key-stage2
Loading