Loading client-tests.fs +11 −9 Original line number Diff line number Diff line Loading @@ -51,17 +51,19 @@ UValue test# 0 to test# \ n2o:done \ end-code| ; : c:dht ( n -- ) $2000 $10000 "test" ins-ip c:connect 0 ?DO : c:dht ( n -- ) $8 $8 "test" ins-ip c:connect 0 ?DO c:add-tag "anonymous" c:fetch-tag \ c:fetch-tags LOOP do-disconnect ; : std-block ( -- ) $10 blocksize! $A blockalign! ; : c:download1 ( -- ) [: .time ." Download test: 1 text file and 2 photos" cr ;] $err net2o-code expect-reply log !time .time s" Download test " $, type 1 ulit, . pi float, f. cr endwith get-ip $400 blocksize! $400 blockalign! stat( request-stats ) std-block stat( request-stats ) "net2o.fs" "net2o.fs" >cache n2o:copy "data/2011-05-13_11-26-57-small.jpg" "photo000s.jpg" >cache n2o:copy "data/2011-05-20_17-01-12-small.jpg" "photo001s.jpg" >cache n2o:copy Loading @@ -73,7 +75,7 @@ UValue test# 0 to test# net2o-code expect-reply close-all \ rewind-total log .time s" Download test 2" $, type cr endwith $10000 blocksize! $400 blockalign! stat( request-stats ) std-block stat( request-stats ) "data/2011-06-02_15-02-38-small.jpg" "photo002s.jpg" >cache n2o:copy "data/2011-06-03_10-26-49-small.jpg" "photo003s.jpg" >cache n2o:copy "data/2011-06-15_12-27-03-small.jpg" "photo004s.jpg" >cache n2o:copy Loading @@ -89,7 +91,7 @@ UValue test# 0 to test# net2o-code expect-reply close-all \ rewind-total log .time s" Download test 3" $, type cr endwith $10000 blocksize! $400 blockalign! stat( request-stats ) std-block stat( request-stats ) "data/2011-05-13_11-26-57.jpg" "photo000.jpg" >cache n2o:copy "data/2011-05-20_17-01-12.jpg" "photo001.jpg" >cache n2o:copy n2o:done 0 ulit, file-id Loading @@ -101,7 +103,7 @@ UValue test# 0 to test# net2o-code expect-reply close-all \ rewind-total log .time s" Download test 4" $, type cr endwith $10000 blocksize! $400 blockalign! stat( request-stats ) std-block stat( request-stats ) "data/2011-06-02_15-02-38.jpg" "photo002.jpg" >cache n2o:copy "data/2011-06-03_10-26-49.jpg" "photo003.jpg" >cache n2o:copy "data/2011-06-15_12-27-03.jpg" "photo004.jpg" >cache n2o:copy Loading Loading @@ -147,7 +149,7 @@ UValue test# 0 to test# : c:test ( -- ) init-cache' $10000 $100000 "test" ins-ip c:connect c:test-rest ; $a $e "test" ins-ip c:connect c:test-rest ; event: ->throw dup DoError throw ; Loading @@ -165,7 +167,7 @@ event: ->throw dup DoError throw ; \ lookup for other users : nat:connect ( addr u -- ) $10000 $100000 2swap nick-connect : nat:connect ( addr u -- ) $A $E 2swap nick-connect ." Connected!" cr ; \ some more helpers Loading @@ -188,13 +190,13 @@ event: ->throw dup DoError throw ; \ terminal connection : c:terminal ( -- ) $10000 $100000 "test" ins-ip c:connect $a $e "test" ins-ip c:connect [: .time ." Terminal test: connect to server" cr ;] $err tc-permit# fs-class-permit or to fs-class-permit net2o-code expect-reply log .time "Terminal test" $, type cr endwith $10000 blocksize! $400 blockalign! stat( request-stats ) std-block stat( request-stats ) [: 3 ulit, file-type "" $, 0 ulit, open-file state-addr >o 2 fs-class! o> ;] n2o>file end-code| ['] .time $err ; No newline at end of file net2o-connect.fs +2 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,8 @@ $20 net2o: tmpnest ( $:string -- ) \ nested (temporary encrypted) command : n2o:create-map { 64: addrs ucode udata 64: addrd -- addrd ucode udata addrs } addrs lit, addrd lit, ucode ulit, new-code addrs ucode n>64 64+ lit, addrd ucode n>64 64+ lit, udata ulit, new-data addrs min-size ucode lshift n>64 64+ lit, addrd min-size ucode lshift n>64 64+ lit, udata ulit, new-data addrd ucode udata addrs ; +net2o: store-key ( $:string -- ) $> \ store key Loading net2o-connected.fs +9 −7 Original line number Diff line number Diff line Loading @@ -28,10 +28,10 @@ $20 net2o: disconnect ( -- ) \ close connection +net2o: get-ip ( -- ) \ request address information >sockaddr $, set-ip [: $, set-ip ;] n2oaddrs ; +net2o: set-blocksize ( n -- ) \ set blocksize 64>n blocksize! ; +net2o: set-blockalign ( n -- ) \ set block alignment 64>n pow2? blockalign ! ; +net2o: set-blocksize ( n -- ) \ set blocksize to 2^n 64>n 1 swap max-block# umin lshift blocksizes! ; +net2o: set-blockalign ( n -- ) \ set block alignment to 2^n 64>n 1 swap max-block# umin lshift blockalign ! ; +net2o: close-all ( -- ) \ close all files n2o:close-all ; \ better slurping Loading Loading @@ -79,9 +79,6 @@ $20 net2o: open-file ( $:string mode -- ) \ open file with mode gen-table $freeze ' context-table is gen-table : blocksize! ( n -- ) dup ulit, set-blocksize blocksize! ; : blockalign! ( n -- ) pow2? dup ulit, set-blockalign blockalign ! ; :noname ( uid useek -- ) 64>r ulit, file-id 64r> lit, set-seek endwith ; is do-track-seek Loading Loading @@ -153,6 +150,11 @@ gen-table $freeze set-current : blocksize! ( n -- ) max-block# umin dup ulit, set-blocksize 1 swap lshift blocksizes! ; : blockalign! ( n -- ) max-block# umin dup ulit, set-blockalign 1 swap lshift blockalign ! ; : open-tracked-file ( addr u mode --) open-file get-size get-stat ; Loading net2o-err.fs +1 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ s" gap in file handles" throwcode !!gap!! s" invalid file id" throwcode !!fileid!! s" could not send" throwcode !!send!! s" wrong packet size" throwcode !!size!! s" no power of two" throwcode !!pow2!! s" map size too big" throwcode !!mapsize!! s" unimplemented net2o function" throwcode !!function!! s" too many commands" throwcode !!commands!! s" float does not fit" throwcode !!floatfit!! Loading net2o-file.fs +2 −2 Original line number Diff line number Diff line Loading @@ -270,7 +270,7 @@ User file-reg# : n2o:close-file ( id -- ) id>addr? .fs-close ; : blocksize! ( n -- ) : blocksizes! ( n -- ) dup blocksize ! file( ." file read: ======= " cr ." file write: ======= " cr ) dup residualread ! residualwrite ! ; Loading @@ -279,7 +279,7 @@ User file-reg# [: fstates 0 ?DO I n2o:close-file LOOP file-reg# off fstate-off blocksize @ blocksize! blocksize @ blocksizes! read-file# off write-file# off ;] file-sema c-section ; : n2o:open-file ( addr u mode id -- ) Loading Loading
client-tests.fs +11 −9 Original line number Diff line number Diff line Loading @@ -51,17 +51,19 @@ UValue test# 0 to test# \ n2o:done \ end-code| ; : c:dht ( n -- ) $2000 $10000 "test" ins-ip c:connect 0 ?DO : c:dht ( n -- ) $8 $8 "test" ins-ip c:connect 0 ?DO c:add-tag "anonymous" c:fetch-tag \ c:fetch-tags LOOP do-disconnect ; : std-block ( -- ) $10 blocksize! $A blockalign! ; : c:download1 ( -- ) [: .time ." Download test: 1 text file and 2 photos" cr ;] $err net2o-code expect-reply log !time .time s" Download test " $, type 1 ulit, . pi float, f. cr endwith get-ip $400 blocksize! $400 blockalign! stat( request-stats ) std-block stat( request-stats ) "net2o.fs" "net2o.fs" >cache n2o:copy "data/2011-05-13_11-26-57-small.jpg" "photo000s.jpg" >cache n2o:copy "data/2011-05-20_17-01-12-small.jpg" "photo001s.jpg" >cache n2o:copy Loading @@ -73,7 +75,7 @@ UValue test# 0 to test# net2o-code expect-reply close-all \ rewind-total log .time s" Download test 2" $, type cr endwith $10000 blocksize! $400 blockalign! stat( request-stats ) std-block stat( request-stats ) "data/2011-06-02_15-02-38-small.jpg" "photo002s.jpg" >cache n2o:copy "data/2011-06-03_10-26-49-small.jpg" "photo003s.jpg" >cache n2o:copy "data/2011-06-15_12-27-03-small.jpg" "photo004s.jpg" >cache n2o:copy Loading @@ -89,7 +91,7 @@ UValue test# 0 to test# net2o-code expect-reply close-all \ rewind-total log .time s" Download test 3" $, type cr endwith $10000 blocksize! $400 blockalign! stat( request-stats ) std-block stat( request-stats ) "data/2011-05-13_11-26-57.jpg" "photo000.jpg" >cache n2o:copy "data/2011-05-20_17-01-12.jpg" "photo001.jpg" >cache n2o:copy n2o:done 0 ulit, file-id Loading @@ -101,7 +103,7 @@ UValue test# 0 to test# net2o-code expect-reply close-all \ rewind-total log .time s" Download test 4" $, type cr endwith $10000 blocksize! $400 blockalign! stat( request-stats ) std-block stat( request-stats ) "data/2011-06-02_15-02-38.jpg" "photo002.jpg" >cache n2o:copy "data/2011-06-03_10-26-49.jpg" "photo003.jpg" >cache n2o:copy "data/2011-06-15_12-27-03.jpg" "photo004.jpg" >cache n2o:copy Loading Loading @@ -147,7 +149,7 @@ UValue test# 0 to test# : c:test ( -- ) init-cache' $10000 $100000 "test" ins-ip c:connect c:test-rest ; $a $e "test" ins-ip c:connect c:test-rest ; event: ->throw dup DoError throw ; Loading @@ -165,7 +167,7 @@ event: ->throw dup DoError throw ; \ lookup for other users : nat:connect ( addr u -- ) $10000 $100000 2swap nick-connect : nat:connect ( addr u -- ) $A $E 2swap nick-connect ." Connected!" cr ; \ some more helpers Loading @@ -188,13 +190,13 @@ event: ->throw dup DoError throw ; \ terminal connection : c:terminal ( -- ) $10000 $100000 "test" ins-ip c:connect $a $e "test" ins-ip c:connect [: .time ." Terminal test: connect to server" cr ;] $err tc-permit# fs-class-permit or to fs-class-permit net2o-code expect-reply log .time "Terminal test" $, type cr endwith $10000 blocksize! $400 blockalign! stat( request-stats ) std-block stat( request-stats ) [: 3 ulit, file-type "" $, 0 ulit, open-file state-addr >o 2 fs-class! o> ;] n2o>file end-code| ['] .time $err ; No newline at end of file
net2o-connect.fs +2 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,8 @@ $20 net2o: tmpnest ( $:string -- ) \ nested (temporary encrypted) command : n2o:create-map { 64: addrs ucode udata 64: addrd -- addrd ucode udata addrs } addrs lit, addrd lit, ucode ulit, new-code addrs ucode n>64 64+ lit, addrd ucode n>64 64+ lit, udata ulit, new-data addrs min-size ucode lshift n>64 64+ lit, addrd min-size ucode lshift n>64 64+ lit, udata ulit, new-data addrd ucode udata addrs ; +net2o: store-key ( $:string -- ) $> \ store key Loading
net2o-connected.fs +9 −7 Original line number Diff line number Diff line Loading @@ -28,10 +28,10 @@ $20 net2o: disconnect ( -- ) \ close connection +net2o: get-ip ( -- ) \ request address information >sockaddr $, set-ip [: $, set-ip ;] n2oaddrs ; +net2o: set-blocksize ( n -- ) \ set blocksize 64>n blocksize! ; +net2o: set-blockalign ( n -- ) \ set block alignment 64>n pow2? blockalign ! ; +net2o: set-blocksize ( n -- ) \ set blocksize to 2^n 64>n 1 swap max-block# umin lshift blocksizes! ; +net2o: set-blockalign ( n -- ) \ set block alignment to 2^n 64>n 1 swap max-block# umin lshift blockalign ! ; +net2o: close-all ( -- ) \ close all files n2o:close-all ; \ better slurping Loading Loading @@ -79,9 +79,6 @@ $20 net2o: open-file ( $:string mode -- ) \ open file with mode gen-table $freeze ' context-table is gen-table : blocksize! ( n -- ) dup ulit, set-blocksize blocksize! ; : blockalign! ( n -- ) pow2? dup ulit, set-blockalign blockalign ! ; :noname ( uid useek -- ) 64>r ulit, file-id 64r> lit, set-seek endwith ; is do-track-seek Loading Loading @@ -153,6 +150,11 @@ gen-table $freeze set-current : blocksize! ( n -- ) max-block# umin dup ulit, set-blocksize 1 swap lshift blocksizes! ; : blockalign! ( n -- ) max-block# umin dup ulit, set-blockalign 1 swap lshift blockalign ! ; : open-tracked-file ( addr u mode --) open-file get-size get-stat ; Loading
net2o-err.fs +1 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ s" gap in file handles" throwcode !!gap!! s" invalid file id" throwcode !!fileid!! s" could not send" throwcode !!send!! s" wrong packet size" throwcode !!size!! s" no power of two" throwcode !!pow2!! s" map size too big" throwcode !!mapsize!! s" unimplemented net2o function" throwcode !!function!! s" too many commands" throwcode !!commands!! s" float does not fit" throwcode !!floatfit!! Loading
net2o-file.fs +2 −2 Original line number Diff line number Diff line Loading @@ -270,7 +270,7 @@ User file-reg# : n2o:close-file ( id -- ) id>addr? .fs-close ; : blocksize! ( n -- ) : blocksizes! ( n -- ) dup blocksize ! file( ." file read: ======= " cr ." file write: ======= " cr ) dup residualread ! residualwrite ! ; Loading @@ -279,7 +279,7 @@ User file-reg# [: fstates 0 ?DO I n2o:close-file LOOP file-reg# off fstate-off blocksize @ blocksize! blocksize @ blocksizes! read-file# off write-file# off ;] file-sema c-section ; : n2o:open-file ( addr u mode id -- ) Loading