zerotier / zeronsd

A DNS server for ZeroTier users
https://zerotier.com
BSD 3-Clause "New" or "Revised" License
493 stars 56 forks source link

Zerotier local url CLI, env setting #207

Closed erikh closed 1 year ago

erikh commented 1 year ago

Closes #196

Be aware this is rebased against #206. Please merge that first to avoid trouble.

This implements a CLI option and environment variable for specifying the local zerotier url. Please note my aptitude for programming is significantly ... rusty (ha! I PUNNED) and that it's probably not the optimal patch. Carrying the launcher struct is probably a better long-term choice.

There are a lot of clippy warnings in the code now. I might take some time and beat some of these back, but there's also a good chance I won't expend the energy, so be aware they are there.

I hope this helps you folks on your journey.

laduke commented 1 year ago

oops. Merging #208 broke this. I'm not sure why but git is doing a bad job at rebasing this for me. Will figure it out.

laduke commented 1 year ago

I have a fixed up version here https://github.com/laduke/zeronsd/tree/tl-zerotier-url integration tests pass and a quick check of cargo run seemed ok. It wouldn't let me force push over this pr's branch.

erikh commented 1 year ago

Ok, I'll get on it, will ack when I'm done. Probably later today.

------- Original Message ------- On Wednesday, March 22nd, 2023 at 2:24 PM, Travis LaDuke @.***> wrote:

I have a fixed up version here https://github.com/laduke/zeronsd/tree/tl-zerotier-url integration tests pass and a quick check of cargo run seemed ok. It wouldn't let me force push over this pr's branch.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

erikh commented 1 year ago

I had to resolve conflicts so please let me know if I screwed something up, but it's there now.

HTH!

------- Original Message ------- On Wednesday, March 22nd, 2023 at 3:03 PM, Erik Hollensbe (OSS) @.***> wrote:

Ok, I'll get on it, will ack when I'm done. Probably later today.

------- Original Message ------- On Wednesday, March 22nd, 2023 at 2:24 PM, Travis LaDuke @.***> wrote:

I have a fixed up version here https://github.com/laduke/zeronsd/tree/tl-zerotier-url integration tests pass and a quick check of cargo run seemed ok. It wouldn't let me force push over this pr's branch.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

laduke commented 1 year ago

Awesome. Thanks! I tested it all locally.

adobito commented 6 months ago

EDIT: Looks like the container I pulled from docker hub is super old and doesn't have this.

EDIT 2: @erikh Is it trivial for you to push a new image? I don't have my env set up to build this and build my own image, and would prefer to avoid it as I just want to give zeronsd a try more than anything.

I'm trying to use this feature but it doesn't appear to be a valid parameter for me.

root@e534403a6208:/# zeronsd start --help
zeronsd-start 
Start the nameserver

USAGE:
    zeronsd start [OPTIONS] <NETWORK_ID>

ARGS:
    <NETWORK_ID>    Network ID to query

OPTIONS:
    -c, --config <PATH>                Configuration file containing these arguments (overrides most
                                       CLI options)
        --chain-cert <PATH>            
        --config-type <CONFIG_TYPE>    Configuration file format [yaml, json, toml] [default: yaml]
    -d, --domain <DOMAIN>              TLD to use for hostnames
    -f, --file <PATH>                  An additional list of hosts in /etc/hosts format
    -h, --help                         Print help information
    -l, --log-level <LEVEL>            Log Level to print [off, trace, debug, error, warn, info]
    -s, --secret <PATH>                Path to authtoken.secret (usually detected)
    -t, --token <PATH>                 Path to a file containing the ZeroTier Central token
        --tls-cert <PATH>              
        --tls-key <PATH>               
    -v                                 Verbose logging (repeat -v for more verbosity)
    -w, --wildcard                     Wildcard all names in Central to point at the respective
                                       member's IP address(es)

when I check the version, I get

root@e534403a6208:~# zeronsd -V
zeronsd 0.5.2

This version appears to be deployed after this change made it in, so I think it should be there. is there something I'm doing wrong?

erikh commented 6 months ago

I don't think a release has been cut with it in there yet.

On Wednesday, January 17th, 2024 at 1:21 PM, Jesús Luzón @.***> wrote:

I'm trying to use this feature but it doesn't appear to be a valid parameter for me.

zeronsd-start Start the nameserver

USAGE: zeronsd start [OPTIONS]

ARGS:

Network ID to query OPTIONS: -c, --config Configuration file containing these arguments (overrides most CLI options) --chain-cert --config-type Configuration file format [yaml, json, toml] [default: yaml] -d, --domain TLD to use for hostnames -f, --file An additional list of hosts in /etc/hosts format -h, --help Print help information -l, --log-level Log Level to print [off, trace, debug, error, warn, info] -s, --secret Path to authtoken.secret (usually detected) -t, --token Path to a file containing the ZeroTier Central token --tls-cert --tls-key -v Verbose logging (repeat -v for more verbosity) -w, --wildcard Wildcard all names in Central to point at the respective member's IP address(es) ``` when I check the version, I get ***@***.***:~# zeronsd -V zeronsd 0.5.2``` This version appears to be deployed after this change made it in, so I think it should be there. is there something I'm doing wrong? — Reply to this email directly, [view it on GitHub](https://github.com/zerotier/zeronsd/pull/207#issuecomment-1896781769), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAAET2ZFLLVF7B24HVJN72DYPA6GPAVCNFSM6AAAAAAVRAJHYWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJWG44DCNZWHE). You are receiving this because you authored the thread.Message ID: ***@***.***>
adobito commented 6 months ago

I don't think a release has been cut with it in there yet.

Oh that makes sense. No wonder when I checked version I thought I was at latest.

I'll see if I can a get a docker image built with latest so I can take it for a spin. I should also have a docker compose file that should be able to run zeronsd with its own copy of zerotier-cli, but sadly I'm sure I can't get it to work until I can pass the local url as an env var.

bruteForce93 commented 3 months ago

I have a fixed up version here https://github.com/laduke/zeronsd/tree/tl-zerotier-url integration tests pass and a quick check of cargo run seemed ok. It wouldn't let me force push over this pr's branch.

I have tried compiling this but bumped into some errors...

error[E0308]: ? operator has incompatible types --> src/utils.rs:69:9 69 / reqwest::Client::builder() 70 .user_agent(version()) 71 .https_only(true) 72 .default_headers(headers) 73 .build()?, _____^ expected reqwest::async_impl::client::Client, found reqwest::Client
= note: ? operator cannot convert from reqwest::Client to reqwest::async_impl::client::Client = note: reqwest::Client and reqwest::async_impl::client::Client have similar names, but are actually distinct types note: reqwest::Client is defined in crate reqwest --> /home/emini/.cargo/registry/src/index.crates.io-6f17d22bba15001f/reqwest-0.12.3/src/async_impl/client.rs:71:1 71 pub struct Client { ^^^^^^^^^^^^^^^^^ note: reqwest::async_impl::client::Client is defined in crate reqwest --> /home/emini/.cargo/registry/src/index.crates.io-6f17d22bba15001f/reqwest-0.11.27/src/async_impl/client.rs:69:1
69 pub struct Client {
^^^^^^^^^^^^^^^^^

= note: perhaps two different versions of crate reqwest are being used?

error[E0308]: ? operator has incompatible types --> src/utils.rs:194:9 194 / reqwest::Client::builder() 195 .user_agent(version()) 196 .default_headers(headers) 197 .build()?, _____^ expected reqwest::async_impl::client::Client, found reqwest::Client
= note: `?` operator cannot convert from `reqwest::Client` to `reqwest::async_impl::client::Client`
= note: `reqwest::Client` and `reqwest::async_impl::client::Client` have similar names, but are actually distinct types
note: reqwest::Client is defined in crate reqwest --> /home/emini/.cargo/registry/src/index.crates.io-6f17d22bba15001f/reqwest-0.12.3/src/async_impl/client.rs:71:1 71 pub struct Client { ^^^^^^^^^^^^^^^^^ note: reqwest::async_impl::client::Client is defined in crate reqwest --> /home/emini/.cargo/registry/src/index.crates.io-6f17d22bba15001f/reqwest-0.11.27/src/async_impl/client.rs:69:1
69 pub struct Client {
^^^^^^^^^^^^^^^^^
= note: perhaps two different versions of crate `reqwest` are being used?