forked from quartzjer/TeleHash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.txt
135 lines (125 loc) · 4.38 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
no pings! always send .see of ones near a writer and .to of id near you (who they would have to .see back from)
anytime any packet comes in check to see if we want to bucket the sender (if they're close to us), if so open a line to them
always just ignore telexes if to throttle back
"open line"
dial yourself via the recipient
they'll respond with a .see (and _line)
unless they're the closest to you, then they /should/ open a line back to place in their own bucket
if they have an open line to you, you're the closest to yourself, they'll .see yourself to you
client model thoughts
three layers
wire
json, line validation, timeouts
calls out to any processing filters
filters
checks all telexes to match filters to callbacks
bucket
responds to any end
self seeding and maintenance of buckets
hist
.hist command, keeps cache of history
forwards
.fwd command, sets up filters and relays
app interface
send telexes
register related filters for answers/timeouts
telex_send(..., callback, expiration)
if no response from other writer by expiration then callback will fire too
depending on the type of telex, wire layer will build a filter to catch responses
.end looks for *any* .see's until expire
.fwd looks for *any* matching signals until (optional) .fwds is empty or expire
.hist looks for *any* matching signals until expire
line events
register to receive any line creation, coming expiration, or deletion event
common utility patterns
centralized signing (rsa?) for announcing self to trusted peers
configured shared authority, probably app-defined or selectable
custom protocol to authority to authenticate app on initialization (http or th)
have announcement signal signed by authority
dial the hash(es) that peers would be listening on sending your identifying signal and it's sig
"itsme"="1.2.3.4:5678"
"itsme-sig"="60AD5A78..."
self-signed (trust is discovered and then remembered, like ssh/otr)
sign announcements
custom protocol to return your public key on demand
when an announcement happens from someone new, ask them for the pubkey and check to see if they're known/validated
dogfooding
chat/list, called "what"
use simple rsa, openssl?
gen or use config'd private key
have a dedicated thapp that takes a signed what announcement (name+url+ipp), signs it back
manually approve any new sigs first time, then auto-sign
"what" client announces using that sig and their own sig so they are whitelisted
any messages are normal signals signed by each client
data structure thoughts
two root lists
writers
hashtable by cb as the key
each one contains details about a writer and it's last known state
hashes
hashtable by sha1 hash as the key
contains what we know about this hash
popularity
signal stats
recent telexes
any fwds we have for it
secondary indexes
buckets
binary distance from self (159 of them)
each contains a list of writers by cb
active
any writer we've gotten a packet from in the last X minutes
used only for finding closer writers to recommend
158 buckets, a fixed array
each entry is also an array of writers
writer
ip:port/hash
last sent
fail (incremented by eviction/nat loops)
last seen (always set fail=0 when updated)
first seen
line/pin
possibly nat'd, only set when a .nat was what created the writer (first telex)
referrer (so we can .nat them if needed)
fwd state
nat'd
every X min (5?) walk array
if last seen > 5, dial self via them (so they .see us back)
forwards
array of writers that we have active forwards for
every X min, refresh
if any become stale, re-dial for closer
selection
get bucket (distance from self)
sort by distance from .to
select last seen <5min
select first seen oldest
and/or with a _line?
eviction
if more than X in bucket
send a .to=self empty telex if last seen > X, increment fail
any last sent - last seen > X and fail > Y
any missing _pin (never got packets back)
finally, youngest (but older than 60s or so, might be mid-dial?)
incoming
--------
switch as a localhost server on 127.0.0.1:xxxxx port
tapping
active or one-time
explicit or automatic
dialing
stream or timer
signals in
only if tap'd?
signals out
only if recipient?
plain js in
plain js out (recipient req)
s-core
-dial=5
-tap=id track sigs
-ipp -nat
-new
-line=true/false request and status
-lend=end for line
-retry=3