Check-in [9277fd8b03]
Not logged in

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

Overview
Comment:Bump version number
Timelines: family | ancestors | descendants | both | trunk | 0.9.1-20191010
Files: files | file ages | folders
SHA1: 9277fd8b03a64bcfc6e40298aa53085fbe3ac89a
User & Date: bernd 2019-10-10 17:45:02.578
Context
2019-10-11
20:07
Send first packet to open DHT both to IPv4 and IPv6 check-in: 127dfc04ac user: bernd tags: trunk
2019-10-10
17:45
Bump version number check-in: 9277fd8b03 user: bernd tags: trunk, 0.9.1-20191010
2019-10-09
22:31
Some refactoring check-in: c62870935b user: bernd tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to addr.fs.
60
61
62
63
64
65
66
67
68
69
70


71
72
73
74
75
76
77
78

in net2o : new-addr ( -- o )
    address-class new >o  address-table @ token-table ! o o> ;
in net2o : dispose-addr ( o:addr -- o:addr )
    host:id $free host:anchor $free host:route $free  host:revoke $free
    host:key sec-free  host:ekey sec-free
    dispose ;
in net2o : dispose-punchs ( -- )
    punch-addrs [: .net2o:dispose-addr ;] $[]o-map
    punch-addrs $free ;
:noname ( -- )


    net2o:dispose-punchs  defers extra-dispose ; is extra-dispose

: new-addr ( addr u -- o ) \G create a new address object from string
    net2o:new-addr n:>o nest-cmd-loop o n:o> ;

also net2o-base
: o-genaddr ( o -- ) >o \G create new address string from object
    host:pri# @ ulit, addr-pri#







|
|
|

>
>
|







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

in net2o : new-addr ( -- o )
    address-class new >o  address-table @ token-table ! o o> ;
in net2o : dispose-addr ( o:addr -- o:addr )
    host:id $free host:anchor $free host:route $free  host:revoke $free
    host:key sec-free  host:ekey sec-free
    dispose ;
in net2o : dispose-addrs ( addr -- )
    dup >r [: .net2o:dispose-addr ;] $[]o-map
    r> $free ;
:noname ( -- )
    dest-addrs  net2o:dispose-addrs
    punch-addrs net2o:dispose-addrs
    defers extra-dispose ; is extra-dispose

: new-addr ( addr u -- o ) \G create a new address object from string
    net2o:new-addr n:>o nest-cmd-loop o n:o> ;

also net2o-base
: o-genaddr ( o -- ) >o \G create new address string from object
    host:pri# @ ulit, addr-pri#
Changes to classes.fs.
233
234
235
236
237
238
239

240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262


263
264
265
266
267
268
269
enum pend#
enum qr#
drop
}scope

cmd-class class
    \ callbacks

    defer: timeout-xt    \ callback for timeout
    defer: setip-xt      \ callback for set-ip
    defer: ack-xt        \ callback for acknowledge
    defer: punch-done-xt \ callback for NAT traversal ok
    defer: sync-done-xt  \ callback for sync done
    defer: sync-none-xt  \ callback for sync not needed
    \ maps for data and code transfer
    0 +field start-maps
    value: code-map
    value: code-rmap
    value: data-map
    value: data-rmap
    0 +field end-maps
    \ strings
    0 +field start-strings
    field: resend0
    field: data-resend
    field: pubkey        \ other side official pubkey
    field: punch-addrs
    field: rqd-xts       \ callbacks for request done (array)
    field: my-error-id
    field: beacon-hash
    0 +field end-strings


    field: request-gen   \ pre-generated request number
    field: perm-mask
    \ secrets
    0 +field start-secrets
    field: crypto-key
    field: dest-0key     \ key for stateless connections
    0 +field end-secrets







>


















<




>
>







233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258

259
260
261
262
263
264
265
266
267
268
269
270
271
enum pend#
enum qr#
drop
}scope

cmd-class class
    \ callbacks
    defer: send0-xt      \ send out a stateless packet
    defer: timeout-xt    \ callback for timeout
    defer: setip-xt      \ callback for set-ip
    defer: ack-xt        \ callback for acknowledge
    defer: punch-done-xt \ callback for NAT traversal ok
    defer: sync-done-xt  \ callback for sync done
    defer: sync-none-xt  \ callback for sync not needed
    \ maps for data and code transfer
    0 +field start-maps
    value: code-map
    value: code-rmap
    value: data-map
    value: data-rmap
    0 +field end-maps
    \ strings
    0 +field start-strings
    field: resend0
    field: data-resend
    field: pubkey        \ other side official pubkey

    field: rqd-xts       \ callbacks for request done (array)
    field: my-error-id
    field: beacon-hash
    0 +field end-strings
    field: dest-addrs    \ list of destinations
    field: punch-addrs   \ list of punch destinations
    field: request-gen   \ pre-generated request number
    field: perm-mask
    \ secrets
    0 +field start-secrets
    field: crypto-key
    field: dest-0key     \ key for stateless connections
    0 +field end-secrets
Changes to configure.ac.
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

AC_INIT([net2o], [0.9.1-20191003], [bernd@net2o.de], [net2o], [https://fossil.net2o.de/net2o/reportlist])
AC_PREREQ([2.59])
AC_CONFIG_MACRO_DIR([m4])
AC_USE_SYSTEM_EXTENSIONS
LT_INIT

AC_MSG_CHECKING([for gforth])








|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

AC_INIT([net2o], [0.9.1-20191010], [bernd@net2o.de], [net2o], [https://fossil.net2o.de/net2o/reportlist])
AC_PREREQ([2.59])
AC_CONFIG_MACRO_DIR([m4])
AC_USE_SYSTEM_EXTENSIONS
LT_INIT

AC_MSG_CHECKING([for gforth])

Changes to connect.fs.
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
\ GNU Affero General Public License for more details.

\ You should have received a copy of the GNU Affero General Public License
\ along with this program.  If not, see <http://www.gnu.org/licenses/>.

Forward >invitations
in net2o Forward dispose-punchs
Forward mynick$
Forward invite-me
Forward qr-invite-me
Defer <invite-result>

scope{ net2o-base
\ nat traversal functions







|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
\ GNU Affero General Public License for more details.

\ You should have received a copy of the GNU Affero General Public License
\ along with this program.  If not, see <http://www.gnu.org/licenses/>.

Forward >invitations
in net2o Forward dispose-addrs
Forward mynick$
Forward invite-me
Forward qr-invite-me
Defer <invite-result>

scope{ net2o-base
\ nat traversal functions
49
50
51
52
53
54
55
56
57

58
59
60
61
62
63
64
    ELSE  64drop
	<err> ." cookie: no owncrypt, un-cmd" <default> forth:cr
    THEN
    un-cmd ;
+net2o: punch-load, ( $:string -- ) \g use for punch payload: nest it
    $> $, nest  o IF
	nat( ." punch from: " return-address .addr-path forth:cr )
	['] punchs code-reply is send-xt  THEN
    net2o:dispose-punchs ;

+net2o: punch ( $:string -- ) \g punch NAT traversal hole
    $> nat( ." punch to: " 2dup .addr$ forth:cr ) net2o:punch ;
+net2o: punch-done ( -- ) \g punch received
    o 0<> own-crypt? and IF
	o-beacon ret+beacon
	nat( ticks .ticks ."  punch done: " return-address .addr-path forth:cr )
    ELSE







|
|
>







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    ELSE  64drop
	<err> ." cookie: no owncrypt, un-cmd" <default> forth:cr
    THEN
    un-cmd ;
+net2o: punch-load, ( $:string -- ) \g use for punch payload: nest it
    $> $, nest  o IF
	nat( ." punch from: " return-address .addr-path forth:cr )
	['] punchs code-reply is send-xt
	punch-addrs net2o:dispose-addrs \ first punch load: empty addresses
    THEN ;
+net2o: punch ( $:string -- ) \g punch NAT traversal hole
    $> nat( ." punch to: " 2dup .addr$ forth:cr ) net2o:punch ;
+net2o: punch-done ( -- ) \g punch received
    o 0<> own-crypt? and IF
	o-beacon ret+beacon
	nat( ticks .ticks ."  punch done: " return-address .addr-path forth:cr )
    ELSE
Changes to do.
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash

echo "This script builds net2o from scratch"

GFORTH=gforth-0.7.9_20191003

if [ "$(uname -o)" = "Cygwin" ]
then
    CONFOPT="--prefix=/usr $*"
else
    CONFOPT="$*"
fi




|







1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash

echo "This script builds net2o from scratch"

GFORTH=gforth-0.7.9_20191010

if [ "$(uname -o)" = "Cygwin" ]
then
    CONFOPT="--prefix=/usr $*"
else
    CONFOPT="$*"
fi
Changes to helper.fs.
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71









72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88


89
90
91
92
93
94
95
96
    lastaddr# 0<> to online?
    ind-addr off  !0key ;

: dhtroot-off ( --- )
    dhtroot-addr$ $off
    dhtroot-addr @ ?dup-IF  net2o:dispose-addr  THEN ;

: ins-ip ( -- net2oaddr )
    net2o-host $@ net2o-port insert-ip  ind-addr off ;
: ins-ip4 ( -- net2oaddr )
    net2o-host $@ net2o-port insert-ip4 ind-addr off ;
: ins-ip6 ( -- net2oaddr )
    net2o-host $@ net2o-port insert-ip6 ind-addr off ;

: pk:connect ( code data key u -- )
    connect( [: .time ." Connect to: " dup hex. cr ;] $err )
    net2o:new-context >o rdrop o to connection  setup!
    dest-pk \ set our destination key
    +resend-cmd net2o:connect









    +flow-control +resend
    connect( [: .time ." Connected, o=" o hex. cr ;] $err ) ;

Forward renat-all

event: :>renat ( -- )  renat-all ;
event: :>disconnect ( addr -- )  .disconnect-me ;
: dht-beacon ( addr u -- )
    <event :>renat main-up@ event> 2drop ;

: +dht-beacon ( -- )
    beacons# @ 0= IF  ret-addr be@ ['] dht-beacon 0 .add-beacon  THEN ;

: dht-connect ( -- )
    dht-connection ?dup-IF  >o o to connection rdrop  EXIT  THEN
    tick-adjust 64@ 64-0= IF  +get-time  THEN
    $8 $8 dhtnick $@ nick>pk dhtroot


    online? IF  +dht-beacon pk:connect  o to dht-connection
    ELSE  2drop 2drop  THEN ;
: dht-disconnect ( -- )
    0 addr dht-connection !@ ?dup-IF
	>o o to connection disconnect-me 0 to connection o>  THEN ;

Variable announced
: subme ( -- )  announced @ IF







<
<
<
<
<
<
<





>
>
>
>
>
>
>
>
>

















>
>
|







53
54
55
56
57
58
59







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
    lastaddr# 0<> to online?
    ind-addr off  !0key ;

: dhtroot-off ( --- )
    dhtroot-addr$ $off
    dhtroot-addr @ ?dup-IF  net2o:dispose-addr  THEN ;








: pk:connect ( code data key u -- )
    connect( [: .time ." Connect to: " dup hex. cr ;] $err )
    net2o:new-context >o rdrop o to connection  setup!
    dest-pk \ set our destination key
    +resend-cmd net2o:connect
    +flow-control +resend
    connect( [: .time ." Connected, o=" o hex. cr ;] $err ) ;

: pk-addr:connect ( code data key u addr -- )
    connect( [: .time ." Connect to: " dup hex. cr ;] $err )
    net2o:new-context >o rdrop o to connection  setup!
    ['] dests is send0-xt  dest-addrs >stack
    dest-pk \ set our destination key
    +resend-cmd net2o:connect
    +flow-control +resend
    connect( [: .time ." Connected, o=" o hex. cr ;] $err ) ;

Forward renat-all

event: :>renat ( -- )  renat-all ;
event: :>disconnect ( addr -- )  .disconnect-me ;
: dht-beacon ( addr u -- )
    <event :>renat main-up@ event> 2drop ;

: +dht-beacon ( -- )
    beacons# @ 0= IF  ret-addr be@ ['] dht-beacon 0 .add-beacon  THEN ;

: dht-connect ( -- )
    dht-connection ?dup-IF  >o o to connection rdrop  EXIT  THEN
    tick-adjust 64@ 64-0= IF  +get-time  THEN
    $8 $8 dhtnick $@ nick>pk dhtroot
    online? IF
	+dht-beacon
	dhtroot-addr@ pk-addr:connect  o to dht-connection
    ELSE  2drop 2drop  THEN ;
: dht-disconnect ( -- )
    0 addr dht-connection !@ ?dup-IF
	>o o to connection disconnect-me 0 to connection o>  THEN ;

Variable announced
: subme ( -- )  announced @ IF
Changes to net2o.fs.
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091




1092
1093
1094
1095
1096
1097
1098
1099
	new-addr punch-addrs >stack
    ELSE  2drop  THEN ;

: punch-wrap ( xt -- )
    return-address { ret[ $10 ] }  catch
    ret[ return-address $10 move  throw ;

: punch-loop ( xt -- )
    [{: xt :}l punch-addrs $@ bounds ?DO
	    I @ xt addr>sock
	cell +LOOP ;] punch-wrap ;

: pings ( o:connection -- )
    \G ping all addresses (why except the first one?)
    ['] ping-addr1 punch-loop ;

: punchs ( addr u o:connection -- )
    \G send a reply to all addresses




    ['] send-punch punch-loop ;

\ send chunk

\ branchless version using floating point

: send-size ( u -- n )
    min-size umax maxdata umin 1-







|
|





|



>
>
>
>
|







1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
	new-addr punch-addrs >stack
    ELSE  2drop  THEN ;

: punch-wrap ( xt -- )
    return-address { ret[ $10 ] }  catch
    ret[ return-address $10 move  throw ;

: addrs-loop ( addrs xt -- )
    [{: addrs xt :}l addrs $@ bounds ?DO
	    I @ xt addr>sock
	cell +LOOP ;] punch-wrap ;

: pings ( o:connection -- )
    \G ping all addresses (why except the first one?)
    punch-addrs ['] ping-addr1 addrs-loop ;

: punchs ( addr u o:connection -- )
    \G send a reply to all addresses
    punch-addrs ['] send-punch addrs-loop 2drop ;

: dests ( addr u o:connection -- )
    \G send a reply to all addresses
    dest-addrs ['] send-punch addrs-loop 2drop ;

\ send chunk

\ branchless version using floating point

: send-size ( u -- n )
    min-size umax maxdata umin 1-
Changes to wiki/commands.md.
1
2
3
4
5
6
7
8
9
10
# Commands #

Version 0.9.1-20191003.

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.1-20191010.

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