Closed dominictarr closed 6 years ago
Yeah, the server thing is a bit of a mis-normer. There way I have it configured on my pub is:
HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 8008 127.0.0.1:8008
HiddenServicePort 8807 127.0.0.1:8807
HiddenServiceVersion 3
For ssb-viewer and sbot. I could have multiple of those configurations if I wanted to listen to more onion addresses.
So - tor connections come in through the net server? (but client connections go out through tor plugin)
Hmm, there is code there for creating a server though... I remember looking at this when you were making the PR it seemed like it should be possible but wasn't as easy (iirc, because the tor npm modules weren't quite complete?)
Yes. We still proxy client connections through tor directly.
I'm not sure the server code makes much sense. You'd have to create the hidden service anyway, so why not just add the HiddenServicePort as well. That's also the normal way you expose things as a hidden service. It should probably just be deleted.
hmm, so i'm thinking about what we need to do to make sure that this returns the correct answer an sbot.getAddress
. It should say the port on the onion address? I figure it should say the net port? But for onion only mode, we want it to only list the onion address, and the net connection should be localhost only (and not in the address).
if you have two hidden services, do they have different addresses?
Right now I just run sbot with: sbot server --port 8008. But there is a problem with generating invites if sbot doesn't know its domain (--host). How will that work with the multiple addresses? I chose not to specify host because I also serve ssb-viewer on normal web, but otherwise I would have used --host and specify my onion addr. That way it would only accept incoming onion traffic, but there is still the --tor-only for when doing connections with other pubs. I'm actually really exciting about your proposal with multiple addresses, where one could specify and onion and a normal address, that way people can choose the security they want without compromising anything.
And yeah two hidden services would be two different addresses. But it shouldn't be that much different from the maybe more common case with serving content over both tor and normal net.
yup! but we gotta make sure that the proposed pattern works for the various usecases we already have. I think currently probably the most awkward thing is that we require more than one server - I worry that some things do not support a "port" like concept.
I think we'll need to remove --tor-only
and expand this to per protocol config.
so, net has a port, ws has a port, and tor has it's port. then we can set a host for net and host for tor.
{
"multiserver": {
"net": {port: ..., host: "localhost", scope: 'local'},
"onion": {port: ..., host: onion_address, scope: 'public'}
}
}
hmm, okay, maybe when we call getAddress()
we need to pass wether we want a public, private, or local address. The local machine can access local, private network can access private address, or public. So we shouldn't advertise our local network ip on a public address. I think it would be best to just have a flag on the config sections, because sometimes addresses that look private are actually public (cjdns!) also we should probably handle cjdns as a plugin instead of pretending it's a raw net address, which is not quite true.
If the scope is local, the server should reject connections from outside that scope - but this will work for tor, since it's proxied via another process on the same machine. though if it's on another machine on your network, could do it as scope=private.
hmm... okay so far I have been assuming that when you run two security protocols, you open two servers with on port and port+1... this would mean for tor that you have two hidden services, with the same host, but the second one is has a different port. Is this possible? or would we need to set hosts in an array? {onion: {host: [host1, host2]}}
I don't think using the same host is a privacy problem, since I presume that the actual port you are connecting too is inside SOCKS5, which is encrypted even to the last node in the tor circuit.
I think you are right about the port. We should reuse them. So if I want to run both normal and tor I would have:
{
"multiserver": {
"net": {port: 8008, host: "localhost", scope: 'public'},
"onion": {port: 8009, host: onion_address, scope: 'public'}
}
}
And then specify in my tor config that 8008 maps to 8009 internally. If I run multiple onions it would be:
{
"multiserver": {
"onion": {port: 8008, host: onion_address1, scope: 'public'},
"onion": {port: 8009, host: onion_address2, scope: 'public'}
}
}
And tor only (I agree we need to remove the hack) would simply be:
{
"multiserver": {
"onion": {port: 8008, host: onion_address1, scope: 'public'}
}
}
I'm not sure about scope. I don't think its needed actually. The great thing about the above, is that I then easily do something like this in the future:
{
"multiserver": {
"onion": {port: 8008, host: onion_address1, scope: 'public'},
"bluetooth": { scope: 'private'}
}
}
That would be a great setting for privacy minded individual on a phone. The bluetooth should of course only be enabled when in a place where one wants to exchange messages in the physical world.
Wait the double onion won't work. Maybe it needs to be an array instead:
{
"multiserver": {
"onion": [{port: 8008, host: onion_address1, scope: 'public'},
{port: 8009, host: onion_address2, scope: 'public'}]
}
}
Wait the double onion won't work.
what is the reason? - is it that tor can't accept connections to the same hidden-service on multiple ports? It seems to me this would actually break quite a few things if so, such as FTP (which has a control connection, and payload connection, a weird design but it's standard)
we need something that is simple enough that people can easily follow the instructions, and hopefully minimal configuration.
I just meant that a dictionary can't have the same key twice :)
oh right of course.
I'm still trying to figure out though: Is possible to have one hidden service, but expose more than one port over it? so bothXYZ...onion:8008
and XYZ....onion:8009
. I'm pretty sure that onion will hide what port you want to connect to, so this seems reasonable if tor was configured with more than one port open.
oh yeah, @ahdinosaur has also described a need to have a differing internal host (that you bind to) and external host (which is what you tell everyone about)
Yeah that's exactly the same thing that we need for tor.
Tor basically just wraps transporting the messages between two machines. Once it has traveled through the hoops it meets the config file:
HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 8008 127.0.0.1:8008
HiddenServicePort 8807 127.0.0.1:8807
Here you can see I map both port 8807 and 8008 to localhost. In /var/lib/tor/hidden_service/ is the key for a specific onion addr, I could have multiple if I wanted to.
right. I think this will be easiest if we have the same host with different ports - we can easily increment the port number when we create a second connection.
@arj03 is it possible to create multilpe tor hidden services via this api?
Oh, hmm - I just realized that this currently sets
server: false
which means this doesn't even create a server.... this creates the ability to use tor as a client protocol... but how do are you configuring the server?asking because I am working on a less hardcoded api for using the various network protocols.