Loading n2o +1 −1 Original line number Diff line number Diff line Loading @@ -4,4 +4,4 @@ require n2o.fs script? [IF] ++debug %droprate \ read in all debugging stuff argc @ 1 > [IF] next-cmd [ELSE] help [THEN] bye [THEN] argc @ 1 > [IF] next-cmd [ELSE] help [THEN] n2o:bye [THEN] n2o.fs +7 −6 Original line number Diff line number Diff line Loading @@ -149,18 +149,18 @@ Variable chat-keys \ commands for the command line user interface Vocabulary net2o-cmds Vocabulary n2o : do-net2o-cmds ( xt -- ) get-order n>r get-recognizers n>r ['] net2o-cmds >body 1 set-order ['] n2o >body 1 set-order ['] rec:word 1 set-recognizers catch nr> set-recognizers nr> set-order throw ; : n2o-cmds ( -- ) init-client word-args ['] quit do-net2o-cmds ; get-current also net2o-cmds definitions get-current also n2o definitions : help ( -- ) \G usage: n2o help [cmd] Loading @@ -176,10 +176,10 @@ get-current also net2o-cmds definitions set-current : next-cmd ( -- ) ?nextarg 0= IF help EXIT THEN ['] net2o-cmds >body search-wordlist ?nextarg 0= IF help EXIT THEN ['] n2o >body search-wordlist IF execute ELSE help THEN ; get-current net2o-cmds definitions get-current n2o definitions : keyin ( -- ) \G usage: n2o keyin/inkey file1 .. filen Loading Loading @@ -348,7 +348,8 @@ synonym qrkey keyqr n2o:done end-code| n2o:close-all c:disconnect THEN ; synonym bye bye : bye ( -- ) subme bye ; set-current Loading net2o-dht.fs +27 −13 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ $200 cells Constant dht-size# \ $100 entris + $100 chains Sema dht-sema Sema d#-sema Variable d#public Loading Loading @@ -138,7 +139,7 @@ Variable dht-table : host>$ ( addr u -- addr u' flag ) >host verify-host >r sigsize# - r> ; : d#. ( -- ) dht-hash $@ 85type ." :" cr [: dht-hash $@ 85type ." :" cr k#size cell DO I cell/ 0 .r ." : " dht-hash I + Loading @@ -147,10 +148,10 @@ Variable dht-table k#tags of [: cr .tag ." , " ;] $[]map cr endof k#owner of [: cr .owner ." , " ;] $[]map cr endof nip endcase cell +LOOP ; cell +LOOP ;] d#-sema c-section ; : d#owner+ ( addr u -- ) \ with sanity checks [: check-owner dht-owner $ins[]sig dht( d#. ) ;] dht-sema c-section ; [: check-owner dht-owner $rep[]sig dht( d#. ) ;] dht-sema c-section ; : d#host+ ( addr u -- ) \ with sanity checks [: check-host dht-host $ins[]sig dht( d#. ) ;] dht-sema c-section ; : d#tags+ ( addr u -- ) \ with sanity checks Loading Loading @@ -270,9 +271,11 @@ false Value add-myip \ new address formats : pub-addr, ( addr u -- ) 2dup pub-addr$ $ins[]sig $, dht-host+ ; : addme-end ( -- ) request( ." addme" forth:cr ) add-myip IF my-addr$ [: $, dht-host+ ;] $[]map my-addr$ ['] pub-addr, $[]map THEN endwith do-expect-reply ; : addme ( addr u -- ) new-addr { addr } now>never Loading @@ -292,7 +295,7 @@ false Value add-myip expect-reply pkc keysize2 $, dht-id mynick$ $, dht-owner+ THEN addr o>addr gen-host $, dht-host+ addr o>addr gen-host pub-addr, addr .n2o:dispose-addr ['] addme-end IS expect-reply? ; previous Loading @@ -300,6 +303,17 @@ previous : +addme ['] addme setip-xt ! ; : -setip ['] .iperr setip-xt ! ; : subme ( -- ) pub-addr$ $[]# 0= ?EXIT $A $E dhtnick $@ nick>pk ins-ip pk:connect net2o-code pkc keysize2 $, dht-id pub-addr$ [: sigsize# - 2dup + sigdate datesize# move gen-host-del $, dht-host- ;] $[]map endwith end-code| disconnect-me ; \ replace me stuff also net2o-base Loading net2o-ip.fs +1 −1 Original line number Diff line number Diff line Loading @@ -23,9 +23,9 @@ 0 Value net2o-sock [THEN] 0 Value query-sock Variable my-ip$ Variable my-addr[] \ object based hosts Variable my-addr$ \ string based hosts (with sigs) Variable pub-addr$ \ publicated addresses (with sigs) Create fake-ip4 $0000 w, $0000 w, $0000 w, $0000 w, $0000 w, $FFFF w, \ prefix for IPv4 addresses encoded as IPv6 Loading net2o-tools.fs +8 −1 Original line number Diff line number Diff line Loading @@ -307,7 +307,14 @@ $10 Constant datesize# 0< IF left $# ELSE $# 1+ right THEN REPEAT drop >r 0 { w^ ins$0 } ins$0 cell $arr r@ cells $ins r> $arr $[]! ; : $del[]sig ( addr u $arrrray -- ) : $rep[]sig ( addr u $array -- ) >r \G replace if newer in one-element array r@ $[]# IF 2dup startdate@ 0 r@ $[]@ startdate@ 64u< IF 2drop rdrop EXIT THEN THEN 0 r> $[]! ; : $del[]sig ( addr u $array -- ) \G delete O(log(n)) from pre-sorted array, check sigs { $arr } 0 $arr $[]# BEGIN 2dup < WHILE 2dup + 2/ { left right $# } Loading Loading
n2o +1 −1 Original line number Diff line number Diff line Loading @@ -4,4 +4,4 @@ require n2o.fs script? [IF] ++debug %droprate \ read in all debugging stuff argc @ 1 > [IF] next-cmd [ELSE] help [THEN] bye [THEN] argc @ 1 > [IF] next-cmd [ELSE] help [THEN] n2o:bye [THEN]
n2o.fs +7 −6 Original line number Diff line number Diff line Loading @@ -149,18 +149,18 @@ Variable chat-keys \ commands for the command line user interface Vocabulary net2o-cmds Vocabulary n2o : do-net2o-cmds ( xt -- ) get-order n>r get-recognizers n>r ['] net2o-cmds >body 1 set-order ['] n2o >body 1 set-order ['] rec:word 1 set-recognizers catch nr> set-recognizers nr> set-order throw ; : n2o-cmds ( -- ) init-client word-args ['] quit do-net2o-cmds ; get-current also net2o-cmds definitions get-current also n2o definitions : help ( -- ) \G usage: n2o help [cmd] Loading @@ -176,10 +176,10 @@ get-current also net2o-cmds definitions set-current : next-cmd ( -- ) ?nextarg 0= IF help EXIT THEN ['] net2o-cmds >body search-wordlist ?nextarg 0= IF help EXIT THEN ['] n2o >body search-wordlist IF execute ELSE help THEN ; get-current net2o-cmds definitions get-current n2o definitions : keyin ( -- ) \G usage: n2o keyin/inkey file1 .. filen Loading Loading @@ -348,7 +348,8 @@ synonym qrkey keyqr n2o:done end-code| n2o:close-all c:disconnect THEN ; synonym bye bye : bye ( -- ) subme bye ; set-current Loading
net2o-dht.fs +27 −13 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ $200 cells Constant dht-size# \ $100 entris + $100 chains Sema dht-sema Sema d#-sema Variable d#public Loading Loading @@ -138,7 +139,7 @@ Variable dht-table : host>$ ( addr u -- addr u' flag ) >host verify-host >r sigsize# - r> ; : d#. ( -- ) dht-hash $@ 85type ." :" cr [: dht-hash $@ 85type ." :" cr k#size cell DO I cell/ 0 .r ." : " dht-hash I + Loading @@ -147,10 +148,10 @@ Variable dht-table k#tags of [: cr .tag ." , " ;] $[]map cr endof k#owner of [: cr .owner ." , " ;] $[]map cr endof nip endcase cell +LOOP ; cell +LOOP ;] d#-sema c-section ; : d#owner+ ( addr u -- ) \ with sanity checks [: check-owner dht-owner $ins[]sig dht( d#. ) ;] dht-sema c-section ; [: check-owner dht-owner $rep[]sig dht( d#. ) ;] dht-sema c-section ; : d#host+ ( addr u -- ) \ with sanity checks [: check-host dht-host $ins[]sig dht( d#. ) ;] dht-sema c-section ; : d#tags+ ( addr u -- ) \ with sanity checks Loading Loading @@ -270,9 +271,11 @@ false Value add-myip \ new address formats : pub-addr, ( addr u -- ) 2dup pub-addr$ $ins[]sig $, dht-host+ ; : addme-end ( -- ) request( ." addme" forth:cr ) add-myip IF my-addr$ [: $, dht-host+ ;] $[]map my-addr$ ['] pub-addr, $[]map THEN endwith do-expect-reply ; : addme ( addr u -- ) new-addr { addr } now>never Loading @@ -292,7 +295,7 @@ false Value add-myip expect-reply pkc keysize2 $, dht-id mynick$ $, dht-owner+ THEN addr o>addr gen-host $, dht-host+ addr o>addr gen-host pub-addr, addr .n2o:dispose-addr ['] addme-end IS expect-reply? ; previous Loading @@ -300,6 +303,17 @@ previous : +addme ['] addme setip-xt ! ; : -setip ['] .iperr setip-xt ! ; : subme ( -- ) pub-addr$ $[]# 0= ?EXIT $A $E dhtnick $@ nick>pk ins-ip pk:connect net2o-code pkc keysize2 $, dht-id pub-addr$ [: sigsize# - 2dup + sigdate datesize# move gen-host-del $, dht-host- ;] $[]map endwith end-code| disconnect-me ; \ replace me stuff also net2o-base Loading
net2o-ip.fs +1 −1 Original line number Diff line number Diff line Loading @@ -23,9 +23,9 @@ 0 Value net2o-sock [THEN] 0 Value query-sock Variable my-ip$ Variable my-addr[] \ object based hosts Variable my-addr$ \ string based hosts (with sigs) Variable pub-addr$ \ publicated addresses (with sigs) Create fake-ip4 $0000 w, $0000 w, $0000 w, $0000 w, $0000 w, $FFFF w, \ prefix for IPv4 addresses encoded as IPv6 Loading
net2o-tools.fs +8 −1 Original line number Diff line number Diff line Loading @@ -307,7 +307,14 @@ $10 Constant datesize# 0< IF left $# ELSE $# 1+ right THEN REPEAT drop >r 0 { w^ ins$0 } ins$0 cell $arr r@ cells $ins r> $arr $[]! ; : $del[]sig ( addr u $arrrray -- ) : $rep[]sig ( addr u $array -- ) >r \G replace if newer in one-element array r@ $[]# IF 2dup startdate@ 0 r@ $[]@ startdate@ 64u< IF 2drop rdrop EXIT THEN THEN 0 r> $[]! ; : $del[]sig ( addr u $array -- ) \G delete O(log(n)) from pre-sorted array, check sigs { $arr } 0 $arr $[]# BEGIN 2dup < WHILE 2dup + 2/ { left right $# } Loading