Im trying to implement a simple C# application that is based on Tor protocol, without identity changes every few minutes etc. just to create a circuit and make a request. I created the onion hidden service, and I want to try make a HTTP request to it and receive an answer first. I have read all the specs, and i looked up the Tor source code, but its really hard, because it is using very low-level C. So far what I understood from the technical point of view is this, if i want to fetch the main page of my onion hidden service I have to:
- Choose a random directory server that is serving onion routers microdescriptors (there are 10 hardcoded, but 1 is serving only the bridges)
- Connect to dir server, fetch a consensus document
/tor/status-vote/current/consensus/
using HTTP protocol, close the
connection. - Parse the list of onion routers, construct the circuit from 3 nodes.
- Parse the entry node with the attributes
Fast Guard HSDir Running Stable Valid
. - Parse the exit node with the attributes
Fast Exit HSDir Running Stable Valid
. - Parse the random middle node? Is it just a OR in the list
without
Exit
orGuard
attributes? Or any OR with attributesExit
orGuard
can also be used as a middle node? - Create a TCP socket and connect to the parsed entry node with
the given IP port. Then create a cell packet with the command
CREATE
with the payload of Diffie-Hellman handshake. Receive a commandCREATED
wit the encryption key. - Form a relay cell packet with command
RELAY_EXTEND
containing the IP port of the middle node, and encrypted half handshake for the middle relay, with the key we parsed from previous action, send it to the connected entry node, receive an answer asRELAY_EXTENDED
packet, parse new encryption key from it. And use it later to encrypt last diffie hellman handshake payload. - Do the previous action, send
RELAY_EXTEND
, to the guard node, but with the address of the exit node, and encrypted diffie hellman handshake with the key we received from middle node. - I guess that is it? The circuit is ready? Now i can use a relay
cell packets,sending them to my guard node socket connection, encrypted with the key i received from exit node with
RELAY_BEGIN
to connect to hosts,RELAY_DATA
to send data to them?
Valid
flagged relays, alsoStable
flag is a preference there, but not a requirement, actually. You don't look toExit
andGuard
attributes at all: they have a different purpose and absolutely unrelated to any matter of middle nodes. So pick up a valid node, if you can't connect - in your while-cycle make a preference for aStable
flag. Feel free to ask further questions!/tor/micro/d/<descriptor id>
, which is a public key which i used to encrypt TAP handshake. I then send the cell to the node, but i do not get any answer,SSL_read
always returns 0. In the documentations there are cells that are used for initial handshake:4.1. Negotiating versions with VERSIONS cells
, so is it actually a mandatory and it needs to be done before building the curcuit?