Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncthing app doesn't resolve syncthing.localhost to localhost (unlike Chrome and Firefox) #232

Closed
lgarron opened this issue Dec 8, 2024 · 6 comments
Labels

Comments

@lgarron
Copy link

lgarron commented Dec 8, 2024

While debugging #231 I found that even though I had set my URL to https://syncthing.localhost:8384 (which I have configured with a trusted certificate), Syncthing has rewritten this to http://syncthing.localhost:8384. This seems to cause the API check to fail.

I don't think it should be rewriting the URL like that.

EDIT: see #232 (comment)

@lgarron
Copy link
Author

lgarron commented Dec 8, 2024

Hmm, looks like the code is trying to look up the scheme through

if ([keyPath isEqualToString:@"configuration.gui"]) {
if ([[[attributeDict objectForKey:@"tls"] lowercaseString] isEqualToString:@"true"]) {
_URI = @"https://";
} else {
_URI = @"http://";
}
}

I definitely have Use HTTPS for GUI configured in the web UI, and ~/Library/Application Support/Syncthing/config.xml contains <gui enabled="true" tls="true" debugging="false" sendBasicAuthPrompt="false">

So something is going wrong with this calculation.

@xor-gate
Copy link
Member

xor-gate commented Dec 8, 2024

The code is only executed first run to load settings from the XML:

if (!_syncthing.URI.length && !_syncthing.ApiKey.length) {
BOOL success = [_syncthing loadConfigurationFromXML];

@lgarron
Copy link
Author

lgarron commented Dec 8, 2024

The code is only executed first run to load settings from the XML:

The API check fails due to this issue even if the app is restarted.
Did you mean to comment on #231 ?

@lgarron
Copy link
Author

lgarron commented Dec 9, 2024

I tried debugging this in Xcode for an hour, and I still can't figure out what's causing the https:// to be dropped.

I can run the following:

defaults write com.github.xor-gate.syncthing-macosx URI -string "https://syncthing.localhost:8384"

However, this results in even more red dots in the menu, even though Syncthing is successfully running and available from the web UI:

clipboard
clipboard

@lgarron
Copy link
Author

lgarron commented Dec 9, 2024

Ah, okay, I finally figured it out.

Safari (and the underlying network library) do not let localhost be localhost. This is very unintuitive if you mostly use Chrome and Firefox.

Therefore, this requires an entry in /etc/hosts to work:

127.0.0.1 syncthing.localhost

As someone who likes to namespaces localhost servers using subdomains, I guess I can live with that. This might benefit from being documented as a caveat in Syncthing docs, but I haven't found a good place for it to send a PR.

@lgarron lgarron changed the title Preferences silently rewrite HTTPS URLs, causing API check to fail Syncthing app doesn't resolve syncthing.localhost to localhost Dec 9, 2024
@lgarron lgarron changed the title Syncthing app doesn't resolve syncthing.localhost to localhost Syncthing app doesn't resolve syncthing.localhost to localhost (unlike Chrome and Firefox) Dec 9, 2024
@xor-gate
Copy link
Member

Thanks for reporting, but as you are doing non-standard things which are not supported in macOS by default. I will close this. Syncthing.app should be simple, and having this domain name for localhost service and localhost https is not the default setup. Most of the time people know then what they are doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants