Check-in [e961e252cc]
Not logged in

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

Overview
Comment:Add preferrence ipv6/ipv4 switch for dht connection
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e961e252cc6d3378ab16576d1dc50315c9991e42
User & Date: bernd 2019-08-21 20:04:30.647
Context
2019-08-21
21:01
Test otrify, works check-in: 901360a4c6 user: bernd tags: trunk
20:04
Add preferrence ipv6/ipv4 switch for dht connection check-in: e961e252cc user: bernd tags: trunk
2019-08-20
12:49
Fix chat lock with GUI check-in: b463747f63 user: bernd tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to addr.fs.
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    64>n dup host:portv4 w! host:portv6 w! ;
+net2o: addr-route ( $:net2o -- ) \g net2o routing part
    $> host:route $! ;
+net2o: addr-key ( $:addr -- ) \g key for connection setup
    $> host:key sec! ;
+net2o: addr-revoke ( $:revoke -- ) \g revocation info
    $> host:revoke $! ;
+net2o: addr-ekey ( $:ekey timeout -- ) \g ephemeral key
    host:ekey-to 64! $> host:ekey $! ;
}scope

address-table $save
' context-table is gen-table

: $[]o-map { addr xt -- }
    \G execute @var{xt} for all elements of the object array @var{addr}.







|
|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    64>n dup host:portv4 w! host:portv6 w! ;
+net2o: addr-route ( $:net2o -- ) \g net2o routing part
    $> host:route $! ;
+net2o: addr-key ( $:addr -- ) \g key for connection setup
    $> host:key sec! ;
+net2o: addr-revoke ( $:revoke -- ) \g revocation info
    $> host:revoke $! ;
+net2o: addr-ekey ( $:ekey -- ) \g ephemeral key
    $> host:ekey $! ;
}scope

address-table $save
' context-table is gen-table

: $[]o-map { addr xt -- }
    \G execute @var{xt} for all elements of the object array @var{addr}.
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
	host:portv4 w@ ulit, addr-port
    ELSE
	host:portv4 w@ ?dup-IF  ulit, addr-portv4  THEN
	host:portv6 w@ ?dup-IF  ulit, addr-portv6  THEN
    THEN
    host:route $@ dup IF  $, addr-route  ELSE  2drop  THEN
    host:key sec@ dup IF  sec$, addr-key  ELSE  2drop  THEN
    host:ekey $@ dup IF  $, host:ekey-to 64@ ulit, addr-ekey  ELSE  2drop  THEN
    host:revoke $@ dup IF  $, addr-revoke  ELSE  2drop  THEN o> ; 
previous
: o>addr ( o -- addr u )
    cmdbuf-o @ >r code-buf$ cmdreset o-genaddr cmdbuf$ r> cmdbuf-o ! ;

: .addr ( o -- ) \G print addr
    >o







|







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
	host:portv4 w@ ulit, addr-port
    ELSE
	host:portv4 w@ ?dup-IF  ulit, addr-portv4  THEN
	host:portv6 w@ ?dup-IF  ulit, addr-portv6  THEN
    THEN
    host:route $@ dup IF  $, addr-route  ELSE  2drop  THEN
    host:key sec@ dup IF  sec$, addr-key  ELSE  2drop  THEN
    host:ekey $@ dup IF  $, addr-ekey  ELSE  2drop  THEN
    host:revoke $@ dup IF  $, addr-revoke  ELSE  2drop  THEN o> ; 
previous
: o>addr ( o -- addr u )
    cmdbuf-o @ >r code-buf$ cmdreset o-genaddr cmdbuf$ r> cmdbuf-o ! ;

: .addr ( o -- ) \G print addr
    >o
125
126
127
128
129
130
131
132


133
134
135

136
137
138
139
140
141
142

: addr>4sock ( -- )
    host:key @ dest-0key< !
    host:portv4 w@ sockaddr1 port be-w!
    host:ipv4 be-ul@ sockaddr1 ipv4!
    host:route $@ !temp-addr ;

:noname ( o xt -- ) { xt } >o


    ipv4( host:ipv4 be-ul@ IF  addr>4sock o o> >r xt execute  r> >o THEN )
    ipv6( host:ipv6 ip6?   IF  addr>6sock o o> >r xt execute  r> >o THEN )
    o> ; is addr>sock


: +my-id ( -- )
    config:prio# @ host:pri# !
    host$ $@ host:id $!
    my-0key @ IF  my-0key sec@ host:key sec!  THEN ;

: +my-addrs ( port o:addr -- )







|
>
>
|
|
|
>







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

: addr>4sock ( -- )
    host:key @ dest-0key< !
    host:portv4 w@ sockaddr1 port be-w!
    host:ipv4 be-ul@ sockaddr1 ipv4!
    host:route $@ !temp-addr ;

: addr>sock6 { xt -- }
    ipv6( host:ipv6 ip6?   IF  addr>6sock o o> >r xt execute  r> >o THEN ) ;
: addr>sock4 { xt -- }
    ipv4( host:ipv4 be-ul@ IF  addr>4sock o o> >r xt execute  r> >o THEN ) ;

: addr>sock ( o xt -- ) { xt } >o
    ipv64( xt addr>sock6 xt addr>sock4 )else( xt addr>sock4 xt addr>sock6 ) o> ;

: +my-id ( -- )
    config:prio# @ host:pri# !
    host$ $@ host:id $!
    my-0key @ IF  my-0key sec@ host:key sec!  THEN ;

: +my-addrs ( port o:addr -- )
160
161
162
163
164
165
166
167


168
169
170
171
172
173
174
175
    my-addr$ $[]free
    pub-addr$ $[]free
    priv-addr$ $[]free ;

: !my-addr$ ( -- )
    my-key-default 0= ?EXIT
    now>never  my-addr[] [:
      nat( ." insert into my-addr$: " dup .addr forth:cr )


      o>addr gen-host my-addr$ $ins[]sig drop ;] $[]o-map ;

: .my-addrs ( -- )
    my-addr[] [: .addr cr ;] $[]o-map ;
: .my-addr$s ( -- )
    my-addr$ [: sigsize# - .addr$ cr ;] $[]map ;
: .pub-addr$s ( -- )
    pub-addr$ [: sigsize# - .addr$ cr ;] $[]map ;







|
>
>
|







163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
    my-addr$ $[]free
    pub-addr$ $[]free
    priv-addr$ $[]free ;

: !my-addr$ ( -- )
    my-key-default 0= ?EXIT
    now>never  my-addr[] [:
	nat( ." insert into my-addr$: " dup .addr forth:cr )
	dup .host:ekey-to 64@ 64dup 64-0= n>64 64+
	sigdate 64'+ le-64!
	o>addr gen-host my-addr$ $ins[]sig drop ;] $[]o-map ;

: .my-addrs ( -- )
    my-addr[] [: .addr cr ;] $[]o-map ;
: .my-addr$s ( -- )
    my-addr$ [: sigsize# - .addr$ cr ;] $[]map ;
: .pub-addr$s ( -- )
    pub-addr$ [: sigsize# - .addr$ cr ;] $[]map ;
Changes to debugging.fs.
50
51
52
53
54
55
56

57
58
59
60
61
62
63
debug: file( \ file read/write debugging
debug: file1( \ simple file read/write debugging
debug: nat( \ NAT traversal stuff
debug: netlink( \ Netlink changes
debug: route( \ do routing
debug: ipv6( \ use ipv6
debug: ipv4( \ use ipv4

debug: request( \ track requests
debug: beacon( \ debug sending beacons
debug: invalid( \ print invalid packets
debug: regen( \ regenerate keys
debug: recvfrom(
debug: sendto(
debug: avalanche( \ distribution tree







>







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
debug: file( \ file read/write debugging
debug: file1( \ simple file read/write debugging
debug: nat( \ NAT traversal stuff
debug: netlink( \ Netlink changes
debug: route( \ do routing
debug: ipv6( \ use ipv6
debug: ipv4( \ use ipv4
debug: ipv64( \ prefer ipv4 over 6
debug: request( \ track requests
debug: beacon( \ debug sending beacons
debug: invalid( \ print invalid packets
debug: regen( \ regenerate keys
debug: recvfrom(
debug: sendto(
debug: avalanche( \ distribution tree
83
84
85
86
87
88
89

90
91
92
93
94
95
96
debug: unhandled( \ unhandled commands
debug: syncfile( \ synchronous file operations
debug: newvault( \ new style vault keys

-db profile( \ don't profile by default )
+db ipv6( \ ipv6 should be on by default )
+db ipv4( \ ipv4 should be on by default )

-db newvault( \ new vault disabled for now )
+db syncfile( \ disable async file operations for now )

\ key debugging task

: toggle ( addr -- )  dup @ 0= swap ! ;








>







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
debug: unhandled( \ unhandled commands
debug: syncfile( \ synchronous file operations
debug: newvault( \ new style vault keys

-db profile( \ don't profile by default )
+db ipv6( \ ipv6 should be on by default )
+db ipv4( \ ipv4 should be on by default )
+db ipv64( \ ipv6 over 4
-db newvault( \ new vault disabled for now )
+db syncfile( \ disable async file operations for now )

\ key debugging task

: toggle ( addr -- )  dup @ 0= swap ! ;

Changes to net2o.fs.
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068

}scope

: send-dX ( addr n -- ) +sendX2
    over data-map .mapc:resend#+ set-dest#
    >send  ack@ .bandwidth+  send-data-packet ;

Defer addr>sock \ uses locals
Forward punch-reply
Forward new-addr

: send-punch ( addr u -- addr u )
    check-addr1 0= IF  2drop  EXIT  THEN
    temp-addr ret-addr $10 move
    insert-address ret-addr ins-dest







|







1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068

}scope

: send-dX ( addr n -- ) +sendX2
    over data-map .mapc:resend#+ set-dest#
    >send  ack@ .bandwidth+  send-data-packet ;

Forward addr>sock \ uses locals
Forward punch-reply
Forward new-addr

: send-punch ( addr u -- addr u )
    check-addr1 0= IF  2drop  EXIT  THEN
    temp-addr ret-addr $10 move
    insert-address ret-addr ins-dest
Changes to wiki/commands.md.
1
2
3
4
5
6
7
8
9
10
# Commands #

Version 0.9.0-20190711.

net2o separates data and commands.  Data is passed through to higher
layers, commands are interpreted when they arrive.  For connection
requests, a special bit is set, and the address then isn't used as
address, but as IV for the opportunistic encoding.

The command interpreter is a stack machine with two data types: 64


|







1
2
3
4
5
6
7
8
9
10
# Commands #

Version 0.9.0-20190801.

net2o separates data and commands.  Data is passed through to higher
layers, commands are interpreted when they arrive.  For connection
requests, a special bit is set, and the address then isn't used as
address, but as IV for the opportunistic encoding.

The command interpreter is a stack machine with two data types: 64
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
  ip port, both protocols
* $19 addr-route ( $:net2o -- )
  net2o routing part
* $1A addr-key ( $:addr -- )
  key for connection setup
* $1B addr-revoke ( $:revoke -- )
  revocation info
* $1C addr-ekey ( $:ekey timeout -- )
  ephemeral key

### dht commands ###

* $33 dht-id ( $:string -- o:o )
  set DHT id for further operations on it
* $20 dht-host+ ( $:string -- )







|







306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
  ip port, both protocols
* $19 addr-route ( $:net2o -- )
  net2o routing part
* $1A addr-key ( $:addr -- )
  key for connection setup
* $1B addr-revoke ( $:revoke -- )
  revocation info
* $1C addr-ekey ( $:ekey -- )
  ephemeral key

### dht commands ###

* $33 dht-id ( $:string -- o:o )
  set DHT id for further operations on it
* $20 dht-host+ ( $:string -- )