mwarning / zerotier-openwrt

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

feature request: support MOON peers in the configuration file #91

Closed SadPencil closed 8 months ago

SadPencil commented 3 years ago

In a regular Linux distro, path /var/lib/zerotier-one/moons.d folder contains the information of MOON peers, each *.moon file per peer. When zerotier service starts, these files are loaded.

Currently, to let the zerotier node join the MOON in openwrt, the only way is to specify config_path in your configuration file.

# persistent configuration folder (for ZT controller mode)
    #option config_path '/etc/zerotier'

and place the moon files inside the folder. However, there are some cons in this method. Zerotier writes temporary files in the configuration folder and the persistent storage space in a OpenWRT router should not be written too much as it is a simple SPI flash that can't support too much write.

See the next comment for my solution.

SadPencil commented 3 years ago

This request can be also achieved as follows.

The current behavior config_path is to make a symlink from /var/lib/zerotier-one to /etc/zerotier. However, it can be improved by something like,

option config_path '/etc/zerotier'
option option copy_config_path '0' # default to 0 in order to be compatible with older versions

and instead of making a symlink, copy all the files from /etc/zerotier to /var/lib/zerotier-one, and initialize the rest files.

ogarcia commented 3 years ago

@SadPencil the only temporally files that ZT creates in /etc/zerotier are zerotier-one.pid and zerotier-one.port. Both with size of 4K and only rewrite on a router reboot. I think that flash can manage this without problem.

SadPencil commented 3 years ago

@SadPencil the only temporally files that ZT creates in /etc/zerotier are zerotier-one.pid and zerotier-one.port. Both with size of 4K and only rewrite on a router reboot. I think that flash can manage this without problem.

The temporally files are small, indeed. But I create a PR for this anyhow. Tested on my router. https://github.com/mwarning/zerotier-openwrt/pull/92

SadPencil commented 3 years ago

@ogarcia For those SPI flash without wear leveling feature, even though the files are small, minimizing the write is meaningful. Please review PR #92 .

ogarcia commented 3 years ago

@mwarning what do you think?

mwarning commented 3 years ago

I will take a look later this week. @SadPencil thank you for your contribution!

openwrtdiy commented 3 years ago

@mwarning support MOON?

mwarning commented 3 years ago

This feature sounds nice, but since I have never used mooons, it takes some time to grook and to have time to get into it. I hope to have time soon. Thank you for all the contributions so far! :)