Commit 460e8ecb authored by bernd's avatar bernd
Browse files

Try chat mode

parent b873af74
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -131,9 +131,6 @@ UValue test# 0 to test#
      n2o:done
    end-code| ['] .time $err n2o:close-all ;

: c:disconnect ( -- ) [: ." Disconnecting..." cr ;] $err
    do-disconnect [: .packets profile( .times ) ;] $err ;

: c:test-rest ( -- )
    c:download1
    7e @time f> IF c:download2
+14 −3
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ get-current net2o-cmds definitions
    get-me
    [: 2dup hash-file 2drop 2dup type
      [: type ." .s2o" ;] $tmp slurp-file
      over date-sig? dup IF  info-color  ELSE  err-color  THEN  attr! .check
      over date-sig? dup >r  info-color err-color r> select  attr! .check
      space over keysize .key-id default-color attr!
      drop free throw cr ;]
    arg-loop ;
@@ -179,6 +179,17 @@ get-current net2o-cmds definitions
    \G usage: n2o server
    get-me-again init-server server-loop ;

set-current previous
\ chat mode

script? [IF]  next-cmd bye  [THEN]
 No newline at end of file
: chat ( -- )
    \G usage: chat @user
    get-me announce-me
    ?@nextarg IF
	." press key to connect to " 2dup type key drop
	$A $A 2swap nick-connect do-chat c:disconnect  THEN ;

set-current

script? [IF]  argc @ 1 > [IF] next-cmd [ELSE] help [THEN] bye  [THEN]

previous
 No newline at end of file
+24 −7
Original line number Diff line number Diff line
@@ -329,15 +329,23 @@ set-current previous previous
: ?key-sfd ( -- fd ) key-sfd "~/.net2o/seckeys.k2o" ?fd dup to key-sfd ;
: ?key-pfd ( -- fd ) key-pfd "~/.net2o/pubkeys.k2o" ?fd dup to key-pfd ;

: append-file ( addr u fd -- ) >r
    r@ file-size throw  r@ reposition-file throw
: write@pos-file ( addr u 64pos fd -- ) >r
    64>d r@ reposition-file throw
    r@ write-file throw  r> flush-file throw ;

: append-file ( addr u fd -- ) >r
    r@ file-size throw r> write@pos-file ;

: key>sfile ( -- )
    keypack keypack-all# ?key-sfd append-file ;
: key>pfile ( -- )
    keypack keypack-all# ?key-pfd append-file ;

: key>sfile@pos ( 64pos -- ) 64>r
    keypack keypack-all# 64r> ?key-sfd write@pos-file ;
: key>pfile@pos ( 64pos -- ) 64>r
    keypack keypack-all# 64r> ?key-pfd write@pos-file ;

: rnd>sfile ( -- )
    keypack keypack-all# >rng$ key>sfile ;
: rnd>pfile ( -- )
@@ -392,24 +400,33 @@ previous
    2dup 2dup [: type '~' emit ;] $tmp rename-file throw
    2dup [: type '+' emit ;] $tmp 2swap rename-file throw ;

Variable cp-tmp

: save-pubkeys ( -- )
    key-pfd ?dup-IF  close-file throw  THEN
    key-pfd ?dup-IF
	dup 0. rot reposition-file throw
	dup cp-tmp $slurp close-file throw  THEN
    0 "~/.net2o/pubkeys.k2o+" ?fd to key-pfd
    cp-tmp $@ key-pfd write-file throw cp-tmp $off
    key-table [: cell+ $@ drop cell+ >o
      ke-sk sec@ d0= IF  pack-pubkey
	  flush( ." saving " ke-nick $@ type F cr )
	  key-crypt key>pfile
	  key-crypt ke-offset 64@ key>pfile@pos
      THEN o> ;] #map
    key-pfd close-file throw
    "~/.net2o/pubkeys.k2o" >backup
    0 to key-pfd ;

: save-seckeys ( -- )
    key-sfd ?dup-IF  close-file throw  THEN
    key-sfd ?dup-IF
	dup 0. rot reposition-file throw
	dup cp-tmp $slurp close-file throw  THEN
    0 "~/.net2o/seckeys.k2o+" ?fd to key-sfd
    cp-tmp $@ key-sfd write-file throw cp-tmp $off
    key-table [: cell+ $@ drop cell+ >o
      ke-sk sec@ d0<> IF  pack-seckey  THEN
      key-crypt key>sfile o> ;] #map
      ke-sk sec@ d0<> IF  pack-seckey
	  key-crypt ke-offset 64@ key>sfile@pos
      THEN o> ;] #map
    "~/.net2o/seckeys.k2o" >backup
    key-sfd close-file throw 0 to key-sfd ;

+11 −0
Original line number Diff line number Diff line
@@ -88,6 +88,17 @@ previous
    $, msg-text msg>
    cookie+request end-code| ;

: .chat ( addr u -- )
    sigdate 64@ .ticks space pkc keysize .key-id ." : " type cr ;

: do-chat ( -- )
    o-timeout
    BEGIN  pad $100 accept cr dup WHILE
	    dup 1+ xback-restore
	    pad swap 2dup o+timeout send-text o-timeout .chat
    REPEAT
    drop ;

:noname ( addr u o:context -- )
    net2o-code  expect-reply
    msg $, nest-sig endwith
+3 −0
Original line number Diff line number Diff line
@@ -2436,6 +2436,9 @@ require net2o-msg.fs
    +flow-control +resend
    [: .time ." Connected, o=" o hex. cr ;] $err ;

: c:disconnect ( -- ) [: ." Disconnecting..." cr ;] $err
    do-disconnect [: .packets profile( .times ) ;] $err ;

: c:fetch-id ( pubkey u -- )
    net2o-code
      expect-reply  fetch-id,