Feature request (dns): "subdomain" support #213

Open
opened 2025-05-22 20:21:02 +00:00 by jfly · 1 comment

I've been trying out data-mesher's dns support, and it's super cool! I love being able to add services to a node, and give it a nice human readable name. For example:

machines/node1/configuration.nix:

networking = {
  hostName = "node1";
  domain = "tld";
};

services.data-mesher.settings.host.names = [ "immich" ];
services.nginx.virtualHosts."immich.tld" = {
   # proxy pass here, etc
};

This works great for services where I don't care which machine it's hosted on. However, there are some services (like syncthing) which I run on many machines, and want easy access to each syncthing instance. Concretely, imagine something like this:

  • node1.tld runs syncthing.
  • node2.tld also runs syncthing.

I would like to be able to access these at st.node1.tld and st.node2.tld. I could see this just being the default behavior: i.e.: *.node1.tld resolves to node1.tld with no additional config, or we let people configure it*.

*I can't do this right now because data-mesher has this strict NameRegex that doesn't allow for dots.

Implementation ideas

I'm open to sending a PR for this if you want. A few ideas:

  1. Relax this NameRegex to allow for dots. Out of curiosity, I tried this and things just worked, but perhaps the strict regex is intentional?
    • Pro: allows people to opt into this behavior
    • Con: this allows nodes to spoof other nodes. For example, node1.tld could claim foo.node2.tld. I imagine this is solvable with more code somewhere, but I'd need a pointer in the right direction.
  2. Change nss-datamesher to resolve *.hostname.tld to hostname.tld. That looks like a straightforward change here: https://git.clan.lol/clan/data-mesher/src/branch/main/nss-datamesher/src/lib.rs#L125.
    • Pro: this would not allow nodes to spoof other nodes
    • Con: this behavior occurs unconditionally, which some folks might not want? Seems fine to me, personally.
I've been trying out data-mesher's dns support, and it's super cool! I love being able to add services to a node, and give it a nice human readable name. For example: `machines/node1/configuration.nix`: ```nix networking = { hostName = "node1"; domain = "tld"; }; services.data-mesher.settings.host.names = [ "immich" ]; services.nginx.virtualHosts."immich.tld" = { # proxy pass here, etc }; ``` This works great for services where I don't care which machine it's hosted on. However, there are some services (like syncthing) which I run on many machines, and want easy access to each syncthing instance. Concretely, imagine something like this: - `node1.tld` runs syncthing. - `node2.tld` also runs syncthing. I would like to be able to access these at `st.node1.tld` and `st.node2.tld`. I could see this just being the default behavior: i.e.: `*.node1.tld` resolves to `node1.tld` with no additional config, or we let people configure it*. *I can't do this right now because data-mesher has [this strict `NameRegex` that doesn't allow for dots](https://git.clan.lol/clan/data-mesher/src/commit/54989ab33b3b5ff5e21e89ce11f0b72b3979ffd6/data-mesher/pkg/config/host.go#L12). ## Implementation ideas I'm open to sending a PR for this if you want. A few ideas: 1. Relax [this `NameRegex`](https://git.clan.lol/clan/data-mesher/src/commit/54989ab33b3b5ff5e21e89ce11f0b72b3979ffd6/data-mesher/pkg/config/host.go#L12) to allow for dots. Out of curiosity, I tried [this](https://git.clan.lol/jfly/data-mesher/commit/065398b48dfb704d2998837b07c9ad804730f1ff) and things just worked, but perhaps the strict regex is intentional? - Pro: allows people to opt into this behavior - Con: this allows nodes to spoof other nodes. For example, `node1.tld` could claim `foo.node2.tld`. I imagine this is solvable with more code somewhere, but I'd need a pointer in the right direction. 2. Change `nss-datamesher` to resolve `*.hostname.tld` to `hostname.tld`. That looks like a straightforward change here: https://git.clan.lol/clan/data-mesher/src/branch/main/nss-datamesher/src/lib.rs#L125. - Pro: this would not allow nodes to spoof other nodes - Con: this behavior occurs unconditionally, which some folks might not want? Seems fine to me, personally.
Member

One approach would be to allow claiming a subdomain if you already have a claim on the parent.

An instance could claim for example ['saturn.sol', 'titan.saturn.sol', 'dione.saturn.sol']. Then when we are resolving DNS from host claims we will allow titan and dione only if the instance has already acquired the claim on saturn.sol.

We have to model it like this for the future scenario where we bring two clans together, and there could be overlapping host claims between two disjoint data-mesher clusters.

Needs more thought though.

One approach would be to allow claiming a subdomain if you already have a claim on the parent. An instance could claim for example `['saturn.sol', 'titan.saturn.sol', 'dione.saturn.sol']`. Then when we are resolving DNS from host claims we will allow `titan` and `dione` only if the instance has already acquired the claim on `saturn.sol`. We have to model it like this for the future scenario where we bring two clans together, and there could be overlapping host claims between two disjoint data-mesher clusters. Needs more thought though.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: clan/data-mesher#213