Delete luci-app-zerotier directory

This commit is contained in:
OPPEN321 2025-02-05 00:21:00 +08:00 committed by GitHub
parent 4a0b45ea04
commit 76796811bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 0 additions and 821 deletions

View File

@ -1,20 +0,0 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2022 ImmortalWrt.org
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI for Zerotier
LUCI_DEPENDS:=+zerotier +jsonfilter +ucode
LUCI_PKGARCH:=all
define Package/luci-app-zerotier/conffiles
/etc/config/zero/
/etc/config/zerotier
endef
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -1,94 +0,0 @@
/* SPDX-License-Identifier: GPL-3.0-only
*
* Copyright (C) 2022 ImmortalWrt.org
*/
'use strict';
'require form';
'require poll';
'require rpc';
'require uci';
'require view';
var callServiceList = rpc.declare({
object: 'service',
method: 'list',
params: ['name'],
expect: { '': {} }
});
function getServiceStatus() {
return L.resolveDefault(callServiceList('zerotier'), {}).then(function (res) {
var isRunning = false;
try {
isRunning = res['zerotier']['instances']['instance1']['running'];
} catch (e) { }
return isRunning;
});
}
function renderStatus(isRunning) {
var spanTemp = '<em><span style="color:%s"><strong>%s %s</strong></span></em>';
var renderHTML;
if (isRunning) {
renderHTML = String.format(spanTemp, 'green', _('ZeroTier'), _('RUNNING'));
} else {
renderHTML = String.format(spanTemp, 'red', _('ZeroTier'), _('NOT RUNNING'));
}
return renderHTML;
}
return view.extend({
load: function() {
return Promise.all([
uci.load('zerotier')
]);
},
render: function(data) {
var m, s, o;
m = new form.Map('zerotier', _('ZeroTier'),
_('ZeroTier is an open source, cross-platform and easy to use virtual LAN.'));
s = m.section(form.TypedSection);
s.anonymous = true;
s.render = function () {
poll.add(function () {
return L.resolveDefault(getServiceStatus()).then(function (res) {
var view = document.getElementById("service_status");
view.innerHTML = renderStatus(res);
});
});
return E('div', { class: 'cbi-section', id: 'status_bar' }, [
E('p', { id: 'service_status' }, _('Collecting data ...'))
]);
}
s = m.section(form.NamedSection, 'sample_config', 'config');
o = s.option(form.Flag, 'enabled', _('Enable'));
o.default = o.disabled;
o.rmempty = false;
o = s.option(form.DynamicList, 'join', _('Network ID'));
o.rmempty = false;
o = s.option(form.Flag, 'nat', _('Auto NAT clients'),
_('Allow ZeroTier clients access your LAN network.'));
o.default = o.disabled;
o.rmempty = false;
o = s.option(form.Button, '_panel', _('ZeroTier Central'),
_('Create or manage your ZeroTier network, and auth clients who could access.'));
o.inputtitle = _('Open website');
o.inputstyle = 'apply';
o.onclick = function () {
window.open("https://my.zerotier.com/network", '_blank');
}
return m.render();
}
});

View File

@ -1,119 +0,0 @@
/* SPDX-License-Identifier: GPL-3.0-only
*
* Copyright (C) 2022 ImmortalWrt.org
*/
'use strict';
'require fs';
'require ui';
'require view';
return view.extend({
load: function() {
return fs.exec('/sbin/ifconfig').then(function(res) {
if (res.code !== 0 || !res.stdout || res.stdout.trim() === '') {
ui.addNotification(null, E('p', {}, _('Unable to get interface info: %s.').format(res.message)));
return '';
}
var interfaces = res.stdout.match(/zt[a-z0-9]+/g);
if (!interfaces || interfaces.length === 0)
return 'No interface online.';
var promises = interfaces.map(function(name) {
return fs.exec('/sbin/ifconfig', [name]);
});
return Promise.all(promises).then(function(results) {
var data = results.map(function(res, index) {
if (res.code !== 0 || !res.stdout || res.stdout.trim() === '') {
ui.addNotification(null, E('p', {}, _('Unable to get interface %s info: %s.').format(interfaces[index], res.message)));
return null;
}
return {
name: interfaces[index],
stdout: res.stdout.trim()
};
}).filter(Boolean);
return data.map(function(info) {
var lines = info.stdout.split('\n');
var parsedInfo = {
name: info.name
};
lines.forEach(function(line) {
if (line.includes('HWaddr')) {
parsedInfo.mac = line.split('HWaddr')[1].trim().split(' ')[0];
} else if (line.includes('inet addr:')) {
parsedInfo.ipv4 = line.split('inet addr:')[1].trim().split(' ')[0];
} else if (line.includes('inet6 addr:')) {
parsedInfo.ipv6 = line.split('inet6 addr:')[1].trim().split('/')[0];
} else if (line.includes('MTU:')) {
parsedInfo.mtu = line.split('MTU:')[1].trim().split(' ')[0];
} else if (line.includes('RX bytes:')) {
var rxMatch = line.match(/RX bytes:\d+ \(([\d.]+\s*[a-zA-Z]+)\)/);
if (rxMatch && rxMatch[1]) {
parsedInfo.rxBytes = rxMatch[1];
}
var txMatch = line.match(/TX bytes:\d+ \(([\d.]+\s*[a-zA-Z]+)\)/);
if (txMatch && txMatch[1]) {
parsedInfo.txBytes = txMatch[1];
}
}
});
return parsedInfo;
});
});
});
},
render: function(data) {
var title = E('h2', {class: 'content'}, _('ZeroTier'));
var desc = E('div', {class: 'cbi-map-descr'}, _('ZeroTier is an open source, cross-platform and easy to use virtual LAN.'));
if (!Array.isArray(data)) {
return E('div', {}, [title, desc, E('div', {}, _('No interface online.'))]);
}
var rows = data.flatMap(function(interfaceData) {
return [
E('th', {class: 'th', colspan: '2'}, _('Network Interface Information')),
E('tr', {class: 'tr'}, [
E('td', {class: 'td left', width: '25%'}, _('Interface Name')),
E('td', {class: 'td left', width: '25%'}, interfaceData.name)
]),
E('tr', {class: 'tr'}, [
E('td', {class: 'td left', width: '25%'}, _('MAC Address')),
E('td', {class: 'td left', width: '25%'}, interfaceData.mac)
]),
E('tr', {class: 'tr'}, [
E('td', {class: 'td left', width: '25%'}, _('IPv4 Address')),
E('td', {class: 'td left', width: '25%'}, interfaceData.ipv4)
]),
E('tr', {class: 'tr'}, [
E('td', {class: 'td left', width: '25%'}, _('IPv6 Address')),
E('td', {class: 'td left', width: '25%'}, interfaceData.ipv6)
]),
E('tr', {class: 'tr'}, [
E('td', {class: 'td left', width: '25%'}, _('MTU')),
E('td', {class: 'td left', width: '25%'}, interfaceData.mtu)
]),
E('tr', {class: 'tr'}, [
E('td', {class: 'td left', width: '25%'}, _('Total Download')),
E('td', {class: 'td left', width: '25%'}, interfaceData.rxBytes)
]),
E('tr', {class: 'tr'}, [
E('td', {class: 'td left', width: '25%'}, _('Total Upload')),
E('td', {class: 'td left', width: '25%'}, interfaceData.txBytes)
])
];
});
return E('div', {}, [title, desc, E('table', { 'class': 'table' }, rows)]);
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});

View File

@ -1,112 +0,0 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:80
msgid "Allow ZeroTier clients access your LAN network."
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:79
msgid "Auto NAT clients"
msgstr ""
#: applications/luci-app-zerotier/root/usr/share/luci/menu.d/luci-app-zerotier.json:14
msgid "Base settings"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:66
msgid "Collecting data ..."
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:85
msgid ""
"Create or manage your ZeroTier network, and auth clients who could access."
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:72
msgid "Enable"
msgstr ""
#: applications/luci-app-zerotier/root/usr/share/rpcd/acl.d/luci-app-zerotier.json:3
msgid "Grant access to ZeroTier configuration"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:91
msgid "IPv4 Address"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:95
msgid "IPv6 Address"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:83
msgid "Interface Name"
msgstr ""
#: applications/luci-app-zerotier/root/usr/share/luci/menu.d/luci-app-zerotier.json:22
msgid "Interface info"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:87
msgid "MAC Address"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:99
msgid "MTU"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:36
msgid "NOT RUNNING"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:76
msgid "Network ID"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:81
msgid "Network Interface Information"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:77
msgid "No interface online."
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:86
msgid "Open website"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:34
msgid "RUNNING"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:103
msgid "Total Download"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:107
msgid "Total Upload"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:30
msgid "Unable to get interface %s info: %s."
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:15
msgid "Unable to get interface info: %s."
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:34
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:36
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:52
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:73
#: applications/luci-app-zerotier/root/usr/share/luci/menu.d/luci-app-zerotier.json:3
msgid "ZeroTier"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:84
msgid "ZeroTier Central"
msgstr ""
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:53
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:74
msgid "ZeroTier is an open source, cross-platform and easy to use virtual LAN."
msgstr ""

View File

@ -1 +0,0 @@
zh_Hans

View File

@ -1,118 +0,0 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: zh_Hans\n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:80
msgid "Allow ZeroTier clients access your LAN network."
msgstr "允许 ZeroTier 客户端访问您的局域网。"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:79
msgid "Auto NAT clients"
msgstr "自动客户端 NAT"
#: applications/luci-app-zerotier/root/usr/share/luci/menu.d/luci-app-zerotier.json:14
msgid "Base settings"
msgstr "基本设置"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:66
msgid "Collecting data ..."
msgstr "收集数据中 ..."
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:85
msgid ""
"Create or manage your ZeroTier network, and auth clients who could access."
msgstr "创建或管理您的 ZeroTier 网络,并允许客户端接入。"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:72
msgid "Enable"
msgstr "启用"
#: applications/luci-app-zerotier/root/usr/share/rpcd/acl.d/luci-app-zerotier.json:3
msgid "Grant access to ZeroTier configuration"
msgstr "授予访问 ZeroTier 配置的权限"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:91
msgid "IPv4 Address"
msgstr "IPv4 地址"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:95
msgid "IPv6 Address"
msgstr "IPv6 地址"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:83
msgid "Interface Name"
msgstr "接口名称"
#: applications/luci-app-zerotier/root/usr/share/luci/menu.d/luci-app-zerotier.json:22
msgid "Interface info"
msgstr "接口信息"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:87
msgid "MAC Address"
msgstr "MAC 地址"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:99
msgid "MTU"
msgstr "MTU"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:36
msgid "NOT RUNNING"
msgstr "未运行"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:76
msgid "Network ID"
msgstr "网络 ID"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:81
msgid "Network Interface Information"
msgstr "网络接口信息"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:77
msgid "No interface online."
msgstr "没有在线的接口。"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:86
msgid "Open website"
msgstr "打开网站"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:34
msgid "RUNNING"
msgstr "运行中"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:103
msgid "Total Download"
msgstr "总下载"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:107
msgid "Total Upload"
msgstr "总上传"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:30
msgid "Unable to get interface %s info: %s."
msgstr "无法获取接口 %s 的信息:%s。"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:15
msgid "Unable to get interface info: %s."
msgstr "无法获取接口信息:%s。"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:34
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:36
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:52
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:73
#: applications/luci-app-zerotier/root/usr/share/luci/menu.d/luci-app-zerotier.json:3
msgid "ZeroTier"
msgstr "ZeroTier"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:84
msgid "ZeroTier Central"
msgstr "ZeroTier 管理中心"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:53
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:74
msgid "ZeroTier is an open source, cross-platform and easy to use virtual LAN."
msgstr "ZeroTier 是一个开源、跨平台且易于使用的虚拟局域网 VPN。"

View File

@ -1,118 +0,0 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: zh_Hant\n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:80
msgid "Allow ZeroTier clients access your LAN network."
msgstr "允許 ZeroTier 用戶端訪問您的區域網路"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:79
msgid "Auto NAT clients"
msgstr "自動 NAT 用戶端"
#: applications/luci-app-zerotier/root/usr/share/luci/menu.d/luci-app-zerotier.json:14
msgid "Base settings"
msgstr "基礎設定"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:66
msgid "Collecting data ..."
msgstr "收集資料中..."
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:85
msgid ""
"Create or manage your ZeroTier network, and auth clients who could access."
msgstr "新建或管理您的 ZeroTier 網路,並授權用戶端訪問"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:72
msgid "Enable"
msgstr "啟用"
#: applications/luci-app-zerotier/root/usr/share/rpcd/acl.d/luci-app-zerotier.json:3
msgid "Grant access to ZeroTier configuration"
msgstr "允許訪問 ZeroTier 的配置"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:91
msgid "IPv4 Address"
msgstr "IPv4 位址"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:95
msgid "IPv6 Address"
msgstr "IPv6 位址"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:83
msgid "Interface Name"
msgstr "介面名稱"
#: applications/luci-app-zerotier/root/usr/share/luci/menu.d/luci-app-zerotier.json:22
msgid "Interface info"
msgstr "介面資訊"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:87
msgid "MAC Address"
msgstr "MAC 位址"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:99
msgid "MTU"
msgstr "MTU"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:36
msgid "NOT RUNNING"
msgstr "尚未執行"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:76
msgid "Network ID"
msgstr "網路 ID"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:81
msgid "Network Interface Information"
msgstr "網路介面資訊"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:77
msgid "No interface online."
msgstr "沒有介面在線上。"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:86
msgid "Open website"
msgstr "開啟網站"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:34
msgid "RUNNING"
msgstr "正在執行"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:103
msgid "Total Download"
msgstr "總下載量"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:107
msgid "Total Upload"
msgstr "總上傳量"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:30
msgid "Unable to get interface %s info: %s."
msgstr "無法取得介面 %s 的資訊:%s"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:15
msgid "Unable to get interface info: %s."
msgstr "無法取得介面資訊:%s"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:34
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:36
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:52
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:73
#: applications/luci-app-zerotier/root/usr/share/luci/menu.d/luci-app-zerotier.json:3
msgid "ZeroTier"
msgstr "ZeroTier"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:84
msgid "ZeroTier Central"
msgstr "ZeroTier 管理中心"
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/base.js:53
#: applications/luci-app-zerotier/htdocs/luci-static/resources/view/zerotier/interface.js:74
msgid "ZeroTier is an open source, cross-platform and easy to use virtual LAN."
msgstr "ZeroTier 是一個開源、跨平台且易於使用的虛擬區域網路 VPN"

View File

@ -1,20 +0,0 @@
config zerotier sample_config
option enabled 0
# persistent configuration folder (for ZT controller mode)
#option config_path '/etc/zerotier'
# copy <config_path> to RAM to prevent writing to flash (for ZT controller mode)
#option copy_config_path '1'
#option port '9993'
# path to the local.conf
#option local_conf '/etc/zerotier.conf'
# Generate secret on first start
option secret ''
# Join a public network called Earth
list join '8056c2e21c000001'
#list join '<other_network>'

View File

@ -1,9 +0,0 @@
#!/bin/sh
zero_enable="$(uci get zerotier.sample_config.enabled)"
nat_enable="$(uci get zerotier.sample_config.nat)"
[ "$ACTION" = ifup -o "$ACTION" = ifupdate ] || exit 0
[ "$ACTION" = ifupdate -a -z "$IFUPDATE_ADDRESSES" -a -z "$IFUPDATE_DATA" ] && exit 0
[ "$zero_enable" -eq "1" -a "${nat_enable}" -eq "1" ] || exit 0
/etc/zerotier.start > /tmp/zero.log 2>&1 &

View File

@ -1,115 +0,0 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
PROG=/usr/bin/zerotier-one
CONFIG_PATH=/var/lib/zerotier-one
service_triggers() {
procd_add_reload_trigger "zerotier"
procd_add_interface_trigger "interface.*.up" wan /etc/init.d/zerotier restart
}
section_enabled() {
config_get_bool enabled "$1" 'enabled' 0
[ $enabled -gt 0 ]
}
start_instance() {
local cfg="$1"
local port secret config_path
local ARGS=""
if ! section_enabled "$cfg"; then
echo "disabled in config"
return 1
fi
[ -d /etc/config/zero ] || mkdir -p /etc/config/zero
config_path=/etc/config/zero
config_get_bool port $cfg 'port'
config_get secret $cfg 'secret'
# Remove existing link or folder
rm -rf $CONFIG_PATH
# Create link from CONFIG_PATH to config_path
if [ -n "$config_path" -a "$config_path" != $CONFIG_PATH ]; then
if [ ! -d "$config_path" ]; then
echo "ZeroTier config_path does not exist: $config_path"
return
fi
ln -s $config_path $CONFIG_PATH
fi
mkdir -p $CONFIG_PATH/networks.d
if [ -n "$port" ]; then
ARGS="$ARGS -p$port"
fi
if [ "$secret" = "generate" ]; then
echo "Generate secret - please wait..."
local sf="/tmp/zt.$cfg.secret"
zerotier-idtool generate "$sf" > /dev/null
[ $? -ne 0 ] && return 1
secret="$(cat $sf)"
rm "$sf"
uci set zerotier.$cfg.secret="$secret"
uci commit zerotier
fi
if [ -n "$secret" ]; then
echo "$secret" > $CONFIG_PATH/identity.secret
# make sure there is not previous identity.public
rm -f $CONFIG_PATH/identity.public
fi
add_join() {
# an (empty) config file will cause ZT to join a network
touch $CONFIG_PATH/networks.d/$1.conf
}
config_list_foreach $cfg 'join' add_join
procd_open_instance
procd_set_param command $PROG $ARGS $CONFIG_PATH
procd_set_param stderr 1
procd_close_instance
}
start_service() {
config_load 'zerotier'
config_foreach start_instance 'zerotier'
touch /tmp/zero.log && /etc/zerotier.start > /tmp/zero.log 2>&1 &
}
stop_instance() {
rm -f /tmp/zero.log
local cfg="$1"
rm -f "/usr/share/nftables.d/chain-pre/forward/zerotier.nft" "/usr/share/nftables.d/chain-pre/srcnat/zerotier.nft"
fw4 reload
echo "zt interface rules removed!" > /tmp/zero.log 2>&1 &
# Remove existing link or folder
rm -f $CONFIG_PATH/networks.d/*.conf
rm -rf $CONFIG_PATH
}
stop_service() {
config_load 'zerotier'
config_foreach stop_instance 'zerotier'
}
reload_service() {
stop
start
}

View File

@ -1,12 +0,0 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@zerotier[-1]
commit ucitrack
delete firewall.zerotier
commit firewall
EOF
rm -f /tmp/luci-indexcache
exit 0

View File

@ -1,37 +0,0 @@
#!/bin/sh
zero_enable="$(uci get zerotier.sample_config.enabled)"
[ "$zero_enable" -eq "1" ] || exit 1
count=0
[ -f "/tmp/zero.log" ] && {
while [ -z "$(ifconfig | grep 'zt' | awk '{print $1}')" ]
do
sleep 2
let count++
[ "$count" -lt 5 ] || exit 19
done
}
nft_incdir="/usr/share/nftables.d/chain-pre"
rm -f "$nft_incdir/input/zerotier.nft" "$nft_incdir/forward/zerotier.nft" "$$nft_incdir/srcnat/zerotier.nft"
nat_enable="$(uci get zerotier.sample_config.nat)"
[ "$nat_enable" -eq "1" ] && {
[ -d "$nft_incdir/input" ] || mkdir -p "$nft_incdir/input"
[ -d "$nft_incdir/forward" ] || mkdir -p "$nft_incdir/forward"
[ -d "$nft_incdir/srcnat" ] || mkdir -p "$nft_incdir/srcnat"
for i in $(ifconfig | grep 'zt' | awk '{print $1}')
do
ip_segment="$(ip route | grep "dev $i proto kernel" | awk '{print $1}')"
echo "iifname $i counter accept comment \"!fw4: Zerotier allow inbound $i\"" >> "$nft_incdir/input/zerotier.nft"
echo "iifname $i counter accept comment \"!fw4: Zerotier allow inbound forward $i\"" >> "$nft_incdir/forward/zerotier.nft"
echo "oifname $i counter accept comment \"!fw4: Zerotier allow outbound forward $i\"" >> "$nft_incdir/forward/zerotier.nft"
echo "oifname $i counter masquerade comment \"!fw4: Zerotier $i outbound postrouting masq\"" >> "$nft_incdir/srcnat/zerotier.nft"
[ -z "$ip_segment" ] || echo "ip saddr $ip_segment counter masquerade comment \"!fw4: Zerotier $ip_segment postrouting masq\"" >> "$nft_incdir/srcnat/zerotier.nft"
done
echo "zt interface rules added!" > "/tmp/zero.log"
uci -q set firewall.@defaults[0].auto_includes="1"
uci -q commit firewall
fw4 reload
}

View File

@ -1,29 +0,0 @@
{
"admin/vpn/zerotier": {
"title": "ZeroTier",
"order": 90,
"action": {
"type": "firstchild"
},
"depends": {
"acl": [ "luci-app-zerotier" ],
"uci": { "zerotier": true }
}
},
"admin/vpn/zerotier/base": {
"title": "Base settings",
"order": 10,
"action": {
"type": "view",
"path": "zerotier/base"
}
},
"admin/vpn/zerotier/interface": {
"title": "Interface info",
"order": 20,
"action": {
"type": "view",
"path": "zerotier/interface"
}
}
}

View File

@ -1,17 +0,0 @@
{
"luci-app-zerotier": {
"description": "Grant access to ZeroTier configuration",
"read": {
"file": {
"/sbin/ifconfig": [ "exec" ]
},
"ubus": {
"service": [ "list" ]
},
"uci": [ "zerotier" ]
},
"write": {
"uci": [ "zerotier" ]
}
}
}