Skip to content
New issue

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

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

Already on GitHub? # to your account

Add option to prefer --agentName over hostname when syncing name to server #6808

Open
redneck-f25 opened this issue Feb 25, 2025 · 7 comments · May be fixed by #6809 or #6828
Open

Add option to prefer --agentName over hostname when syncing name to server #6808

redneck-f25 opened this issue Feb 25, 2025 · 7 comments · May be fixed by #6809 or #6828
Assignees

Comments

@redneck-f25
Copy link
Contributor

Is your feature request related to a problem? Please describe.
On embedded devices in our network the configured agent name (--agentName) changes on outer conditions while the hostname itself does not change. So we need have an option to prefer the agent name (if given as argument) over the hostname.

In this context it would also be nice to opt-in to be able to change the name an the server until then next connection. This makes ist easier to track changes while commissioning.

Describe the solution you'd like
See pull request and the Screenshot below.

Describe alternatives you've considered
We could use a plugin to detect the circumstance and drop the records from the DB and let the device reconnect.

Additional context
Image

@redneck-f25 redneck-f25 changed the title Add option to prefer --agentName over hostname when syncing name to Add option to prefer --agentName over hostname when syncing name to server Feb 25, 2025
@si458
Copy link
Collaborator

si458 commented Feb 25, 2025

in theory you can set agentName=mynamehere inside the .msh file,
then when you connect it uses the agentName
but from checking, it only uses this name when it first connects to the server and the device doesn exist
not every time the server.app is run, even tho it should sync it?
going to look into it

@si458
Copy link
Collaborator

si458 commented Feb 25, 2025

@redneck-f25 ok have checked, it does seem to only use that value on first launch/install,
never every restart of the service!
so your PR will indeed fix it i believe
also you forgot to edit default3.handlebars which is the new UI (HINT: ?sitestyle=3)
i can sort out translations etc for you if you can do the PR 👍

@si458 si458 self-assigned this Feb 25, 2025
@redneck-f25
Copy link
Contributor Author

@si458 thanks for the check. i haven't forgotten. i just did not. in the PR comment i mentioned i will do :-).

Please could you double-check that mesh flags 8 an 16 are not uses right now.

Another reason for --agentName is, that even this year Windows and applications and services running on it (e.g. Mark Russinovich's psexec) have problems with (tcp-/dns-)hostnames longer than the NetBIOS-ComputerName limit (something like 15 or 16 octets).

@redneck-f25
Copy link
Contributor Author

Image

Image

@redneck-f25
Copy link
Contributor Author

@si458 got in touch with translation tool, attached another PR to this issue
@Ylianst thanks for MeshCentral and for including the batteries

Steps:

  • cd translate
  • node translate.js extractall translate.json
  • https://meshcentral.example.org/translator.htm
  • [Save to Server (F3)]
  • node translate.js merge ../../meshcentral-data/translate.json translate.json de
  • node translate.js extractall translate.json
  • rm ../../meshcentral-data/translate.json

concerning changes:

+++ translate/translate.json
@ 10226
+    {
+      "en": "Allow to override server device name until next connection",
+      "de": "Erlaube das Überschreiben des Server-Gerätenames bis zur nächsten Verbindung",
+      "xloc": [
+        "default.handlebars->47->2334",
+        "default3.handlebars->35->2330"
+      ]
+    },
@ 63053
+    {
+      "en": "prefer --agentname",
+      "de": "bevorzuge --agentName",
+      "xloc": [
+        "default.handlebars->47->2187",
+        "default3.handlebars->35->2182"
+      ]
+    },
@ 94197
+    {
+      "en": "allow override",
+      "de": "erlaube Überschreiben",
+      "xloc": [
+        "default.handlebars->47->2188",
+        "default3.handlebars->35->2183"
+      ]
+    },
@ 96329
+    {
+      "en": "Prefer value of --agentName",
+      "de": "Bevorzuge Wert von --agentName",
+      "xloc": [
+        "default.handlebars->47->2333",
+        "default3.handlebars->35->2329"
+      ]
+    },

@redneck-f25
Copy link
Contributor Author

@si458 what do you think about this issue and the PRs?

It's a hassle to always stash and merge on vendor-updates :-). so i build a plugin, which resolves my needs: MeshCentral-Agentname2Servername (see the Bugs section). I would prefer to have this merged into the core. If you don't have the time for this (i.e. translations) we might close this issue and the PRs to get it out of our mind.

Another word about debugging: The plugin depends on the MeshCentral-PluginHookScheduler which has a companion MeshCentral-PluginHookExample to explain the usage. Maybe it can support you and other contributors while debugging and improving (as the two console.log()-lines some days ago). I guess, with this plugin we can keep the debug code almost outside of the worktree.

WIP

@si458
Copy link
Collaborator

si458 commented Mar 10, 2025

@redneck-f25 sorry mad a mad weekend. I will try to have a look on Wednesday on my development machine and see how it goes and come back to you!

# for free to join this conversation on GitHub. Already have an account? # to comment