A simple onion router written in Go as a student project during the course at TUHH.
A Python version of this onion router which runs in GCloud can be found here.
It uses the Gin Web Framework for the server and clients pages.
This is my first Go project so there are highly likely unidiomatic or inefficient code fragments.
- Open up 6 terminals so each next step is done in different terminals.
- One for the (dummy) server.
- One for the client.
- One for the directory node.
- Three for the intermediate nodes.
- Start the simple server that returns random quotes. (
cd Server
andgo run .
)- The server is now up and running on
localhost:8080
, where the result of a simple request can be seen.
- The server is now up and running on
- Start the directory node. (
cd DirectoryNode
andgo run .
)- The directory node's informations can be viewed at
localhost:8888
where the registered node and the received and send connections from these nodes will be shown.
- The directory node's informations can be viewed at
- Start the three intermediate nodes in three different terminals. The port for each node has to be passed as an argument so after
cd Node
dogo run . 8000
go run . 8001
go run . 8002
- After each command the directory node should output the received node connection with the corresponding public key. Refreshing the directory nodes dashboard (
localhost:8888
) should show the three registered connections.
- Now the client can be started (
cd Client
andgo run .
). This will start a small webserver atlocalhost:9999
which shows a simple website that is able to connect to the directory node, ask it for three nodes, builds up an onion request by creating three AES keys that will be encrypted with the corresponding node's public key and sends this request then to the first node. The website includes a small animation which shows how the sending, encryption and decryption works step by step. In the end the response is shown. Note, that this response is a dummy response on the website but the servers output in the terminal shows the HTTP result that the server sent back.
A custom, very simple protocol is used between the nodes and the client to wrap up a request.
size of address | size of content | Encrypted 256 AES key | address | content
4 bytes | 4 bytes | 512 bytes | ... | ...