keepassxreboot / keepassxc

KeePassXC is a cross-platform community-driven port of the Windows application “Keepass Password Safe”.
https://keepassxc.org/
Other
21.39k stars 1.48k forks source link

Show current reported hostname somewhere #11451

Closed liayn closed 1 week ago

liayn commented 1 week ago

Summary

Using the AutoOpen Feature in combination with the IfDevice attribute one needs to know the hostname. Whilst this is pretty easy on Windows and Linux, I'm failing to find the right hostname on MacOS though. (I find the hostname, but it is not recognized obviously by KeepassXC.)

It would be handy to have the expected hostname displayed somewhere.

Context

Technically speaking, I need the info QHostInfo::localHostName(); returns. :-) https://github.com/keepassxreboot/keepassxc/blob/d03ffc228ca56a0a4418a1e8ef1998e538118efc/src/gui/DatabaseWidget.cpp#L2563

droidmonkey commented 1 week ago

Hello, your computer's hostname is shown using the terminal command hostname. I confirmed it is the same as what is returned by QHostInfo::localHostName()

liayn commented 1 week ago

Thanks for your reply.

Hello, your computer's hostname is shown using the terminal command hostname. I confirmed it is the same as what is returned by QHostInfo::localHostName()

Turns out... the hostname changes depending on the network I'm connected with. Seems to be a common Mac issue. (once it was <computer-name>.local, then it is Mac.lan, ...) That explains a lot and of course means that I can't use this nice KeepassXC feature in a sensible manner.

droidmonkey commented 1 week ago

Easily done:

Enter hostnames in a comma separated list to define computers that will open this database.

https://keepassxc.org/docs/KeePassXC_UserGuide#_automatic_database_opening

liayn commented 1 week ago

Easily done:

Enter hostnames in a comma separated list to define computers that will open this database.

https://keepassxc.org/docs/KeePassXC_UserGuide#_automatic_database_opening

I'm aware, I'm using this already in some cases.

But as you can see above the hostname Mac.lan actually includes the local DNS suffix .lan. This is different most likely for every network. You may of course include the "usual ones" you are using, but it will fail on public WiFi probably and guest networks. As long as it's using the mDNS suffix .local, it seems to use the defined computer name together with this suffix, unless the DHCP also sends suggested hostnames, which "wins" then (at least according to my observation so far).

droidmonkey commented 1 week ago

You'll have to consult macos documentation. From my read there is only .local and any defined dns suffix such as .lan.