schollz/hostyoself

Documentation bug: what is the `inputKey` field for?

daveloyall opened this issue · 2 comments

Hi again, Mark.

What is the inputKey field for?

(You can spawn multiple hosts with this key).

Ok, where do I put the input key? What does 'multiple hosts' mean here? Does that mean I can spawn up multiple copies of hostyoself that serve up the same files at the same address and are available via the same sharable URL?

@daveloyall I didn't know how to explain this easily so I left it out of the documentation.

Multiple people can host a website with the same domain name. When this happens, the relay encounters multiple sockets trying to serve data. The relay chooses a socket to request data based on the time it connected (first-come first-serve). This way, someone cannot "hijack" your domain.

I could have stopped there, but I didn't. I allowed each socket to also give the relay a secret "key". When the relay sees two sockets with the same domain and same key, then it will choose one of them randomly to serve the data.

Essentially, if you upload the same thing using the same "domain" and same "key" then you get load balancing!

Does that make sense? I thought this was a kinda cool feature (so you can serve a website from a dozen phones if you wanted!), but its sort of advanced...

It is a cool feature. Can the relay share the list of other phones with each phone?