Check-in [5cb84dae88]
Not logged in

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

Overview
Comment:Group context handling changed
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5cb84dae88917172cf0c8936caf79e207e55563c
User & Date: bernd 2019-06-17 23:00:55
Context
2019-06-19
21:24
Somewhat repair older presentations check-in: 99af21523b user: bernd tags: trunk
2019-06-17
23:00
Group context handling changed check-in: 5cb84dae88 user: bernd tags: trunk
2019-06-12
21:37
Some more work on locking down chats check-in: 2d8a974f37 user: bernd tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to classes.fs.

125
126
127
128
129
130
131
132
133
134
135
136
137
138






139
140
141
142
143
144
145
...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
    64field: min-slack
    64field: max-slack
    64field: time-offset  \ make timestamps smaller
    64field: lastdeltat
end-class ack-class

cmd-class class
    $value: msging-id$
    field: peers[]
    field: silent-last#
end-class msging-class

cmd-class class{ msg
    $value: id$






    method start
    method tag
    method chain
    method signal
    method re
    method text
    method object
................................................................................
    1 pthread-mutexes +field code-sema
    0 +field end-semas
    \ contexts for subclasses
    field: next-context  \ link field to connect all contexts
    field: log-context
    field: ack-context
    field: msging-context
    field: msg-context
    field: file-state    \ files
    \ rest of state
    field: codebuf#
    field: context#
    field: wait-task
    value: max-timeouts \ initialized with timeouts#
    $10 +field return-address \ used as return address







<
<





>
>
>
>
>
>







 







<







125
126
127
128
129
130
131


132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
...
252
253
254
255
256
257
258

259
260
261
262
263
264
265
    64field: min-slack
    64field: max-slack
    64field: time-offset  \ make timestamps smaller
    64field: lastdeltat
end-class ack-class

cmd-class class


    field: silent-last#
end-class msging-class

cmd-class class{ msg
    $value: id$
    field: peers[]
    field: keys[]
    field: log[]
    field: mode
    \ mode bits:
    0 5 bits: otr# chain# redate# lock# visible#
    method start
    method tag
    method chain
    method signal
    method re
    method text
    method object
................................................................................
    1 pthread-mutexes +field code-sema
    0 +field end-semas
    \ contexts for subclasses
    field: next-context  \ link field to connect all contexts
    field: log-context
    field: ack-context
    field: msging-context

    field: file-state    \ files
    \ rest of state
    field: codebuf#
    field: context#
    field: wait-task
    value: max-timeouts \ initialized with timeouts#
    $10 +field return-address \ used as return address

Changes to msg.fs.

20
21
22
23
24
25
26
27





28
29
30
31
32
33
34
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
Forward pk-connect? ( key u cmdlen datalen -- flag )
Forward addr-connect ( key+addr u cmdlen datalen xt -- )
Forward pk-peek? ( addr u0 -- flag )

: ?hash ( addr u hash -- ) >r
    2dup r@ #@ d0= IF  "" 2swap r> #!  ELSE  2drop rdrop  THEN ;

: >group ( addr u -- )  msg-groups ?hash ;






: avalanche-msg ( msg u1 o:connect -- )
    \G forward message to all next nodes of that message group
    { d: msg }
    last# cell+ $@ dup IF
	bounds ?DO  I @ o <> IF  msg I @ .avalanche-to  THEN
	cell +LOOP
................................................................................
User skip-sig?

Sema msglog-sema

: ?msg-context ( -- o )
    msging-context @ dup 0= IF
	drop
	msg-context @ 0= IF
	    net2o:new-msg msg-context !
	THEN
	net2o:new-msging dup msging-context !
    THEN ;

: >chatid ( group u -- id u )  defaultkey sec@ keyed-hash#128 ;

: msg-log@ ( last# -- addr u )
    [: cell+ $@ save-mem ;] msglog-sema c-section ;
................................................................................
: ?save-msg ( addr u -- )
    ?msg-log
    last# otr-mode @ replay-mode @ or 0= and
    IF  save-msgs&  THEN ;

Sema queue-sema

\ peer queue

: peer> ( -- addr / 0 )
    [: peers[] back> ;] queue-sema c-section ;
: >peer ( addr u -- )
    [: peers[] $+[]! ;] queue-sema c-section ;

\ events

msg-class class end-class msg-notify-class

msg-notify-class ' new static-a with-allocater Constant msg-notify-o

: >msg-log ( addr u -- addr' u )
    last# >r +msg-log last# ?dup-IF  $@ ?save-msg  THEN  r> to last# ;

: do-msg-nestsig ( addr u -- )
    2dup parent .msg-context @ .msg:display
    msg-notify-o .msg:display ;

: display-lastn ( n -- )
    net2o:new-msg >o 0 to parent msg:redisplay dispose o> ;
: display-sync-done ( -- )
    rows  msg-context @ .msg:redisplay ;

: display-one-msg { d: msgt -- }
    net2o:new-msg >o 0 to parent
    msgt ['] msg:display catch IF  ." invalid entry"  cr  2drop  THEN
    dispose o> ;

Forward silent-join

\ !!FIXME!! should use an asynchronous "do-when-connected" thing

: +unique-con ( -- ) o last# cell+ +unique$ ;
Forward +chat-control







|
>
>
>
>
>







 







<
<
<







 







|


|

|











|



|

|


|

|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
..
51
52
53
54
55
56
57



58
59
60
61
62
63
64
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
Forward pk-connect? ( key u cmdlen datalen -- flag )
Forward addr-connect ( key+addr u cmdlen datalen xt -- )
Forward pk-peek? ( addr u0 -- flag )

: ?hash ( addr u hash -- ) >r
    2dup r@ #@ d0= IF  "" 2swap r> #!  ELSE  2drop rdrop  THEN ;

: >group ( addr u -- )
    2dup msg-group# #@ d0= IF
	net2o:new-msg cell- [ msg-class >osize @ cell+ ]L
	2over msg-group# #!
    THEN  last# cell+ $@ drop cell+ to msg-group-o
    msg-groups ?hash ;

: avalanche-msg ( msg u1 o:connect -- )
    \G forward message to all next nodes of that message group
    { d: msg }
    last# cell+ $@ dup IF
	bounds ?DO  I @ o <> IF  msg I @ .avalanche-to  THEN
	cell +LOOP
................................................................................
User skip-sig?

Sema msglog-sema

: ?msg-context ( -- o )
    msging-context @ dup 0= IF
	drop



	net2o:new-msging dup msging-context !
    THEN ;

: >chatid ( group u -- id u )  defaultkey sec@ keyed-hash#128 ;

: msg-log@ ( last# -- addr u )
    [: cell+ $@ save-mem ;] msglog-sema c-section ;
................................................................................
: ?save-msg ( addr u -- )
    ?msg-log
    last# otr-mode @ replay-mode @ or 0= and
    IF  save-msgs&  THEN ;

Sema queue-sema

\ peer queue, in msg context

: peer> ( -- addr / 0 )
    [: msg:peers[] back> ;] queue-sema c-section ;
: >peer ( addr u -- )
    [: msg:peers[] $+[]! ;] queue-sema c-section ;

\ events

msg-class class end-class msg-notify-class

msg-notify-class ' new static-a with-allocater Constant msg-notify-o

: >msg-log ( addr u -- addr' u )
    last# >r +msg-log last# ?dup-IF  $@ ?save-msg  THEN  r> to last# ;

: do-msg-nestsig ( addr u -- )
    2dup msg-group-o .msg:display
    msg-notify-o .msg:display ;

: display-lastn ( n -- )
    msg-group-o >o msg:redisplay o> ;
: display-sync-done ( -- )
    rows  msg-group-o .msg:redisplay ;

: display-one-msg { d: msgt -- }
    msg-group-o >o
    msgt ['] msg:display catch IF  ." invalid entry"  cr  2drop  THEN
    o> ;

Forward silent-join

\ !!FIXME!! should use an asynchronous "do-when-connected" thing

: +unique-con ( -- ) o last# cell+ +unique$ ;
Forward +chat-control

Changes to net2o.fs.

413
414
415
416
417
418
419
420
421

422
423
424
425
426
427
428
....
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
....
1986
1987
1988
1989
1990
1991
1992


1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2 Value flybursts#
$100 Value flybursts-max#
$20 cells Value resend-size#
#50.000.000 d>64 64Constant init-delay# \ 50ms initial timeout step
#60.000.000.000 d>64 64Constant connect-timeout# \ 60s connect timeout

Variable init-context#
Variable msg-groups


UValue connection

in net2o : new-log ( -- o )
    cmd-class new >o  log-table @ token-table ! o o> ;
in net2o : new-ack ( -- o )
    o ack-class new >o  parent!  ack-table @ token-table !
    init-delay# rtdelay 64!
................................................................................
      fstate-free
      \ erase crypto keys
      log-context @ ?dup-IF  .dispose  THEN
      ack-context @ ?dup-IF
	  >o timing-stat $off track-timing $off dispose o>
      THEN
      msging-context @ ?dup-IF  .dispose  THEN
      msg-context    @ ?dup-IF  .dispose  THEN
      unlink-ctx  ungroup-ctx
      end-semas start-semas DO  I pthread_mutex_destroy drop
      1 pthread-mutexes +LOOP
      dispose  0 to connection
      cmd( ." disposed" cr ) ;] file-sema c-section ;

event: :>dispose-context ( o -- )  .net2o:dispose-context ;
................................................................................
\\\
Local Variables:
forth-local-words:
    (
     (("net2o:" "+net2o:") definition-starter (font-lock-keyword-face . 1)
      "[ \t\n]" t name (font-lock-function-name-face . 3))
     (("64field:") non-immediate (font-lock-type-face . 2)


      "[ \t\n]" t name (font-lock-variable-name-face . 3))
     (("with") compile-only (font-lock-type-face . 2)
      "[ \t\n]" t name (font-lock-variable-name-face . 3))
     (("endwith") compile-only (font-lock-type-face . 2))
    )
forth-local-indent-words:
    (
    (("net2o:" "+net2o:") (0 . 2) (0 . 2) non-immediate)
    (("with") (0 . 2) (0 . 2) compile-only)
    (("endwith") (-2 . 0) (0 . -2) compile-only)
    )
End:
[THEN]







|
|
>







 







<







 







>
>













413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
....
1672
1673
1674
1675
1676
1677
1678

1679
1680
1681
1682
1683
1684
1685
....
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2 Value flybursts#
$100 Value flybursts-max#
$20 cells Value resend-size#
#50.000.000 d>64 64Constant init-delay# \ 50ms initial timeout step
#60.000.000.000 d>64 64Constant connect-timeout# \ 60s connect timeout

Variable init-context#
hash: msg-groups
hash: msg-group# ( hash for group objects )
UValue msg-group-o
UValue connection

in net2o : new-log ( -- o )
    cmd-class new >o  log-table @ token-table ! o o> ;
in net2o : new-ack ( -- o )
    o ack-class new >o  parent!  ack-table @ token-table !
    init-delay# rtdelay 64!
................................................................................
      fstate-free
      \ erase crypto keys
      log-context @ ?dup-IF  .dispose  THEN
      ack-context @ ?dup-IF
	  >o timing-stat $off track-timing $off dispose o>
      THEN
      msging-context @ ?dup-IF  .dispose  THEN

      unlink-ctx  ungroup-ctx
      end-semas start-semas DO  I pthread_mutex_destroy drop
      1 pthread-mutexes +LOOP
      dispose  0 to connection
      cmd( ." disposed" cr ) ;] file-sema c-section ;

event: :>dispose-context ( o -- )  .net2o:dispose-context ;
................................................................................
\\\
Local Variables:
forth-local-words:
    (
     (("net2o:" "+net2o:") definition-starter (font-lock-keyword-face . 1)
      "[ \t\n]" t name (font-lock-function-name-face . 3))
     (("64field:") non-immediate (font-lock-type-face . 2)
      "[ \t\n]" t name (font-lock-variable-name-face . 3))
     (("hash:") non-immediate (font-lock-type-face . 2)
      "[ \t\n]" t name (font-lock-variable-name-face . 3))
     (("with") compile-only (font-lock-type-face . 2)
      "[ \t\n]" t name (font-lock-variable-name-face . 3))
     (("endwith") compile-only (font-lock-type-face . 2))
    )
forth-local-indent-words:
    (
    (("net2o:" "+net2o:") (0 . 2) (0 . 2) non-immediate)
    (("with") (0 . 2) (0 . 2) compile-only)
    (("endwith") (-2 . 0) (0 . -2) compile-only)
    )
End:
[THEN]

Changes to wiki/commands.md.

385
386
387
388
389
390
391



392
393
394
395
396
397
398
...
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
  turn a past message into OTR
* $2B msg-coord ( $:gps -- )
  GPS coordinates
* $2C msg-url ( $:url -- )
  specify message URL
* $2D msg-like ( xchar -- )
  add a like




### group description commands ###

* $20 group-name ( $:name -- )
  group symbolic name
* $21 group-id ( $:group -- )
  group id, is a pubkey
................................................................................
  join a chat group
* $23 msg-leave ( $:group -- )
  leave a chat group
* $24 msg-reconnect ( $:pubkey+addr -- )
  rewire distribution tree
* $25 msg-last? ( start end n -- )
* $26 msg-last ( $:[tick0,msgs,..tickn] n -- )
* $27 msg-key ( $:key -- )
* $A msg-nestsig ( $:cmd+sig -- )
  check sig+nest
* $28 msg-nestencsig ( $:enc[cmd]+sig -- )
  decrypt, chech sig+nest

### DVCS patch commands ###

DVCS metadata is stored in messages, containing message text, refs
and patchset objects. Patchset objects are constructed in a way
that makes identical transactions have the same hash.








>
>
>







 







<


<
<







385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
...
416
417
418
419
420
421
422

423
424


425
426
427
428
429
430
431
  turn a past message into OTR
* $2B msg-coord ( $:gps -- )
  GPS coordinates
* $2C msg-url ( $:url -- )
  specify message URL
* $2D msg-like ( xchar -- )
  add a like
* $2E msg-lock ( $:key -- )
  lock down communciation
* $2F msg-unlock ( -- )

### group description commands ###

* $20 group-name ( $:name -- )
  group symbolic name
* $21 group-id ( $:group -- )
  group id, is a pubkey
................................................................................
  join a chat group
* $23 msg-leave ( $:group -- )
  leave a chat group
* $24 msg-reconnect ( $:pubkey+addr -- )
  rewire distribution tree
* $25 msg-last? ( start end n -- )
* $26 msg-last ( $:[tick0,msgs,..tickn] n -- )

* $A msg-nestsig ( $:cmd+sig -- )
  check sig+nest



### DVCS patch commands ###

DVCS metadata is stored in messages, containing message text, refs
and patchset objects. Patchset objects are constructed in a way
that makes identical transactions have the same hash.