-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Hi there! First, thanks for croc
, I use it all the time.
A while back, I had added support for discovering a relay via mDNS.
I was thinking, I could clean it up and send you a PR, but I wanted to make sure that this would be something that you'd be interested in first.
The way it works is that you'd announce a croc relay as available with your favorite mDNS server (something like this for Avahi):
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name>croc relay</name>
<service>
<type>_croc._tcp</type>
<port>9009</port>
<txt-record>description=croc relay service</txt-record>
<txt-record>version=10.2.2-g12345</txt-record>
<txt-record>ip=1.2.3.4:8888</txt-record>
</service>
</service-group>
Let's say that this is announcing from my router, at 192.168.1.1:9009. I'd do a croc send file
, and croc
would automatically use the discovered relay (192.168.1.1:9009
, but tell the user to use the IP from the txt-record, like:
Sending 'file' (666 MB)
Code is: 3518-enrico-couple-brandy
On the other computer run
croc --relay 1.2.3.4:8888 3518-enrico-couple-brandy
This solves the problem I had of having different aliases for croc (or not using my aliases so it ended up just using your relay). It should also make it easier for others run and use their own relays. If this is something desirable, I'd have to re-do the support and also clean things up.
I'll leave it up to you to decide if you want this kind of thing, and if so:
- should
croc
use a discovered relay by default (it adds a short bit of time to starting up) or should the user need to specify an option (or possibly an environment variable)? - how do you want to handle the case of multiple relays being broadcast?
- should the user be able to select them, and if so, whats the UI for that? (Currently, my implementation was naive and picked the first one it found.)
- OPTIONAL, but nice to have:
croc relay
probably should have builtin support for advertising via mdns, so users don't have to mess with Avahai.- For that to work right,
croc relay
would need support discovery of its own external IP somehow. So for that you'd probably need to query an external service like https://api.ipify.org/ or https://icanhazip.com/ or something. How do you handle finding multiple IPs, etc? Like I said, this can be optional.
- For that to work right,
Anyway, let me know what you think!
FYI my implementation used https://github.com/grandcat/zeroconf which seems dead. I used this only because go-chromecast
uses it. I think a rewrite would be using https://github.com/hashicorp/mdns, but I'm open to any suggestions.