On 2 Aug 2016, at 23:37, Nick Mathewson nickm@torproject.org wrote:
Hi, all!
I've seen a couple of emails from people looking into new ways to do naming for onion services. That's great! Before anybody gets too far, I'd like to send this quick note to let you know that integrating stuff like this into Tor is actually easier than you think.
Here's how you do it, using a Tor controller. (See control-spec.txt for protocol documentation. Also see one of the several friendly libraries, like steam, that exist to interface with Tor over this protocol.)
First, you set the Tor option "__LeaveStreamsUnattached". This tells Tor that it shouldn't try to handle new client requests immediately, but it should instead let the controller take responsibility.
In the controller, you make sure that you are watching STREAM events so that you find out about new streams.
Whenever there's a new stream, you check its address. If the address is one that you don't want to rewrite, you just call ATTACHSTREAM on it, with a circuit ID of 0. (The 0 means "Tor, you figure out how to attach this one.".
Otherwise, you do whatever magic dance you do in order to find out the real address for the stream.
If the lookup operation is successful, you say "REDIRECTSTREAM (stream ID) (new address". And then you ATTACHSTREAM as above.
If the lookup operation fails, you call "CLOSESTREAM (stream ID) 2". (The 2 means "resolve failed".
And that's it for the Tor integration! All you need to do now is figure out how the name lookup works.
Has someone put together an example resolver that just does simple extension substitution? It would amuse me to be able to visit 3g2upl4pq6kufc4m.chive, or 3g2upl4pq6kufc4m.allium.
Tim
Tim Wilson-Brown (teor)
teor2345 at gmail dot com PGP C855 6CED 5D90 A0C5 29F6 4D43 450C BA7F 968F 094B ricochet:ekmygaiu4rzgsk6n xmmp: teor at torproject dot org