Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
136 lines (125 sloc) 4.37 KB
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 its 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 its 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