Check-in [c97a6ae834]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed problem with GUI and join/left
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c97a6ae8348dc0e4ad831f74a5784f82a3b821d9
User & Date: bernd 2024-06-23 14:47:24
Context
2024-06-27
08:55
Bump version number check-in: 268786b8e7 user: bernd tags: trunk, 0.9.9-20240627
2024-06-23
14:47
Fixed problem with GUI and join/left check-in: c97a6ae834 user: bernd tags: trunk
2024-06-13
14:22
Bump version number check-in: cd895eb164 user: bernd tags: trunk, 0.9.9-20240613
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to connected.fs.

187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
:noname ( throwcode -- )
    remote? @ IF
	?dup-IF  init-reply
	    $error-id $@ dup IF  $, error-id  ELSE  2drop  THEN
	    nlit, ko  THEN
    ELSE
	error-id>o ?dup-IF
	    >o [{: tc :}h1 tc throw ;] wait-task @ send-event o>
	ELSE  throw  THEN
    THEN ; IS >throw

also }scope

: blocksize! ( n -- )  min-block# umax max-block# umin dup ulit, set-blocksize
    1 swap lshift net2o:blocksizes! ;







|







187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
:noname ( throwcode -- )
    remote? @ IF
	?dup-IF  init-reply
	    $error-id $@ dup IF  $, error-id  ELSE  2drop  THEN
	    nlit, ko  THEN
    ELSE
	error-id>o ?dup-IF
	    >o [{: tc :}h1 tc throw ;] wait-task-event o>
	ELSE  throw  THEN
    THEN ; IS >throw

also }scope

: blocksize! ( n -- )  min-block# umax max-block# umin dup ulit, set-blocksize
    1 swap lshift net2o:blocksizes! ;

Changes to dvcs.fs.

923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
    msg-group$ $@ >group ?save-msg  0 dvcs-request# !
    msg( ." === metadata sync done ===" forth:cr ) ;

: dvcs-sync-done ( -- )
    msg( ." dvcs-sync-done" forth:cr )
    net2o:close-all
    msg( ." dvcs-sync-done closed" forth:cr )
    o [{: xo :}h1 xo .ev-dvcs-sync-done ;] wait-task @ send-event ;

: +dvcs-sync-done ( -- )
    ['] dvcs-sync-done is sync-done-xt
    ['] dvcs-sync-none is sync-none-xt ;

also net2o-base
: dvcs-join, ( -- )







|







923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
    msg-group$ $@ >group ?save-msg  0 dvcs-request# !
    msg( ." === metadata sync done ===" forth:cr ) ;

: dvcs-sync-done ( -- )
    msg( ." dvcs-sync-done" forth:cr )
    net2o:close-all
    msg( ." dvcs-sync-done closed" forth:cr )
    o [{: xo :}h1 xo .ev-dvcs-sync-done ;] wait-task-event ;

: +dvcs-sync-done ( -- )
    ['] dvcs-sync-done is sync-done-xt
    ['] dvcs-sync-none is sync-none-xt ;

also net2o-base
: dvcs-join, ( -- )

Changes to file.fs.

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
	THEN
    THEN o>
    [: .time ." download done: " fs-id ? fs-path $@ type cr ;] do-debug ;
: parent-file-done ( -- )
    o [{: xo :}h1
	xo >o action-of file-xt IF  file-xt  ELSE  file:err  THEN
	0 is file-xt o> ;]
    parent .wait-task @ send-event ;
\ id handling

: id>addr ( id -- addr remainder )
    [: >r file-state $@ r> cells /string >r dup IF  @  THEN r> ;]
    filestate-sema c-section ;
: id>addr? ( id -- addr )
    id>addr cell < !!fileid!! ;







|







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
	THEN
    THEN o>
    [: .time ." download done: " fs-id ? fs-path $@ type cr ;] do-debug ;
: parent-file-done ( -- )
    o [{: xo :}h1
	xo >o action-of file-xt IF  file-xt  ELSE  file:err  THEN
	0 is file-xt o> ;]
    parent .wait-task-event ;
\ id handling

: id>addr ( id -- addr remainder )
    [: >r file-state $@ r> cells /string >r dup IF  @  THEN r> ;]
    filestate-sema c-section ;
: id>addr? ( id -- addr )
    id>addr cell < !!fileid!! ;

Changes to gui.fs.

642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
	    2dup search-connect ?dup-IF  >o +group greet o> 2drop  EXIT  THEN
	    2dup pk-peek? IF  chat-connect true !!connected!!
	    ELSE  2drop  THEN ;] $[]map ;] catch nothrow
    [ ' !!connected!! >body @ ]L = IF  show-connected  THEN ;

: ev-chat-connects  gui-chat-connects
    connection dup [{: con :}h1 con to connection ;]
    swap .wait-task @ send-event ;

false Value in-group?

: group[] ( box group -- box )
    [:  in-group? ?EXIT  true to in-group?
	data $@ group-name >o to text$ o>
	data cell+ $@ drop cell+ >o groups:id$ groups:member[] o>







|







642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
	    2dup search-connect ?dup-IF  >o +group greet o> 2drop  EXIT  THEN
	    2dup pk-peek? IF  chat-connect true !!connected!!
	    ELSE  2drop  THEN ;] $[]map ;] catch nothrow
    [ ' !!connected!! >body @ ]L = IF  show-connected  THEN ;

: ev-chat-connects  gui-chat-connects
    connection dup [{: con :}h1 con to connection ;]
    swap .wait-task-event ;

false Value in-group?

: group[] ( box group -- box )
    [:  in-group? ?EXIT  true to in-group?
	data $@ group-name >o to text$ o>
	data cell+ $@ drop cell+ >o groups:id$ groups:member[] o>

Changes to keccaklow.fs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
\ This file has been generated using SWIG and fsi,
\ and is already platform dependent, search for the corresponding
\ fsi-file to compile it where no one has compiled it before ;)
\ Forth systems have their own own dynamic loader and don't need addional C-Code.
\ That's why this file will just print normal forth-code once compiled
\ and can be used directly with include or require.
\ As all comments are stripped during the compilation, please
\ insert the copyright notice of the original file here.

\ ----===< prefix >===-----
cell 8 = [IF] "64" [ELSE] "32" [THEN]
machine "amd64" str= [IF]
    cpu? avx512dq [IF]
	2drop "AVX512"
    [ELSE]
	cpu? avx2 cpu? svm 0= and [IF] \ AVX2 only on Intel

	    2drop "AVX2"
	[ELSE]
	    2drop "x86_64"
	[THEN]
    [THEN]
[ELSE]
    machine "386" str= [IF]












|


|
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
\ This file has been generated using SWIG and fsi,
\ and is already platform dependent, search for the corresponding
\ fsi-file to compile it where no one has compiled it before ;)
\ Forth systems have their own own dynamic loader and don't need addional C-Code.
\ That's why this file will just print normal forth-code once compiled
\ and can be used directly with include or require.
\ As all comments are stripped during the compilation, please
\ insert the copyright notice of the original file here.

\ ----===< prefix >===-----
cell 8 = [IF] "64" [ELSE] "32" [THEN]
machine "amd64" str= [IF]
    cpu? avx512dq cpu? svm 0= and [IF] \ avx512dq on Intel only if available
	2drop "AVX512"
    [ELSE]
	cpu? avx2 cpu? svm 0= cpu? avx512dq or and [IF]
	    \ AVX2 only on Intel, except if avx512dq is available, then on AMD, too
	    2drop "AVX2"
	[ELSE]
	    2drop "x86_64"
	[THEN]
    [THEN]
[ELSE]
    machine "386" str= [IF]

Changes to linux/net.fs.

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
: get-netlink ( -- )
    PF_NETLINK SOCK_DGRAM NETLINK_ROUTE socket dup ?ior to netlink-sock
    getpid     [ netlink-addr nl_pid ]L l!
    netlink-sock netlink-addr sockaddr_nl bind ?ior
    prep-netlink ;

: netlink? ( -- flag )
    pollfds pollfd# >poll drop read-event
    pollfds [ pollfd revents ]L + w@ POLLIN and ;

: wait-for-netlink ( -- )
    BEGIN  netlink? 0= WHILE  ?events  REPEAT ;

: read-netlink ( -- addr u )
    netlink-sock netlink-buffer netlink-size# MSG_DONTWAIT recv dup ?ior-again







|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
: get-netlink ( -- )
    PF_NETLINK SOCK_DGRAM NETLINK_ROUTE socket dup ?ior to netlink-sock
    getpid     [ netlink-addr nl_pid ]L l!
    netlink-sock netlink-addr sockaddr_nl bind ?ior
    prep-netlink ;

: netlink? ( -- flag )
    pollfds pollfd# >poll drop ?events
    pollfds [ pollfd revents ]L + w@ POLLIN and ;

: wait-for-netlink ( -- )
    BEGIN  netlink? 0= WHILE  ?events  REPEAT ;

: read-netlink ( -- addr u )
    netlink-sock netlink-buffer netlink-size# MSG_DONTWAIT recv dup ?ior-again

Changes to msg.fs.

1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
reply-table $@ inherit-table msging-table

$21 net2o: msg-group ( $:group -- ) \g set group
    $> >group ;
+net2o: msg-join ( $:group -- ) \g join a chat group
    $> >load-group parent >o
    +unique-con +chat-control
    wait-task @ ?dup-IF  <hide>  THEN
    pubkey $@ joined,
    o> ;
+net2o: msg-leave ( $:group -- ) \g leave a chat group
    $> >group parent msg-group-o .msg:peers[] del$cell
    parent >o pubkey $@ left, o> ;
+net2o: msg-reconnect ( $:pubkey+addr -- ) \g rewire distribution tree
    $> $make







|







1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
reply-table $@ inherit-table msging-table

$21 net2o: msg-group ( $:group -- ) \g set group
    $> >group ;
+net2o: msg-join ( $:group -- ) \g join a chat group
    $> >load-group parent >o
    +unique-con +chat-control
\    wait-task @ ?dup-IF  <hide>  THEN
    pubkey $@ joined,
    o> ;
+net2o: msg-leave ( $:group -- ) \g leave a chat group
    $> >group parent msg-group-o .msg:peers[] del$cell
    parent >o pubkey $@ left, o> ;
+net2o: msg-reconnect ( $:pubkey+addr -- ) \g rewire distribution tree
    $> $make
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
; msgfs-class is fs-create
:noname ( addr u -- u )
    [ termserver-class ] defers fs-read
; msgfs-class is fs-read
:noname ( -- )
    parent 0 fs-inbuf !@ 0 fs-path !@
    [{: px $pack $addr :}h1 px $pack $addr ev-msg-eval ;]
    parent .wait-task @ send-event
    fs:fs-clear
; msgfs-class is fs-flush
:noname ( -- )
    fs-path @ 0= ?EXIT
    fs-inbuf $@len IF
	msg( ." Closing file " fs-path $@ .chat-file forth:cr )
	fs-flush







|







1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
; msgfs-class is fs-create
:noname ( addr u -- u )
    [ termserver-class ] defers fs-read
; msgfs-class is fs-read
:noname ( -- )
    parent 0 fs-inbuf !@ 0 fs-path !@
    [{: px $pack $addr :}h1 px $pack $addr ev-msg-eval ;]
    parent .wait-task-event
    fs:fs-clear
; msgfs-class is fs-flush
:noname ( -- )
    fs-path @ 0= ?EXIT
    fs-inbuf $@len IF
	msg( ." Closing file " fs-path $@ .chat-file forth:cr )
	fs-flush
1619
1620
1621
1622
1623
1624
1625

1626
1627
1628
1629
1630
1631
1632

1633
1634
1635
1636
1637

1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648

: send-avalanche ( xt -- )
    msg-group-o .msg:?otr IF  now>otr  ELSE  now>never  THEN
    (send-avalanche)
    >r .chat r> 0= IF  msg-group-o .msg:.nobody  THEN ;

: send-otr-avalanche ( args xt group -- )

    msg-group-o >r to msg-group-o
    msg-group-o .msg:mode dup @ msg:otr# or swap
    ['] send-avalanche !wrapper
    r> to msg-group-o ;

also net2o-base
: joined, ( addr u -- )

    key| o msg-group-o [{: d: key object group :}h1 object >o
	key [: $, msg-signal " joined" $, msg-action ;] group send-otr-avalanche
	o> ;]
    wait-task @ send-event ;
: left, ( addr u -- )

    key| o msg-group-o [{: d: key object group :}h1 object >o
	key [: $, msg-signal " left" $, msg-action ;] group send-otr-avalanche
	o> ;]
    wait-task @ send-event ;
previous

\ chat helper words

Variable chat-keys

: @/ ( addr u -- addr1 u1 addr2 u2 ) '@' $split ;







>







>
|


|

>
|


|







1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651

: send-avalanche ( xt -- )
    msg-group-o .msg:?otr IF  now>otr  ELSE  now>never  THEN
    (send-avalanche)
    >r .chat r> 0= IF  msg-group-o .msg:.nobody  THEN ;

: send-otr-avalanche ( args xt group -- )
    msg( ." Sending OTR avalanche msg" forth:cr )
    msg-group-o >r to msg-group-o
    msg-group-o .msg:mode dup @ msg:otr# or swap
    ['] send-avalanche !wrapper
    r> to msg-group-o ;

also net2o-base
: joined, ( addr u -- )
    key| msg( 2dup .simple-id ." : joined" forth:cr )
    o msg-group-o [{: d: key object group :}h1 object >o
	key [: $, msg-signal " joined" $, msg-action ;] group send-otr-avalanche
	o> ;]
    wait-task-event ;
: left, ( addr u -- )
    key| msg( 2dup .simple-id ." : left" forth:cr )
    o msg-group-o [{: d: key object group :}h1 object >o
	key [: $, msg-signal " left" $, msg-action ;] group send-otr-avalanche
	o> ;]
    wait-task-event ;
previous

\ chat helper words

Variable chat-keys

: @/ ( addr u -- addr1 u1 addr2 u2 ) '@' $split ;

Changes to net2o.fs.

515
516
517
518
519
520
521


522
523
524
525
526
527
528
529
530
531
532

\ create new maps

Variable mapstart $1 mapstart !

: ret0 ( -- ) return-addr $10 erase ;
: setup! ( -- )   setup-table @ token-table !  ret0 ;


: context! ( -- )
    context-table @ token-table !
    o [{: connection :}h1 connection .do-connect ;]
    wait-task @ main-up@ over select send-event ;

: new-code@ ( -- addrs addrd u -- )
    new-code-s 64@ new-code-d 64@ new-code-size @ ;
: new-code! ( addrs addrd u -- )
    new-code-size ! new-code-d 64! new-code-s 64! newcode-val validated or! ;
: new-data@ ( -- addrs addrd u -- )
    new-data-s 64@ new-data-d 64@ new-data-size @ ;







>
>



|







515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534

\ create new maps

Variable mapstart $1 mapstart !

: ret0 ( -- ) return-addr $10 erase ;
: setup! ( -- )   setup-table @ token-table !  ret0 ;
: wait-task-event ( xt -- )
    wait-task @ main-up@ over select send-event ;
: context! ( -- )
    context-table @ token-table !
    o [{: connection :}h1 connection .do-connect ;]
    wait-task-event ;

: new-code@ ( -- addrs addrd u -- )
    new-code-s 64@ new-code-d 64@ new-code-size @ ;
: new-code! ( addrs addrd u -- )
    new-code-size ! new-code-d 64! new-code-s 64! newcode-val validated or! ;
: new-data@ ( -- addrs addrd u -- )
    new-data-s 64@ new-data-d 64@ new-data-size @ ;
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
    [IFDEF] no-hybrid
	pollfds [ pollfd 2* revents ]L + w@ POLLIN and IF  try-reads off
	    do-block read-a-packet4
	    ( 0 pollfds [ pollfd 2* revents ]L + w! ) +rec EXIT  THEN
    [THEN]
    try-read# try-reads !  0 0 ;

: read-event ( -- )
    pollfds revents w@ POLLIN and IF
	?events  \ 0 pollfds revents w!
    THEN ;

: try-read-packet-wait ( -- addr u / 0 0 )
    [defined] no-hybrid ( [defined] darwin ) [ ( or ) 0= ] [IF]
	try-read# try-reads @ ?DO
	    don't-block read-a-packet
	    dup IF  unloop  +rec  EXIT  THEN  2drop
	LOOP
    [THEN]
    poll-sock IF read-a-packet4/6 read-event ELSE 0 0 THEN ;

4 Value sends#
4 Value sendbs#
16 Value recvs# \ balance receive and send
Variable recvflag  recvflag off

[defined] no-hybrid ( [defined] darwin or ) [IF]







<
<
<
<
<







|







1440
1441
1442
1443
1444
1445
1446





1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
    [IFDEF] no-hybrid
	pollfds [ pollfd 2* revents ]L + w@ POLLIN and IF  try-reads off
	    do-block read-a-packet4
	    ( 0 pollfds [ pollfd 2* revents ]L + w! ) +rec EXIT  THEN
    [THEN]
    try-read# try-reads !  0 0 ;






: try-read-packet-wait ( -- addr u / 0 0 )
    [defined] no-hybrid ( [defined] darwin ) [ ( or ) 0= ] [IF]
	try-read# try-reads @ ?DO
	    don't-block read-a-packet
	    dup IF  unloop  +rec  EXIT  THEN  2drop
	LOOP
    [THEN]
    poll-sock IF read-a-packet4/6 ELSE 0 0 THEN ?events ;

4 Value sends#
4 Value sendbs#
16 Value recvs# \ balance receive and send
Variable recvflag  recvflag off

[defined] no-hybrid ( [defined] darwin or ) [IF]
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
	    0= IF  try-read-packet-wait
		dup IF  UNLOOP  UNLOOP  EXIT  THEN  2drop  THEN
	    send-another-chunk  LOOP  drop
    read-a-packet? dup ?LEAVE LOOP ;

: send-loop ( -- )
    send-anything?
    BEGIN  0= IF   wait-send drop read-event  THEN
	!!0depth!! send-another-chunk  AGAIN ;

: create-sender-task ( -- )
    [:  \ ." created sender task " up@ h. cr
	prep-evsocks send-loop ;] 1 net2o-task to sender-task ;

Forward handle-beacon







|







1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
	    0= IF  try-read-packet-wait
		dup IF  UNLOOP  UNLOOP  EXIT  THEN  2drop  THEN
	    send-another-chunk  LOOP  drop
    read-a-packet? dup ?LEAVE LOOP ;

: send-loop ( -- )
    send-anything?
    BEGIN  0= IF   wait-send drop ?events  THEN
	!!0depth!! send-another-chunk  AGAIN ;

: create-sender-task ( -- )
    [:  \ ." created sender task " up@ h. cr
	prep-evsocks send-loop ;] 1 net2o-task to sender-task ;

Forward handle-beacon