Setting of activeBridge

This commit is contained in:
Key Networks 2018-01-31 11:14:49 +08:00
parent 09f1e841b3
commit 83f0bb781a
6 changed files with 43 additions and 14 deletions

View File

@ -587,6 +587,25 @@ exports.members = async function(req, res) {
throw err;
}
}
} else if (req.body.activeBridge) {
req.checkBody('activeBridge', 'activeBridge state must be boolean').isBoolean();
req.sanitize('activeBridge').trim();
req.sanitize('activeBridge').escape();
errors = req.validationErrors();
if (!errors) {
const activeBridge =
{
activeBridge: req.body.activeBridge
};
try {
const mem = await zt.member_object(req.params.nwid, req.body.id, activeBridge);
} catch (err) {
throw err;
}
}
} else if (req.body.name) {
req.sanitize('name').trim();
req.sanitize('name').escape();
@ -709,16 +728,12 @@ exports.assign_ip = async function(req, res) {
let ipAddressInManagedRoute = false;
network.routes.forEach(function(item) {
let ipv4 = new ipaddr.Address4(value);
console.log('ipv4 = ' + JSON.stringify(ipv4));
let target4 = new ipaddr.Address4(item.target);
console.log('target4 = ' + JSON.stringify(target4));
if (ipv4.isValid() && target4.isValid()) {
if (ipv4.isInSubnet(target4)) ipAddressInManagedRoute = true;
}
let ipv6 = new ipaddr.Address6(value);
console.log('ipv6 = ' + JSON.stringify(ipv6));
let target6 = new ipaddr.Address6(item.target);
console.log('target6 = ' + JSON.stringify(target6));
if (ipv6.isValid() && target6.isValid()) {
if (ipv6.isInSubnet(target6)) ipAddressInManagedRoute = true;
}

View File

@ -1,6 +1,6 @@
{
"name": "ztncui",
"version": "0.4.0",
"version": "0.4.1",
"private": true,
"scripts": {
"start": "node ./bin/www",

View File

@ -83,7 +83,6 @@ router.get('/network/:nwid/member/:id/ipAssignments/:index/delete', restrict, ne
router.post('/network/:nwid/member/:id/ipAssignments', restrict, networkController.assign_ip);
// GET request for any network object
router.get('/network/:nwid/:object', restrict, networkController.network_object);

View File

@ -17,6 +17,7 @@ block content
if error
b #{error}
else
p This network controller has a ZeroTier address of <b>#{zt_address}</b>
h4 This network controller has a ZeroTier address of <b>#{zt_address}</b>
a(href='/controller/networks') List all networks on this network controller
h4
a(href='/controller/networks') List all networks on this network controller

View File

@ -8,11 +8,17 @@ extends network_layout
block net_content
script.
$(function() {
$('.checkbox').on('click', function() {
$('#authCheckBox').on('click', function() {
$.post('', {id: this.value, auth: this.checked});
});
});
$(function() {
$('#activeBridgeCheckBox').on('click', function() {
$.post('', {id: this.value, activeBridge: this.checked});
});
});
$(function() {
$('.text').on('change', function() {
$.post('', {id: this.name, name: this.value});
@ -30,7 +36,9 @@ block net_content
| Member ID
td(width='10%')
| Authorized
td(width='57%')
td(width='10%')
| Active bridge
td(width='47%')
| IP assignment
each member in members
tr
@ -43,7 +51,9 @@ block net_content
td
a(href=url) #{member.id}
td
input.checkbox(type='checkbox' name='authCheckBox' value=member.id checked=(member.authorized? true : false))
input.checkbox(type='checkbox' id='authCheckBox' value=member.id checked=(member.authorized? true : false))
td
input.checkbox(type='checkbox' id='activeBridgeCheckBox' value=member.id checked=(member.activeBridge? true : false))
td
each ipAssignment in member.ipAssignments
a(href='/controller/network/' + network.nwid + '/member/' + member.id + '/ipAssignments')
@ -58,8 +68,6 @@ block net_content
.alert.alert-info
strong There are no members on this network - invite users to join #{network.nwid}
a.btn.btn-default(href='/controller/networks' name='networks' role='button') Networks
= ' '
a.btn.btn-default(href='' name='refresh' role='button') Refresh
if errors

View File

@ -11,4 +11,10 @@ block net_content
a(href='../' + member.address) #{member.address}
h4 Editing of
b #{title}
| has not been implemented
| has not been implemented.
h4
| Note that you may be able to edit some properties on the
strong
a(href='/controller/network/' + network.nwid + '/members') Members
| page.