mwarning / zerotier-openwrt

A OpenWrt package for ZeroTier One - Pull requests are welcome!
695 stars 146 forks source link

Improve ZT config file #72

Closed ogarcia closed 4 years ago

ogarcia commented 4 years ago

To avoid discuss over commits, better use this issue. Related to https://github.com/zerotier/ZeroTierOne/issues/1240

Current status

Current config file have the following options:

config zerotier sample_config
    option enabled 0
    option port '9993' # ZT UDP listen port
    option config_path '/etc/zerotier' # persistent configuration folder (for ZT controller mode)
    option local_conf '/etc/zerotier.conf' # path to the local.conf
    option secret '' # Generate secret on first start
    list join '8056c2e21c000001' # Join a public network called Earth

Proposal

Instead of use a list of networks use a list of configs to have named networks and can use commands join and leave

config zerotier
    option enabled 0 # Enable or disable full service at startup
    option port '9993' # ZT UDP listen port
    option config_path '/etc/zerotier' # persistent configuration folder (for ZT controller mode)
    option local_conf '/etc/zerotier.conf' # path to the local.conf
    option secret '' # Take note that you have only one secret that identifies the client

config network 'earth'
    option enabled 0 # Enable or disable this config at startup
    option id '8056c2e21c000001'

config network 'mynetwork'
    option enabled 0 # Enable or disable this config at startup
    option id '8056c2e21c000011'

Benefits of proposal

Proposal problems

ogarcia commented 4 years ago

IMHO. I would not implement this change. There is a simple workaround to see networks IDs:

# uci show zerotier
zerotier.mybeautifulnetwork=zerotier
zerotier.mybeautifulnetwork.enabled='1'
zerotier.mybeautifulnetwork.config_path='/etc/zerotier'
zerotier.mybeautifulnetwork.join='8056c2e21c000011'
zerotier.mybeautifulnetwork.secret='XXXXXXX'

Or if you know the name of network in your current config:

# uci get zerotier.mybeautifulnetwork.join
8056c2e21c000011

Even if you want do this in one command:

zerotier-cli join `uci get zerotier.mybeautifulnetwork.join`

Or for lazy ones can make a shell function

zerotierjoin () {
  zerotier-cli join `uci get zerotier.${1}.join`
}

The reason of don't touch config file and don't add the new options is that maintain both versions of config is hard to do it and confusing for the user

fundef1 commented 4 years ago

This really boils down to how user friendly you want to be. Off course users can already work around it (I can curl any website by first doing an nslookup and parsing that and substituting the IP address ;-) But that's not the point.

ZT is the userfriendly counterpart to WG. Which has much wider adoption, better support, but is more linux-y and requires your own publicly reachable server (AFAIK). So do you want to get people off WG, or enable less savy people to get on the ZT wagon....

So to the core of the argument: is it more confusing for the user? (and hey, I'm a user and since you asked...)

I think the current format is not following conventions, so you could argue it doesn't follow the principle of least surprise. There are really two issues:

From a user's perspective it really doesn't matter how hard it is to do, buy i'm assuming you'll be the one to do it so ultimately it's your call.

mwarning commented 4 years ago

Sorry for the delay. I will look into this again this weekend.

mwarning commented 4 years ago

It seems to be a good idea to attach a human readable name to a network id.

But I do not know if switching between different networks is a common practice with ZT. I have only use ZT with one network so far. If it is, then I would give this feature a go. Otherwise, I would advise people to use the ZT command line interface or to script something.

glimberg commented 4 years ago

From our experience running, and operating ZeroTier, switching between different networks is not commonplace. Especially since ZeroTier can join multiple networks at once. It's more of a set it & leave it going all the time thing.

ogarcia commented 4 years ago

As say @glimberg switching between different networks not is a common practice. Is more common up an instance and join (with same ID) in multiple networks at once.

I think that better of implement the proposed change is modify the start_instance() to can do /etc/init.d/zerotier start_instance instance_name by hand. This change only need move the logic of section_enabled from start_instance to start_service. Doing this you can have a command to connect and disconnect by hand without modify the syntax of config file.

mwarning commented 4 years ago

Ok, that settles it. I will close the issue.

@ogarcia we can implement that another day. Or feel free to submit a merge request.