Compare commits

...

12 Commits

Author SHA1 Message Date
zhongjin d982e4e038 更新 'src/views/login.pug'
3 weeks ago
zhongjin 533a14548a 更新 'src/views/index.pug'
3 weeks ago
zhongjin 4f02ee057f 更新 'src/views/front_door.pug'
3 weeks ago
zhongjin b7f4c81f55 更新 'src/views/head_layout.pug'
3 weeks ago
zhongjin 024ab9d116 更新 'src/views/front_door.pug'
3 weeks ago
zhongjin 88c8f68260 更新 'src/routes/index.js'
3 weeks ago
key-networks 1b2284864d Issue#123: compatibility issue with zerotier 1.12.1 (#125)
1 year ago
key-networks 42248c1359
Issue#91 and issue#107 (#111)
2 years ago
key-networks 0557b386a9
alma: Prepare for build on AlmaLinux 8 (#105)
2 years ago
key-networks 794f846125
Issue#98: Upgrade jquery (#104)
2 years ago
Key Networks 8fb29fa607 Version bump
3 years ago
lideming b50215f620
fix IPv6 route target comparing (#75)
3 years ago

@ -10,7 +10,7 @@ Follow us on [![alt @key_networks on Twitter](https://i.imgur.com/wWzX9uB.png)](
Instructions for installing on Linux from RPM or DEB packges are available at [key-networks.com/ztncui](https://key-networks.com/ztncui).
## Docker Container Image
See [github.com/key-networks/ztncui-containerized](https://github.com/key-networks/ztncui-containerized)
See [https://github.com/key-networks/ztncui-aio](https://github.com/key-networks/ztncui-aio)
## Getting Started
@ -45,21 +45,9 @@ npm install
##### 3. authtoken.secret
The app needs to know the zerotier-one authtoken.secret. There are two options:
The app needs to know the zerotier-one authtoken.secret.
###### A: Allow access to /var/lib/zerotier-one/authtoken.secret
The user running the ztncui app needs read access to authtoken.secret. This can be achieved with:
```shell
sudo usermod -aG zerotier-one username
sudo chmod g+r /var/lib/zerotier-one/authtoken.secret
```
Where:
* username is the user running the ztncui app
Note that you need to log out and in again to apply the new group membership.
###### OR
###### B: Make a .env file
###### Make a .env file
In the root of the ztncui directory, create a `.env` file with the content:
```
ZT_TOKEN=########################
@ -67,17 +55,19 @@ ZT_TOKEN=########################
Where:
* ######################## is the token string.
You can also specify in the `.env` file a different address for the zerotier-one API (which defaults to localhost:9993):
```
ZT_ADDR=localhost:9995
After all edits to the `.env file` (see other options below), make the `.env` readable by the user running ztncui only:
```shell
chmod 400 .env
chown ztncui.ztncui .env
```
Make `.env` readable by the user running ztncui only:
```shell
chmod 600 .env
##### 4. Zerotier-one API port
You can specify in the `.env` file a different address for the zerotier-one API (which defaults to localhost:9993):
```
ZT_ADDR=localhost:9995
```
The `.env` file should make it easier to run ztncui on a non-Linux platform.
##### 4. Run in production mode
To run the server in production mode, add the following to the `.env` file (see 3B above):
@ -315,4 +305,5 @@ Problems with ztncui can be reported using the GitHub issue tracking system. Pl
The ztncui code is open source code, licensed under the GNU GPLv3, and is free to use on those terms. If you are interested in commercial licensing, please contact us via the contact form at [key-networks.com](https://key-networks.com) .
## Thanks
@lideming for a rework and improvement of the network details page, adding DNS support, peer status/address/latency and other improvements.
- @lideming for a rework and improvement of the network details page, adding DNS support, peer status/address/latency and other improvements.
- @Koromix for a fix for incompatibility with ZeroTier 1.12.

@ -0,0 +1,8 @@
getent passwd ztncui || useradd --system --home-dir /opt/key-networks/ztncui --shell /bin/false ztncui
if [ $(getent group zerotier-one) ]; then
echo "Adding user ztncui to group zerotier-one..."
usermod -a -G zerotier-one ztncui
chmod g+r /var/lib/zerotier-one/authtoken.secret
else
echo "Could not add user ztncui to group zerotier-one... is zerotier-one installed?"
fi

@ -4,7 +4,7 @@
],
"cflags+": ["-Wno-cast-function-type"],
"include_dirs+": ["<!(node -e \"require('nan')\")"],
+ "libraries": ["/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a"],
+ "libraries": ["/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++fs.a"],
"dependencies": ["libargon2"],
"configurations": {
"Debug": {

@ -26,7 +26,7 @@ BINDINGGYP='node_modules/argon2/binding.gyp'
NODE_VER='v16'
if [ ! -f /usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a ]; then
if [ ! -f /usr/lib/gcc/x86_64-redhat-linux/8/libstdc++fs.a ]; then
echo "You must install libstdc++-static"
exit 1
fi

@ -17,15 +17,26 @@ async function get_network_with_members(nwid) {
zt.network_detail(nwid),
zt.peers(),
zt.members(nwid)
.then(member_ids =>
Promise.all(
.then(member_ids => {
// Fix weird data returned by ZeroTier 1.12
if (Array.isArray(member_ids)) {
let obj = {};
for (let id of member_ids) {
let key = Object.keys(id)[0];
let value = Object.values(id)[0];
obj[key] = value;
}
member_ids = obj;
}
return Promise.all(
Object.keys(member_ids)
.map(id => Promise.all([
zt.member_detail(nwid, id),
storage.getItem(id)
]))
)
).then(results => results.map(([member, name]) => {
);
}).then(results => results.map(([member, name]) => {
member.name = name || '';
return member;
}))

@ -186,13 +186,9 @@ exports.routes = async function(nwid, route, action) {
const network = await network_detail(nwid);
let routes = network.routes;
const target6 = new ipaddr.Address6(route.target);
if (target6.isValid()) {
const parts = route.target.split('/');
route.target = target6.canonicalForm() + '/' + parts[1];
}
route.target = canonicalTarget(route.target);
const route_to_del = routes.find(rt => rt.target === route.target);
const route_to_del = routes.find(rt => canonicalTarget(rt.target) === route.target);
if (!route_to_del) {
if (action === 'add') {
@ -220,6 +216,15 @@ exports.routes = async function(nwid, route, action) {
}
}
function canonicalTarget(target) {
const target6 = new ipaddr.Address6(target);
if (target6.isValid()) {
const parts = target.split('/');
return target6.canonicalForm() + '/' + parts[1];
}
return target;
}
exports.network_object = async function(nwid, object) {
const options = await init_options();
options.method = 'POST';

@ -1,6 +1,6 @@
{
"name": "ztncui",
"version": "0.8.4",
"version": "0.8.14",
"private": true,
"scripts": {
"start": "node ./bin/www",
@ -19,7 +19,7 @@
"got": "^7.1.0",
"helmet": "^3.23.0",
"ip-address": "^5.8.9",
"jquery": "~3.4.1",
"jquery": "^3.6.1",
"morgan": "~1.9.1",
"node-persist": "^2.1.0",
"pug": "^3.0.2",

@ -21,7 +21,7 @@ function guest_only(req, res, next) {
/* GET home page. */
router.get('/', guest_only, function(req, res, next) {
res.render('front_door', {title: 'ztncui'});
res.render('front_door', {title: '经纬飞行网络'});
});
router.get('/logout', function(req, res) {
@ -33,13 +33,13 @@ router.get('/logout', function(req, res) {
router.get('/login', guest_only, function(req, res) {
let message = null;
if (req.session.error) {
if (req.session.error !== 'Access denied!') {
if (req.session.error !== '无权限!') {
message = req.session.error;
}
} else {
message = req.session.success;
}
res.render('login', { title: 'Login', message: message });
res.render('login', { title: '登录', message: message });
});
router.post('/login', async function(req, res) {
@ -55,7 +55,7 @@ router.post('/login', async function(req, res) {
}
});
} else {
req.session.error = 'Authentication failed, please check your username and password.'
req.session.error = '登录失败,请检查用户名和密码.'
res.redirect('/login');
}
});

@ -9,5 +9,5 @@ block login_content
h1!= title
h2
a(href='https://zerotier.com' target='_blank') ZeroTier
| network controller UI
a(href='https://www.jingweiht.com/zerotier' target='_blank') ZeroTier
| 网络控制器

@ -31,9 +31,9 @@ html(lang='en')
span.icon-bar
span.icon-bar
span.icon-bar
a.navbar-brand(href='https://key-networks.com' target='_blank')
a.navbar-brand(href='https://www.jingweiht.com' target='_blank')
img(src='/images/key-logo.svg' alt='Key Networks logo' height='25px' width='25px' style='display: inline')
| Key Networks
| 飞行网络
.collapse.navbar-collapse(id='BarNav')
ul.nav.navbar-nav
block nav_items
@ -42,5 +42,5 @@ html(lang='en')
block nav_login
a(href='/logout')
span.glyphicon.glyphicon-log-out
| Logout
| 退出
block body_content

@ -9,14 +9,14 @@ block content
h1!= title
h2
a(href='https://zerotier.com' target='_blank') ZeroTier
| network controller UI by
a(href='https://key-networks.com' target='_blank') Key Networks
a(href='https://www.jingweiht.com/zerotier' target='_blank') ZeroTier
| 飞行网络控制器
a(href='https://www.jingweiht.com/key-networks' target='_blank') Key Networks
if error
b #{error}
else
h4 This network controller has a ZeroTier address of <b>#{zt_status.address}</b>
h4 ZeroTier version <b>#{zt_status.version}</b>
h4 ZeroTier 网络地址 <b>#{zt_status.address}</b>
h4 ZeroTier 版本 <b>#{zt_status.version}</b>
h4
a(href='/controller/networks') List all networks on this network controller
a(href='/controller/networks') 列表当前控制器下的所有网络

@ -21,7 +21,7 @@ block login_content
form.form-horizontal(method='POST' action='')
.form-group.row
.col-sm-2
label.control-label(for='username') Username:
label.control-label(for='username') 用户名:
.col-sm-10
.input-group
span.input-group-addon
@ -30,7 +30,7 @@ block login_content
.form-group.row
.col-sm-2
label.control-label(for='password') Password:
label.control-label(for='password') 密码:
.col-sm-10
.input-group
span.input-group-addon
@ -40,6 +40,6 @@ block login_content
.form-group.row
.col-sm-2
.col-sm-10
button.btn.btn-primary(type='submit') Login
button.btn.btn-primary(type='submit') 登录
= ' '
a.btn.btn-default(href='/' name='cancel' role='button') Cancel
a.btn.btn-default(href='/' name='cancel' role='button') 取消

@ -1,6 +1,6 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017-2021 Key Networks (https://key-networks.com)
Copyright (C) 2017-2023 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
@ -135,6 +135,7 @@ block net_content
td
if (peer)
each path in peer.paths
if (path.preferred == true)
- const [ip, port] = path.address.split('/');
= ip
span(style='color: gray;') /#{port}
@ -142,6 +143,7 @@ block net_content
if (peer.latency != -1)
br
| (#{peer.latency} ms)
- break
else
.alert.alert-info
strong There are no members on this network - invite users to join #{network.nwid}

Loading…
Cancel
Save