Skip to content

Instantly share code, notes, and snippets.

@Hexagon
Created September 18, 2019 21:00
Show Gist options
  • Save Hexagon/667ce73a9ce7359c241b28ffcfd7a2f0 to your computer and use it in GitHub Desktop.
Save Hexagon/667ce73a9ce7359c241b28ffcfd7a2f0 to your computer and use it in GitHub Desktop.
Decent Network
Characteristics
Node
- Public Key
- Private Key
- Current public address (TCP Address, own if public node, closest public node if restricted node)
- UUID (UUID, constant)
If public port available, same as Private Address, else closest available public node
- Public Address Slots [10]
Slots used for opening tunnels to the closest private nodes
- CAR: Close Address Registry [1000]
Constantly maintained, if an active node closer than the farthest dead node is discovered, the farthest dead node is removed
- FAR: Friend Adress Registry [n]
Manually managed, with cache with every connected node public address
- Uplink (Transport Layer)
Continously maintained connection to farthest upstrem node in CAR
- Downlink (Transport Layer)
Continously maintained connection to farthest downstream node in CAR
Network
Transport Layer - Distributed - No encryption should be needed
Communication Layer - P2P - Public key encryption
Message
Transport Layer (Unencrypted)
A way for the message to progress through the network
Destination UUID
TTL
Payload layer (Encrypted using receiver public key)
Sender UUID
Sender signature (Signed using sender private key)
Sender Public Address (TCP)
Message Size (Int64)
Chunk Position (Int64)
Chunk Size (Int64)
Data
Transport Methods
Forward Message
If Destination is within CAR
Ping node using last known public address, if up, deliver
Deliver message to closest public node in CAR, Reduce TTL
Else
Forward message to Uplink/Downlink depending on direction, wait for acknowledgement, leave message
Negotiate Link
Recursively try farthest node to find an connectable up/downlink, when established, keep connection as long as possible
On successful negotiation, receive information on remote up/downlinks, update CAR with the info
On losing connection, renegotiate immediately
After x seconds, renegotiate in background, replace up/downlink when a new candidate is found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment