Initial commit

This commit is contained in:
Key Networks 2017-12-13 22:05:07 +08:00
commit c7e7dcaf72
45 changed files with 6724 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
etc/storage/
node_modules/
*.swp

674
LICENSE Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

137
README.md Normal file
View File

@ -0,0 +1,137 @@
# ztncui - ZeroTier network controller UI
ztncui is a web UI for a standalone [ZeroTier](https://zerotier.com) network controller.
## Getting Started
### Prerequisites
ztncui is a [node.js](https://nodejs.org) [Express](https://expressjs.com) application that requires [node.js](https://nodejs.org) v8 or higher.
It requires [ZeroTier One](https://www.zerotier.com/download.shtml) to be installed on the same machine. This will run as the network controller to establish ZeroTier networks.
ztncui has been developed on a Linux platform and expects the ZT home directory to be in `/var/lib/zerotier-one`. It should be easy to modify for other platforms - please feed back if this is required.
### Installing
##### 1. Clone the repository on a machine running ZeroTier One:
```shell
git clone https://github.com/key-networks/ztncui.git
```
##### 2. Install the [node.js](https://nodejs.org) packages:
```shell
cd ztncui
npm install
```
##### 3. Start the app manually:
```shell
npm start
```
##### 4. Test access on http://localhost:3000
If the machine has a GUI and GUI web browser, then use it to access the app, otherwise use a CLI web browser like Lynx or wget or curl:
```shell
curl http://localhost:3000
```
You should see the front page of the app (or the raw HTML with curl).
##### 5. Remote access:
For security reasons (until this app is battle-hardened and has been scrutinized by the ZT community), it currently listens only on the looback interface. It can be reverse proxied by something like Nginx, but it would be best to access over an SSH tunnel at this stage.
###### SSH tunnel from Linux / Unix / macOS client
An SSH tunnel can be established with:
```shell
ssh -f user@network.controller.machine -L 3333:localhost:3000 -N
```
where:
* **network.controller.machine** is the FQDN of the machine running the ZT network controller and ztncui, and
* **user** is any user account that you have on that machine.
Once the SSH tunnel has been established, access the ztncui web interface in a web browser on your local machine at: http://localhost:3333
###### SSH tunnel from a Windows machine
On Windows you can install [PuTTY](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)
Open PuTTY and configure as follows:
1. Go to Connection -> SSH -> Tunnels.
2. Set **Source port** to 3333
3. Set **Destination** to localhost:3000
4. Click on the **Add** button.
5. Go **Session** in the **Category** panel on the left.
6. Set **Host Name (or IP address)** to the FQDN of the machine running the ZT network controller and ztncui.
7. Enter a name for the configuration in **Saved Sessions** and click **Save**.
8. Click the **Open** button and log into the network controller machine.
Once the SSH tunnel has been established, access the ztncui web interface in a web browser on your local machine at: http://localhost:3333
## Usage
### User accounts
Once you have access to the web UI of ztncui, log in as user **admin** with password **password**.
You will be prompted to change the default password.
It's a good idea to create your own username and delete the default admin account. You can do this by clicking on the **Users** tab and then the **Create user** tab. Note that you then have to log out and log in as the new user before you can delete the default admin account.
### Networks
Click on the **Home** tab to get to the network controller home page. From there you can click on the **Networks** tab to see the existing networks configured on the network controller (probably none if you have just set it up).
#### Create a new network
Click on the **Add network** tab to create a new ZeroTier network that is controlled by the network controller. Give it a name and click **Create Network**. You will then be taken back to the **Networks** page that lists all the networks on the controller.
#### Delete a network
On the **Networks** page, click the trash can icon to delete a network. You will be warned that this action cannot be undone. Click the **Delete** button to confirm the action.
#### Change network name
On the **Networks** page, click the name of the network to rename it.
#### Easy network setup
On the **Networks** page, click **easy setup** for the network that you want to auto-configure. Click **Generate network address** to assign a random network address, or manually enter the network address in CIDR notation. The start and end of the IP assignment pool will be automatically calculated, but these can be manually adjusted. Click **Submit** to apply the configuration. You should then get a notice that the network setup succeeded.
Note that the **easy setup** only works for IPv4 at this stage. To set up IPv6, follow the **detail** link for a network from the **Networks** page and set up each property manually.
#### Join devices to the network
Invite users to join the network with:
```shell
sudo zerotier-cli join ################
```
where ################ is the 16-digit ZeroTier network ID.
Get the user to send you their 10-digit ZeroTier address, which they can get by running:
```shell
sudo zerotier-cli status
```
#### Authorize members on the network
On the **Networks** page, click **members** to see the devices which are trying to join the network. Use the ZeroTier address given to you by the user to identify them and name them appropriately under **Member name**.
Then check the **Authorized** checkbox to authorize the user on the network.
If the user's device is online and you click the **Refresh** button, you should see their IP assignment being populated.
Once two or more members are authorized on the network, they should be able to connect to each other via their assigned IP addresses.
#### Network detail
On the **Networks** page, click **detail** to see the detail of a network.
Note that certain properties can be set by clicking on them - e.g.:
* ipAssignmentPools
* name
* routes
* v4AssignMode
* v6AssignMode
Note that editing of certain properties, such as rules and tags, has not been implemented yet. Please feed back on your requirements.
#### Member detail
On the network **detail** page and on the **members** page, if you click on the member ID, you will end up on the member detail page.
Certain properties for the member can be set by clicking on them - e.g.:
* authorized
* umm... nothing else at this stage - let us know what you need.
## Feedback
Please give us your feedback... good, bad or ugly. Constructive criticism is welcomed. Please use the contact form at [key-networks.com](https://key-networks.com/) - Thanks :)
## License
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) .

73
app.js Normal file
View File

@ -0,0 +1,73 @@
/*
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
*/
const express = require('express');
const path = require('path');
const favicon = require('serve-favicon');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const expressValidator = require('express-validator');
const session = require('express-session');
const index = require('./routes/index');
const users = require('./routes/users');
const zt_controller = require('./routes/zt_controller');
const app = express();
const session_secret = Math.random().toString(36).substring(2,12);
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
// uncomment after placing your favicon in /public
app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(session({
resave: false,
saveUninitialized: false,
secret: session_secret
}));
app.use(expressValidator());
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/fonts', express.static(path.join(__dirname, 'node_modules/bootstrap/fonts')));
app.use('/bscss', express.static(path.join(__dirname, 'node_modules/bootstrap/dist/css')));
app.use('/jqjs', express.static(path.join(__dirname, 'node_modules/jquery/dist')));
app.use('/bsjs', express.static(path.join(__dirname, 'node_modules/bootstrap/dist/js')));
app.use('/', index);
app.use('/users', users);
app.use('/controller', zt_controller);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = req.session.error;
var msg = req.session.success;
delete req.session.error;
delete req.session.success;
res.locals.message = '';
if (err) res.locals.message = '<p class="msg error">' + err + '</p>';
if (msg) res.locals.message = '<p class="msg success">' + msg + '</p>';
next();
});
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
module.exports = app;

90
bin/www Executable file
View File

@ -0,0 +1,90 @@
#!/usr/bin/env node
/**
* Module dependencies.
*/
var app = require('../app');
var debug = require('debug')('ztnc:server');
var http = require('http');
/**
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on loopback network interface.
*/
server.listen(port, 'localhost');
server.on('error', onError);
server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
}
/**
* Event listener for HTTP server "error" event.
*/
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
/**
* Event listener for HTTP server "listening" event.
*/
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}

48
controllers/auth.js Normal file
View File

@ -0,0 +1,48 @@
/*
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
*/
const argon2 = require('argon2');
const usersController = require('../controllers/usersController');
hash_check = async function(user, password) {
let verified = false;
try {
var users = await usersController.get_users();
} catch (err) {
throw err;
}
try {
verified = await argon2.verify(users[user].hash, password);
} catch (err) {
throw err;
}
return verified;
}
exports.authenticate = async function(name, pass, callback) {
try {
var users = await usersController.get_users();
} catch (err) {
throw err;
}
let user = users[name];
if (!user) return callback(new Error('cannot find user'));
let verified = await hash_check(name, pass);
if (verified) {
return callback(null, user);
} else {
return callback(new Error('invalid password'));
}
}
exports.restrict = function(req, res, next) {
if (req.session.user) {
next();
} else {
req.session.error = 'Access denied!';
res.redirect('/login');
}
}

View File

@ -0,0 +1,559 @@
/*
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
*/
const fs = require('fs');
const ipaddr = require('ip-address');
const storage = require('node-persist');
const zt = require('./zt');
storage.initSync({dir: 'etc/storage'});
// ZT network controller home page
exports.index = async function(req, res) {
const page = 'controller_home';
try {
zt_address = await zt.get_zt_address();
res.render('index', {title: 'ztncui', page: page, zt_address: zt_address});
} catch (err) {
res.render('index', {title: 'ztncui',
page: page, error: 'ERROR resolving ZT address: ' + err});
}
};
// Display list of all networks on this ZT network controller
exports.network_list = async function(req, res) {
const page = 'networks';
try {
networks = await zt.network_list();
res.render('networks', {title: 'Networks on this controller', page: page, networks: networks});
} catch (err) {
res.render('networks', {title: 'Networks on this controller', page: page, error: 'Error retrieving list of networks on this controller: ' + err});
}
};
// Display detail page for specific network
exports.network_detail = async function(req, res) {
const page = 'networks';
try {
const network = await zt.network_detail(req.params.nwid);
const members = await zt.members(req.params.nwid);
res.render('network_detail', {title: 'Detail for network', page: page, network: network, members: members});
} catch (err) {
res.render('network_detail', {title: 'Detail for network', page: page, error: 'Error resolving detail for network ' + req.params.nwid + ': ' + err});
}
};
// Display Network create form on GET
exports.network_create_get = function(req, res) {
const page = 'add_network';
res.render('network_create', {title: 'Create network', page: page});
};
// Handle Network create on POST
exports.network_create_post = async function(req, res) {
const page = 'add_network';
req.checkBody('name', 'Network name required').notEmpty();
req.sanitize('name').escape();
req.sanitize('name').trim();
const errors = req.validationErrors();
const name = { name: req.body.name };
if (errors) {
res.render('network_create', {title: 'Create Network', page: page, name: name, errors: errors});
return;
} else {
try {
const network = await zt.network_create(name);
res.redirect('/controller/networks');
} catch (err) {
res.render('network_detail', {title: 'Create Network - error', page: page, error: 'Error creating network ' + name.name});
}
}
};
// Display Network delete form on GET
exports.network_delete_get = async function(req, res) {
const page = 'networks';
try {
const network = await zt.network_detail(req.params.nwid);
res.render('network_delete', {title: 'Delete network', page: page,
nwid: req.params.nwid, network: network});
} catch (err) {
res.render('network_delete', {title: 'Delete network', page: page, error: 'Error resolving network ' + req.params.nwid + ': ' + err});
}
};
// Handle Network delete on POST
exports.network_delete_post = async function(req, res) {
const page = 'networks';
try {
const network = await zt.network_delete(req.params.nwid);
res.render('network_delete', {title: 'Delete network', page: page, network: network});
} catch (err) {
res.render('network_delete', {title: 'Delete network', page: page, error: 'Error deleting network ' + req.params.nwid + ': ' + err});
}
};
// Network object GET
exports.network_object = async function(req, res) {
const page = 'networks';
try {
const network = await zt.network_detail(req.params.nwid);
res.render(req.params.object, {title: req.params.object, page: page, network: network}, function(err, html) {
if (err) {
if (err.message.indexOf('Failed to lookup view') !== -1 ) {
return res.render('not_implemented', {title: req.params.object, page: page, network: network});
}
throw err;
}
res.send(html);
});
} catch (err) {
res.render(req.params.object, {title: req.params.object, page: page, error: 'Error resolving detail for network ' + req.params.nwid + ': ' + err});
}
}
// Handle Network rename form on POST
exports.name = async function(req, res) {
const page = 'networks';
req.checkBody('name', 'Network name required').notEmpty();
req.sanitize('name').escape();
req.sanitize('name').trim();
const errors = req.validationErrors();
const name = { name: req.body.name };
if (errors) {
try {
const network = await zt.network_detail(req.params.nwid);
res.render('name', {title: 'Rename network', page: page, network: network, name: name, errors: errors});
} catch (err) {
res.render('name', {title: 'Rename network', page: page, error: 'Error resolving network detail for network ' + req.params.nwid + ': ' + err});
}
} else {
try {
const network = await zt.network_object(req.params.nwid, name);
res.redirect('/controller/networks');
} catch ( err) {
res.render('name', {title: 'Rename network', page: page, error: 'Error renaming network ' + req.params.nwid + ': ' + err});
}
}
};
// ipAssignmentPools POST
exports.ipAssignmentPools = async function(req, res) {
const page = 'networks';
req.checkBody('ipRangeStart', 'IP range start required').notEmpty();
req.checkBody('ipRangeStart', 'IP range start needs a valid IPv4 or IPv6 address').isIP();
req.sanitize('ipRangeStart').escape();
req.sanitize('ipRangeStart').trim();
req.checkBody('ipRangeEnd', 'IP range end required').notEmpty();
req.checkBody('ipRangeEnd', 'IP range end needs a valid IPv4 or IPv6 address').isIP();
req.sanitize('ipRangEnd').escape();
req.sanitize('ipRangEnd').trim();
const errors = req.validationErrors();
const ipAssignmentPool =
{
ipRangeStart: req.body.ipRangeStart,
ipRangeEnd: req.body.ipRangeEnd
};
if (errors) {
try {
const network = await zt.network_detail(req.params.nwid);
res.render('ipAssignmentPools', {title: 'ipAssignmentPools', page: page, ipAssignmentPool: ipAssignmentPool, network: network, errors: errors});
} catch (err) {
res.render('ipAssignmentPools', {title: 'ipAssignmentPools', page: page, error: 'Error resolving network detail for network ' + req.params.nwid + ': ' + err});
}
} else {
try {
const network = await zt.ipAssignmentPools(req.params.nwid, ipAssignmentPool, 'add');
res.render('ipAssignmentPools', {title: 'ipAssignmentPools', page: page, ipAssignmentPool: ipAssignmentPool, network: network});
} catch (err) {
res.render('ipAssignmentPools', {title: 'ipAssignmentPools', page: page, error: 'Error applying IP Assignment Pools for network ' + req.params.nwid + ': ' + err});
}
}
}
isValidPrefix = function(str, max) {
const num = Math.floor(Number(str));
return String(num) == str && num >= 0 && num <= max;
}
// routes POST
exports.routes = async function (req, res) {
const page = 'networks';
req.checkBody('target', 'Target network is required').notEmpty();
req.sanitize('target').trim();
req.checkBody('target', 'Target network must be valid CIDR format')
.custom(value => {
const parts = value.split('/');
const ipv4 = new ipaddr.Address4(parts[0]);
const ipv6 = new ipaddr.Address6(parts[0]);
let isValidIPv4orIPv6 = false;
let prefixMax = 32;
if (ipv4.isValid()) {
isValidIPv4orIPv6 = true;
} else {
}
if (ipv6.isValid()) {
isValidIPv4orIPv6 = true;
prefixMax = 128;
} else {
}
return isValidIPv4orIPv6 && isValidPrefix(parts[1], prefixMax);
});
req.checkBody('via', 'Gateway must be a valid IPv4 or IPv6 address').optional({ checkFalsy: true }).isIP();
req.sanitize('via').escape();
req.sanitize('via').trim();
if (! req.body.via) {
req.body.via = null;
}
const errors = req.validationErrors();
const route =
{
target: req.body.target,
via: req.body.via
};
if (errors) {
try {
const network = await zt.network_detail(req.params.nwid);
res.render('routes', {title: 'routes', page: page, route: route, network: network, errors: errors});
} catch (err) {
res.render('routes', {title: 'routes', page: page, error: 'Error resolving network detail'});
}
} else {
try {
const network = await zt.routes(req.params.nwid, route, 'add');
res.render('routes', {title: 'routes', page: page, route: route, network: network});
} catch (err) {
res.render('routes', {title: 'routes', page: page, error: 'Error adding route for network ' + req.params.nwid + ': ' + err});
}
}
}
// route_delete GET
exports.route_delete = async function (req, res) {
const page = 'networks';
const route =
{
target: req.params.target_ip + '/' + req.params.target_prefix,
via: null
};
try {
const network = await zt.routes(req.params.nwid, route, 'delete');
res.render('routes', {title: 'routes', page: page, route: route, network: network});
} catch (err) {
res.render('routes', {title: 'routes', page: page, error: 'Error deleting route for network ' + req.params.nwid + ': ' + err});
}
}
// ipAssignmentPool_delete GET
exports.ipAssignmentPool_delete = async function (req, res) {
const page = 'networks';
const ipAssignmentPool =
{
ipRangeStart: req.params.ipRangeStart,
ipRangeEnd: req.params.ipRangeEnd
};
try {
const network = await zt.ipAssignmentPools(req.params.nwid, ipAssignmentPool, 'delete');
res.render('ipAssignmentPools', {title: 'ipAssignmentPools', page: page, ipAssignmentPool: ipAssignmentPool, network: network});
} catch (err) {
res.render('ipAssignmentPools', {title: 'ipAssignmentPools', page: page, error: 'Error deleting IP Assignment Pool for network ' + req.params.nwid + ': ' + err});
}
}
// v4AssignMode POST
exports.v4AssignMode = async function (req, res) {
const page = 'networks';
const v4AssignMode =
{
v4AssignMode: { zt: req.body.zt }
};
try {
const network = await zt.network_object(req.params.nwid, v4AssignMode);
res.render('v4AssignMode', {title: 'v4AssignMode', page: page, network: network});
} catch (err) {
res.render('v4AssignMode', {title: 'v4AssignMode', page: page, error: 'Error applying v4AssignMode for network ' + req.params.nwid + ': ' + err});
}
}
// v6AssignMode POST
exports.v6AssignMode = async function (req, res) {
const page = 'networks';
const v6AssignMode =
{
v6AssignMode:
{
'6plane': req.body['6plane'],
rfc4193: req.body.rfc4193,
zt: req.body.zt
}
};
try {
const network = await zt.network_object(req.params.nwid, v6AssignMode);
res.render('v6AssignMode', {title: 'v6AssignMode', page: page, network: network});
} catch (err) {
res.render('v6AssignMode', {title: 'v6AssignMode', page: page, error: 'Error applying v6AssignMode for network ' + req.params.nwid + ': ' + err});
}
}
// Display detail page for specific member
exports.member_detail = async function(req, res) {
const page = 'networks';
try {
const network = await zt.network_detail(req.params.nwid);
const member = await zt.member_detail(req.params.nwid, req.params.id);
res.render('member_detail', {title: 'Network member detail', page: page, network: network, member: member});
} catch (err) {
res.render(req.params.object, {title: req.params.object, page: page, error: 'Error resolving detail for member ' + req.params.id + ' of network ' + req.params.nwid + ': ' + err});
}
};
// Member object GET
exports.member_object = async function(req, res) {
const page = 'networks';
try {
const network = await zt.network_detail(req.params.nwid);
const member = await zt.member_detail(req.params.nwid, req.params.id);
res.render(req.params.object, {title: req.params.object, page: page, network: network, member: member}, function(err, html) {
if (err) {
if (err.message.indexOf('Failed to lookup view') !== -1 ) {
return res.render('not_implemented', {title: req.params.object, page: page, network: network, member: member});
}
throw err;
}
res.send(html);
});
} catch (err) {
res.render(req.params.object, {title: req.params.object, page: page, error: 'Error resolving detail for member ' + req.params.id + ' of network ' + req.params.nwid + ': ' + err});
}
}
// Member authorized POST
exports.member_authorized = async function(req, res) {
const page = 'networks';
const authorized = { authorized: req.body.authorized };
try {
const network = await zt.network_detail(req.params.nwid);
const member = await zt.member_object(req.params.nwid, req.params.id, authorized);
res.render('authorized', {title: 'authorized', page: page, network: network, member: member});
} catch (err) {
res.render('authorized', {title: 'authorized', page: page, error: 'Error authorizing member ' + req.params.id + ' on network ' + req.params.nwid + ': ' + err});
}
}
// Easy network setup GET
exports.easy_get = async function(req, res) {
const page = 'networks';
try {
const network = await zt.network_detail(req.params.nwid);
res.render('network_easy', {title: 'Easy setup of network', page: page, network: network});
} catch (err) {
res.render('network_easy', {title: 'Easy setup of network', page: page, error: 'Error resolving detail for network ' + req.params.nwid + ': ' + err});
}
}
// Easy network setup POST
exports.easy_post = async function(req, res) {
const page = 'networks';
req.checkBody('networkCIDR', 'Network address is required').notEmpty();
req.sanitize('networkCIDR').trim();
req.checkBody('networkCIDR', 'Network address must be in CIDR notation')
.custom(value => {
const parts = value.split('/');
const ipv4 = new ipaddr.Address4(parts[0]);
return ipv4.isValid() && isValidPrefix(parts[1], 32);
});
req.checkBody('poolStart', 'Start of IP assignment pool is required')
.notEmpty();
req.checkBody('poolStart', 'Start of IP assignment pool must be valid IPv4 address')
.isIP(4);
req.sanitize('poolStart').escape();
req.sanitize('poolStart').trim();
req.checkBody('poolEnd', 'End of IP assignment pool is required')
.notEmpty();
req.checkBody('poolEnd', 'End of IP assignment pool must be valid IPv4 address')
.isIP(4);
req.sanitize('poolEnd').escape();
req.sanitize('poolEnd').trim();
const errors = req.validationErrors();
const ipAssignmentPools =
[{
ipRangeStart: req.body.poolStart,
ipRangeEnd: req.body.poolEnd
}];
const routes =
[{
target: req.body.networkCIDR,
via: null
}];
const v4AssignMode =
{
zt: true
};
if (errors) {
network =
{
ipAssignmentPools: ipAssignmentPools,
routes: routes,
v4AssignMode: v4AssignMode
};
res.render('network_easy', {title: 'Easy setup of network', page: page, network: network, errors: errors});
} else {
try {
const network = await zt.network_easy_setup(req.params.nwid,
routes,
ipAssignmentPools,
v4AssignMode);
res.render('network_easy', {title: 'Easy setup of network', page: page, network: network, message: 'Network setup succeeded'});
} catch (err) {
res.render('network_easy', {title: 'Easy setup of network', page: page, error: 'Error resolving detail for network ' + req.params.nwid + ': ' + err});
}
}
}
// Easy members auth GET or POST
exports.members = async function(req, res) {
const page = 'networks';
let errors = null;
if (req.method === 'POST') {
req.checkBody('id', 'Member ID is required').notEmpty();
req.sanitize('id').trim();
req.sanitize('id').escape();
if (req.body.auth) {
req.checkBody('auth', 'Authorization state must be boolean').isBoolean();
req.sanitize('auth').trim();
req.sanitize('auth').escape();
errors = req.validationErrors();
if (!errors) {
const auth =
{
authorized: req.body.auth
};
try {
const mem = await zt.member_object(req.params.nwid, req.body.id, auth);
} catch (err) {
throw err;
}
}
} else if (req.body.name) {
req.sanitize('name').trim();
req.sanitize('name').escape();
errors = req.validationErrors();
if (!errors) {
try {
const ret = await storage.setItem(req.body.id, req.body.name);
} catch (err) {
throw err;
}
}
}
}
try {
const network = await zt.network_detail(req.params.nwid);
const member_ids = await zt.members(req.params.nwid);
const members = [];
for (id in member_ids) {
let member = await zt.member_detail(req.params.nwid, id);
let name = await storage.getItem(member.id);
if (!name) name = '';
member.name = name;
members.push(member);
}
res.render('members', {title: 'Members of this network', page: page,
network: network, members: members, errors: errors});
} catch (err) {
res.render('members', {title: 'Members of this network', page: page,
error: 'Error resolving detail for network ' + req.params.nwid
+ ': ' + err});
}
}
// Member delete GET and POST
exports.member_delete = async function(req, res) {
const page = 'networks';
try {
const network = await zt.network_detail(req.params.nwid);
let member = null;
let name = null;
if (req.method === 'POST') {
member = await zt.member_delete(req.params.nwid, req.params.id);
if (member.deleted) {
name = await storage.removeItem(member.id);
}
} else {
member = await zt.member_detail(req.params.nwid, req.params.id);
name = await storage.getItem(member.id);
}
if (!name) name = '';
member.name = name;
res.render('member_delete', {title: 'Delete member from ' + network.name,
network: network, member: member});
} catch (err) {
res.render('member_delete', {title: 'Delete member from network', page: page,
error: 'Error resolving detail for member ' + req.params.id
+ ' of network ' + req.params.nwid + ': ' + err});
}
}

25
controllers/token.js Normal file
View File

@ -0,0 +1,25 @@
/*
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
*/
const fs = require('fs');
const util = require('util');
const readFile = util.promisify(fs.readFile);
let _token = null;
exports.get = async function() {
if (_token) {
return _token;
} else {
try {
_token = await readFile('/var/lib/zerotier-one/authtoken.secret', 'utf8');
return _token;
} catch(err) {
throw(err);
}
}
}

View File

@ -0,0 +1,173 @@
/*
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
*/
const fs = require('fs');
const argon2 = require('argon2');
const util = require('util');
const passwd_file = 'etc/passwd';
const min_pass_len = 10;
const readFile = util.promisify(fs.readFile);
const writeFile = util.promisify(fs.writeFile);
const chmod = util.promisify(fs.chmod);
let _users = null;
get_users = async function() {
if (_users) {
return _users;
} else {
try {
_users = JSON.parse(await readFile(passwd_file, 'utf8'));
return _users;
} catch(err) {
throw(err);
}
}
}
exports.get_users = get_users;
update_users = async function(users) {
try {
await writeFile(passwd_file, JSON.stringify(users), 'utf8');
await chmod(passwd_file, 0600);
} catch (err) {
throw err;
}
_users = null;
return await get_users();
}
exports.users_list = async function(req, res) {
const page = 'users';
try {
const users = await get_users();
res.render('users', { title: 'Admin users', page: page, message: 'List of users with admin priviledges', users: users });
} catch (err) {
res.render('users', { title: 'Admin users', page: page, message: 'Error', users: null, error: 'Error returning list of users: ' + err });
}
}
exports.password_get = async function(req, res) {
const page = 'users';
const user =
{
name: req.params.name,
password1: null,
password2: null
};
res.render('password', { title: 'Set password', page: page, user: user, readonly: true, message: '' });
}
exports.password_post = async function(req, res) {
const page = 'users';
req.checkBody('username', 'Username required').notEmpty();
req.sanitize('username').escape();
req.sanitize('username').trim();
req.checkBody('password1', 'Password required').notEmpty();
req.checkBody('password1', 'Minimum password length is ' + min_pass_len + ' characters').isLength({ min: min_pass_len, max: 160 });
req.checkBody('password2', 'Please re-enter password').notEmpty();
req.checkBody('password2', 'Minimum password length is ' + min_pass_len + ' characters').isLength({ min: min_pass_len, max: 160 });
req.checkBody('password2', 'Passwords are not the same').equals(req.body.password1);
const errors = req.validationErrors();
if (errors) {
const user =
{
name: req.body.username,
password1: req.body.password1,
password2: req.body.password2
};
const message = 'Please check errors below';
res.render('password', { title: 'Set password', page: page, user: user, readonly: true, message: message, errors: errors });
} else {
let pass_set = true;
if (req.body.pass_set === 'check') pass_set = false;
const hash = await argon2.hash(req.body.password1);
const user =
{
name: req.body.username,
pass_set: pass_set,
hash: hash
};
const passwd_user =
{
[req.body.username]: user
};
let users = await get_users();
users[req.body.username] = user;
users = await update_users(users);
const message = 'Successfully set password for ' + req.body.username;
res.render('password', { title: 'Set password', page: page, user: user, readonly: true, message: message });
}
}
exports.user_create_get = async function(req, res) {
const page = 'create_user';
const user =
{
name: null,
password1: null,
password2: null
};
res.render('password', { title: 'Create new admin user', page: page, user: user, readonly: false});
}
exports.user_create_post = async function(req, res) {
const page = 'create_user';
res.redirect(307, '/users/' + req.body.username + '/password');
}
exports.user_delete = async function(req, res) {
const page = 'users';
try {
var users = await get_users();
} catch (err) {
throw err;
}
const user = users[req.params.name];
if (user && (req.session.user.name === user.name)) {
res.render('user_delete', { title: 'Delete user', page: page, user: user, self_delete: true });
}
if (req.body.delete === 'delete') {
if (user) {
const deleted_user = { name: user.name };
delete users[user.name];
users = await update_users(users);
res.render('user_delete', { title: 'Deleted user', page: page, user: deleted_user, deleted: true });
} else {
res.render('user_delete', { title: 'Delete user', page: page, user: null });
}
} else {
if (user) {
res.render('user_delete', { title: 'Delete user', page: page, user: user });
} else {
res.render('user_delete', { title: 'Delete user', page: page, user: null });
}
}
}

266
controllers/zt.js Normal file
View File

@ -0,0 +1,266 @@
/*
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
*/
const got = require('got');
const ipaddr = require('ip-address');
const token = require('./token');
init_options = async function() {
let tok = null;
try {
tok = await token.get();
} catch (err) {
throw(err);
}
options = {
json: true,
headers: {
'X-ZT1-Auth': tok
}
}
return options;
}
get_zt_address = async function() {
const options = await init_options();
try {
const response = await got('localhost:9993/status', options);
return response.body.address;
} catch(err) {
throw(err);
}
}
exports.get_zt_address = get_zt_address;
exports.network_list = async function() {
const options = await init_options();
let network = {};
let networks = [];
let nwids = [];
try {
const response = await got('localhost:9993/controller/network', options);
nwids = response.body;
} catch(err) {
throw(err);
}
for (let nwid of nwids) {
try {
const response = await got('localhost:9993/controller/network/'
+ nwid, options);
network = (({name, nwid}) => ({name, nwid}))(response.body);
networks.push(network);
} catch(err) {
throw(err);
}
}
return networks;
}
network_detail = async function(nwid) {
const options = await init_options();
try {
const response = await got('localhost:9993/controller/network/'
+ nwid, options);
return response.body;
} catch(err) {
throw(err);
}
}
exports.network_detail = network_detail;
exports.network_create = async function(name) {
const options = await init_options();
options.method = 'POST';
options.body = name;
const zt_address = await get_zt_address();
try {
const response = await got('localhost:9993/controller/network/'
+ zt_address + '______', options);
return response.body;
} catch(err) {
throw(err);
}
}
exports.network_delete = async function(nwid) {
const options = await init_options();
options.method = 'DELETE';
try {
const response = await got('localhost:9993/controller/network/'
+ nwid, options);
response.body.deleted = true;
return response.body;
} catch(err) {
throw(err);
}
}
exports.ipAssignmentPools = async function(nwid, ipAssignmentPool, action) {
const options = await init_options();
options.method = 'POST';
const network = await network_detail(nwid);
let ipAssignmentPools = network.ipAssignmentPools;
if (action === 'add') {
ipAssignmentPools.push(ipAssignmentPool);
} else if (action === 'delete') {
const pool = ipAssignmentPools.find(pool =>
pool.ipRangeStart === ipAssignmentPool.ipRangeStart &&
pool.ipRangeEnd === ipAssignmentPool.ipRangeEnd);
ipAssignmentPools = ipAssignmentPools.filter(p => p != pool);
}
options.body = { ipAssignmentPools: ipAssignmentPools };
try {
const response = await got('localhost:9993/controller/network/'
+ nwid, options);
return response.body;
} catch(err) {
throw(err);
}
}
exports.routes = async function(nwid, route, action) {
const options = await init_options();
options.method = 'POST';
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];
}
const route_to_del = routes.find(rt => rt.target === route.target);
if (!route_to_del) {
if (action === 'add') {
routes.push(route);
} else if (action === 'delete') {
throw new Error('Cannot delete non-existent route target');
}
} else {
if (action === 'add') {
throw new Error('Route target is not unique');
} else if (action === 'delete') {
routes = routes.filter(rt => rt != route_to_del);
}
}
options.body = { routes: routes };
try {
const response = await got('localhost:9993/controller/network/'
+ nwid, options);
return response.body;
} catch(err) {
throw(err);
}
}
exports.network_object = async function(nwid, object) {
const options = await init_options();
options.method = 'POST';
options.body = object;
try {
const response = await got('localhost:9993/controller/network/'
+ nwid, options);
return response.body;
} catch(err) {
throw(err);
}
}
exports.members = async function(nwid) {
const options = await init_options();
try {
const response = await got('localhost:9993/controller/network/'
+ nwid + '/member', options);
return response.body;
} catch(err) {
throw(err);
}
}
exports.member_detail = async function(nwid, id) {
const options = await init_options();
try {
const response = await got('localhost:9993/controller/network/'
+ nwid + '/member/' + id, options);
return response.body;
} catch(err) {
throw(err);
}
}
exports.member_object = async function(nwid, id, object) {
const options = await init_options();
options.method = 'POST';
options.body = object;
try {
const response = await got('localhost:9993/controller/network/'
+ nwid + '/member/' + id, options);
return response.body;
} catch(err) {
throw(err);
}
}
exports.member_delete = async function(nwid, id) {
const options = await init_options();
options.method = 'DELETE';
try {
const response = await got('localhost:9993/controller/network/'
+ nwid + '/member/' + id, options);
response.body.deleted = true;
return response.body;
} catch(err) {
throw(err);
}
}
exports.network_easy_setup = async function(nwid,
routes,
ipAssignmentPools,
v4AssignMode) {
const options = await init_options();
options.method = 'POST';
options.body =
{
ipAssignmentPools: ipAssignmentPools,
routes: routes,
v4AssignMode: v4AssignMode
};
try {
const response = await got('localhost:9993/controller/network/'
+ nwid, options);
return response.body;
} catch(err) {
throw(err);
}
}

1
etc/passwd Normal file
View File

@ -0,0 +1 @@
{"admin":{"name":"admin","pass_set":false,"hash":"$argon2i$v=19$m=4096,t=3,p=1$/VYxjWHBzbkuCEO6Hh0AUw$nJaTJtth57vCAyYvg+UbtnscilR0UcE02AfLOhERe3A"}}

3401
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

29
package.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "ztncui",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"devstart": "nodemon ./bin/www"
},
"dependencies": {
"argon2": "^0.16.2",
"body-parser": "~1.18.2",
"bootstrap": "^3.3.7",
"cookie-parser": "~1.4.3",
"debug": "~3.1.0",
"express": "~4.16.2",
"express-session": "^1.15.6",
"express-validator": "^4.3.0",
"got": "^7.1.0",
"ip-address": "^5.8.9",
"jquery": "^3.2.1",
"morgan": "~1.9.0",
"node-persist": "^2.1.0",
"pug": "2.0.0-rc.4",
"serve-favicon": "~2.4.5"
},
"devDependencies": {
"nodemon": "^1.12.5"
}
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

View File

@ -0,0 +1,107 @@
html, body {
height: 100%;
font: 16px "Lucida Grande", Helvetica, Arial, sans-serif;
}
input[type=checkbox] {
transform: scale(1.5);
}
input[type=radio] {
transform: scale(1.5);
}
.navbar-inverse {
background-color: #315b80;
border-color: #23415c;
}
.navbar-inverse .navbar-brand {
color: #ecf0f1;
}
.navbar-inverse .navbar-brand:hover,
.navbar-inverse .navbar-brand:focus {
color: #ffffff;
}
.navbar-inverse .navbar-text {
color: #ecf0f1;
}
.navbar-inverse .navbar-nav > li > a {
color: #ecf0f1;
}
.navbar-inverse .navbar-nav > li > a:hover,
.navbar-inverse .navbar-nav > li > a:focus {
color: #ffffff;
}
.navbar-inverse .navbar-nav > li > .dropdown-menu {
background-color: #315b80;
}
.navbar-inverse .navbar-nav > li > .dropdown-menu > li > a {
color: #ecf0f1;
}
.navbar-inverse .navbar-nav > li > .dropdown-menu > li > a:hover,
.navbar-inverse .navbar-nav > li > .dropdown-menu > li > a:focus {
color: #ffffff;
background-color: #23415c;
}
.navbar-inverse .navbar-nav > li > .dropdown-menu > li.divider {
background-color: #23415c;
}
.navbar-inverse .navbar-nav .open .dropdown-menu > .active > a,
.navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover,
.navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus {
color: #ffffff;
background-color: #23415c;
}
.navbar-inverse .navbar-nav > .active > a,
.navbar-inverse .navbar-nav > .active > a:hover,
.navbar-inverse .navbar-nav > .active > a:focus {
color: #ffffff;
background-color: #23415c;
}
.navbar-inverse .navbar-nav > .open > a,
.navbar-inverse .navbar-nav > .open > a:hover,
.navbar-inverse .navbar-nav > .open > a:focus {
color: #ffffff;
background-color: #23415c;
}
.navbar-inverse .navbar-toggle {
border-color: #23415c;
}
.navbar-inverse .navbar-toggle:hover,
.navbar-inverse .navbar-toggle:focus {
background-color: #23415c;
}
.navbar-inverse .navbar-toggle .icon-bar {
background-color: #ecf0f1;
}
.navbar-inverse .navbar-collapse,
.navbar-inverse .navbar-form {
border-color: #ecf0f1;
}
.navbar-inverse .navbar-link {
color: #ecf0f1;
}
.navbar-inverse .navbar-link:hover {
color: #ffffff;
}
@media (max-width: 767px) {
.navbar-inverse .navbar-nav .open .dropdown-menu > li > a {
color: #ecf0f1;
}
.navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover,
.navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus {
color: #ffffff;
}
.navbar-inverse .navbar-nav .open .dropdown-menu > .active > a,
.navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover,
.navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus {
color: #ffffff;
background-color: #23415c;
}
}
.navbar {
background-image: none;
}

54
routes/index.js Normal file
View File

@ -0,0 +1,54 @@
/*
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
*/
const express = require('express');
const auth = require('../controllers/auth');
const authenticate = auth.authenticate;
const restrict = auth.restrict;
const router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('front_door', {title: 'ztncui'});
});
router.get('/logout', function(req, res) {
req.session.destroy(function() {
res.redirect('/');
});
});
router.get('/login', function(req, res) {
let message = null;
if (req.session.error) {
if (req.session.error !== 'Access denied!') {
message = req.session.error;
}
} else {
message = req.session.success;
}
res.render('login', { title: 'Login', message: message });
});
router.post('/login', async function(req, res) {
await authenticate(req.body.username, req.body.password, function(err, user) {
if (user) {
req.session.regenerate(function() {
req.session.user = user;
req.session.success = 'Authenticated as ' + user.name;
if (user.pass_set) {
res.redirect('/controller');
} else {
res.redirect('/users/' + user.name + '/password');
}
});
} else {
req.session.error = 'Authentication failed, please check your username and password.'
res.redirect('/login');
}
});
});
module.exports = router;

34
routes/users.js Normal file
View File

@ -0,0 +1,34 @@
/*
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
*/
const express = require('express');
const router = express.Router();
const auth = require('../controllers/auth');
const restrict = auth.restrict;
const usersController = require('../controllers/usersController');
// GET request for users
router.get('/', restrict, usersController.users_list);
// GET request for password
router.get('/:name/password', restrict, usersController.password_get);
// POST request for password
router.post('/:name/password', restrict, usersController.password_post);
// GET request for user create
router.get('/create', restrict, usersController.user_create_get);
// POST request for user create
router.post('/create', restrict, usersController.user_create_post);
// GET request for user delete
router.get('/:name/delete', restrict, usersController.user_delete);
// POST request for user delete
router.post('/:name/delete', restrict, usersController.user_delete);
module.exports = router;

90
routes/zt_controller.js Normal file
View File

@ -0,0 +1,90 @@
/*
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
*/
const express = require('express');
const auth = require('../controllers/auth');
const restrict = auth.restrict;
const router = express.Router();
var networkController = require('../controllers/networkController');
// network routes //
// GET ZT network controller home page
router.get('/', restrict, networkController.index);
// Get request for creating a network
router.get('/network/create', restrict, networkController.network_create_get);
// POST request for creating a network
router.post('/network/create', restrict, networkController.network_create_post);
// GET request to delete network
router.get('/network/:nwid/delete', restrict, networkController.network_delete_get);
// POST request to delete network
router.post('/network/:nwid/delete', restrict, networkController.network_delete_post);
// POST request for Network name
router.post('/network/:nwid/name', restrict, networkController.name);
// GET request for ipAssignmentPool delete
router.get('/network/:nwid/ipAssignmentPools/:ipRangeStart/:ipRangeEnd/delete', restrict, networkController.ipAssignmentPool_delete);
// POST request for ipAssignmentPools
router.post('/network/:nwid/ipAssignmentPools', restrict, networkController.ipAssignmentPools);
// GET request for route delete
router.get('/network/:nwid/routes/:target_ip/:target_prefix/delete', restrict, networkController.route_delete);
// POST request for routes
router.post('/network/:nwid/routes', restrict, networkController.routes);
// POST request for v4AssignMode
router.post('/network/:nwid/v4AssignMode', restrict, networkController.v4AssignMode);
// POST request for v6AssignMode
router.post('/network/:nwid/v6AssignMode', restrict, networkController.v6AssignMode);
// GET request for member delete
router.get('/network/:nwid/member/:id/delete', restrict, networkController.member_delete);
// POST request for member delete
router.post('/network/:nwid/member/:id/delete', restrict, networkController.member_delete);
// GET request for any member object
router.get('/network/:nwid/member/:id/:object', restrict, networkController.member_object);
// POST request for member authorized
router.post('/network/:nwid/member/:id/authorized', restrict, networkController.member_authorized);
// GET request for member detail
router.get('/network/:nwid/member/:id', restrict, networkController.member_detail);
// GET request for easy network setup
router.get('/network/:nwid/easy', restrict, networkController.easy_get);
// POST request for easy network setup
router.post('/network/:nwid/easy', restrict, networkController.easy_post);
// GET request for easy member (de)authorization
router.get('/network/:nwid/members', restrict, networkController.members);
// POST request for easy member (de)authorization
router.post('/network/:nwid/members', restrict, networkController.members);
// GET request for any network object
router.get('/network/:nwid/:object', restrict, networkController.network_object);
// GET request for one network
router.get('/network/:nwid', restrict, networkController.network_detail);
// GET request for list of all networks
router.get('/networks', restrict, networkController.network_list);
module.exports = router;

31
views/authorized.pug Normal file
View File

@ -0,0 +1,31 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
block net_content
h4 for member
a(href='../' + member.address) #{member.address}
form(method='POST' action='')
.radio
label
input(type='radio' name='authorized' value='true' checked=member.authorized)
| Yes
.radio
label
input(type='radio' name='authorized' value='false' checked=!member.authorized)
| No
.form-group(style='padding-top: 10px')
button.btn.btn-primary(type='submit') Submit
= ' '
a.btn.btn-default(href='../' + member.address name='cancel' role='button') Cancel
if errors
ul
for err in errors
li!= err.msg

View File

@ -0,0 +1,36 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends head_layout
block body_content
nav.navbar.navbar-inverse.navbar-fixed-top
.container-fluid
.navbar-header
button.navbar-toggle(type='button' data-toggle='collapse' data-target='#BarNav')
span.icon-bar
span.icon-bar
span.icon-bar
a.navbar-brand(href='https://key-networks.com' target='_blank') Key Networks
.collapse.navbar-collapse(id='BarNav')
ul.nav.navbar-nav
li(class=(page === 'controller_home'? 'active' : ''))
a(href='/controller') Home
li(class=(page === 'users'? 'active' : ''))
a(href='/users') Users
li(class=(page === 'networks'? 'active' : ''))
a(href='/controller/networks') Networks
li(class=(page === 'add_network'? 'active' : ''))
a(href='/controller/network/create') Add network
ul.nav.navbar-nav.navbar-right
li
a(href='/logout')
span.glyphicon.glyphicon-log-out
| Logout
.container(style='margin-top:50px')
.row
.col-sm-12
block content

6
views/error.pug Normal file
View File

@ -0,0 +1,6 @@
extends controller_layout
block content
h1= message
h2= error.status
pre #{error.stack}

13
views/front_door.pug Normal file
View File

@ -0,0 +1,13 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends login_layout
block login_content
h1!= title
h2
a(href='https://zerotier.com' target='_blank') ZeroTier
| network controller UI

17
views/head_layout.pug Normal file
View File

@ -0,0 +1,17 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
doctype html
html(lang='en')
head
title= title
meta(charset='utf-8')
meta(name='viewport', content='width=device-width, initial-scale=1')
link(rel='stylesheet', href='/bscss/bootstrap.min.css')
link(rel='stylesheet', href='/stylesheets/style.css')
script(src='/jqjs/jquery.min.js')
script(src='/bsjs/bootstrap.min.js')
body
block body_content

22
views/index.pug Normal file
View File

@ -0,0 +1,22 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends controller_layout
block content
h1!= title
h2
a(href='https://zerotier.com' target='_blank') ZeroTier
| network controller UI
h3 Network controller details
if error
b #{error}
else
p This network controller has a ZeroTier address of <b>#{zt_address}</b>
a(href='/controller/networks') List all networks on this network controller

View File

@ -0,0 +1,52 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
block net_content
.row
.col-sm-12
table.table.table-responsive.table-striped.table-hover
tr
th
th IP range start
th IP range end
each ipAssignmentPool in network.ipAssignmentPools
tr
td(width='3%')
a(href='/controller/network/' + network.nwid + '/ipAssignmentPools/' + ipAssignmentPool.ipRangeStart + '/' + ipAssignmentPool.ipRangeEnd + '/delete')
i.glyphicon.glyphicon-trash
td= ipAssignmentPool.ipRangeStart
td= ipAssignmentPool.ipRangeEnd
.row
.col-sm-12
h3 Add new IP Assignment Pool:
form(method='POST' action='/controller/network/' + network.nwid + '/ipAssignmentPools')
.form-group.row
.col-sm-2
label(for='ipRangeStart') IP range start:
.col-sm-12
input#ipRangeStart.form-control(type='text' name='ipRangeStart' placeholder='IP range start' value=(undefined===ipAssignmentPool? '' : ipAssignmentPool.ipRangeStart))
.form-group.row
.col-sm-2
label(for='ipRangeEnd') IP range end:
.col-sm-12
input#ipRangeEnd.form-control(type='text' name='ipRangeEnd' placeholder='IP range end' value=(undefined===ipAssignmentPool? '' : ipAssignmentPool.ipRangeEnd))
.form-group.row
.col-sm-12
button.btn.btn-primary(type='submit') Submit
= ' '
a.btn.btn-default(href='/controller/network/' + network.nwid name='cancel' role='button') Cancel
if errors
.row
.col-sm-12
ul
for err in errors
li!= err.msg

44
views/login.pug Normal file
View File

@ -0,0 +1,44 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends login_layout
block login_content
if error
b #{error}
else
.row
.col-sm-12
h1= title
if message
.alert.alert-info
strong= message
form.form-horizontal(method='POST' action='')
.form-group.row
.col-sm-2
label.control-label(for='username') Username:
.col-sm-10
.input-group
span.input-group-addon
i.glyphicon.glyphicon-user
input#username.form-control(type='text' name='username' placeholder='Enter your username')
.form-group.row
.col-sm-2
label.control-label(for='password') Password:
.col-sm-10
.input-group
span.input-group-addon
i.glyphicon.glyphicon-lock
input#password.form-control(type='password' name='password' placeholder='Enter your password')
.form-group.row
.col-sm-12
button.btn.btn-primary(type='submit') Login
= ' '
a.btn.btn-default(href='/' name='cancel' role='button') Cancel

27
views/login_layout.pug Normal file
View File

@ -0,0 +1,27 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends head_layout
block body_content
nav.navbar.navbar-inverse.navbar-fixed-top
.container-fluid
.navbar-header
button.navbar-toggle(type='button' data-toggle='collapse' data-target='#BarNav')
span.icon-bar
span.icon-bar
span.icon-bar
a.navbar-brand(href='https://key-networks.com' target='_blank') Key Networks
.collapse.navbar-collapse(id='BarNav')
ul.nav.navbar-nav.navbar-right
li
a(href='/login')
span.glyphicon.glyphicon-log-in
| Login
.container(style='margin-top:50px')
.row
.col-sm-12
block login_content

28
views/member_delete.pug Normal file
View File

@ -0,0 +1,28 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
block net_content
if member.deleted
.alert.alert-success
strong #{member.name} (#{member.id}) was deleted
a.btn.btn-default(href='../../members' name='networks' role='button') Members
else
.alert.alert-info
strong.
Note: To undo a member deletion, just get the member to
join the network again
form(method='POST' action='')
button.btn.btn-primary(type='submit', name='delete') Delete #{member.name} (#{member.id})
= ' '
a.btn.btn-default(href='/controller/network/' + network.nwid + '/members',
name='cancel', role='button') Cancel
if errors
ul
for err in errors
li!= err.msg

33
views/member_detail.pug Normal file
View File

@ -0,0 +1,33 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
block net_content
h4 for member
a(href= member.address) #{member.address}
each value, key in member
.row
.col-sm-2
a(href= member.address + '/' + key) #{key}:
.col-sm-10
- if ((!!value ) && (value.constructor == Object))
p {
each v2, k2 in value
p #{k2}: #{v2},
p }
- else if ((!!value ) && (value.constructor == Array))
p [
each elem in value
p {
each v2, k2 in elem
p #{k2}: #{v2},
p }
p ]
- else
| #{value}
a.btn.btn-default(href='../members' name='networks' role='button') Members

64
views/members.pug Normal file
View File

@ -0,0 +1,64 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
block net_content
script.
$(function() {
$('.checkbox').on('click', function() {
$.post('', {id: this.value, auth: this.checked});
});
});
$(function() {
$('.text').on('change', function() {
$.post('', {id: this.name, name: this.value});
});
});
form(method='POST' action='')
table.table.table-responsive.table-striped.table-hover
tr
td(width='3%')
= ''
td(width='20%')
| Member name
td(width='10%')
| Member ID
td(width='10%')
| Authorized
td(width='57%')
| IP assignment
each member in members
tr
- let url = '/controller/network/' + network.nwid + '/member/' + member.id
td
a(href=url + '/delete')
i.glyphicon.glyphicon-trash
td
input.form-control.text(type='text' name=member.id value=member.name)
td
a(href=url) #{member.id}
td
input.checkbox(type='checkbox' name='authCheckBox' value=member.id checked=(member.authorized? true : false))
td
each ipAssignment in member.ipAssignments
each digit in ipAssignment
= digit
= ' '
else
.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
ul
for err in errors
li!= err.msg

28
views/name.pug Normal file
View File

@ -0,0 +1,28 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
block net_content
form(method='POST' action='')
.form-group.row
.col-sm-2
label(for='name') Network name:
.col-sm-10
input#name.form-control(type='text' name='name' placeholder='New network name' value=(undefined===network.name? '' : network.name))
.form-group.row
.col-sm-12
button.btn.btn-primary(type='submit') Submit
= ' '
a.btn.btn-default(href='/controller/networks' name='cancel' role='button') Cancel
if errors
.row
.col-sm-12
ul
for err in errors
li!= err.msg

33
views/network_create.pug Normal file
View File

@ -0,0 +1,33 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends controller_layout
block content
.row
.col-sm-12
h1= title
if error
b #{error}
else
form(method='POST' action='')
.form-group.row
.col-sm-2
label(for='name') Network name:
.col-sm-10
input#name.form-control(type='text' name='name' placeholder='Enter new network name' value=(undefined===name ? '' : name.name))
.form-group.row
.col-sm-12
button.btn.btn-primary(type='submit') Create Network
if errors
.row
.col-sm-12
ul
for err in errors
li!= err.msg

24
views/network_delete.pug Normal file
View File

@ -0,0 +1,24 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
block net_content
if network.deleted
.alert.alert-success
strong #{network.name} (#{network.nwid}) was deleted
else
.alert.alert-danger
strong Warning! Deleting a network cannot be undone
form(method='POST' action='')
button.btn.btn-danger(type='submit', name='delete') Delete #{network.name} (#{network.nwid})
= ' '
a.btn.btn-default(href='/controller/networks', name='cancel', role='button') Cancel
if errors
ul
for err in errors
li!= err.msg

47
views/network_detail.pug Normal file
View File

@ -0,0 +1,47 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends controller_layout
block content
if error
b #{error}
else
h2
a(href= network.nwid + '/name') #{network.name}
| (#{network.nwid}):
- if (members !== undefined)
h3 Members
each value, key in members
.row
.col-sm-2
a(href= network.nwid + '/member/' + key) #{key}
.col-sm-10
| revision: #{value}
h3= title
each value, key in network
.row
.col-sm-2
a(href= network.nwid + '/' + key) #{key}:
.col-sm-10
- if ((!!value ) && (value.constructor == Object))
p {
each v2, k2 in value
p #{k2}: #{v2},
p }
- else if ((!!value ) && (value.constructor == Array))
p [
each elem in value
p {
each v2, k2 in elem
p #{k2}: #{v2},
p },
p ]
- else
| #{value}
a.btn.btn-default(href='/controller/networks' name='networks' role='button') Networks

88
views/network_easy.pug Normal file
View File

@ -0,0 +1,88 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
block net_content
script.
function randomOctet() {
return Math.floor(Math.random() * 255);
}
function randomIPv4() {
const networkCIDR = document.getElementById('networkCIDR');
const CIDR = '10.' + randomOctet() + '.' + randomOctet() + '.0/24';
networkCIDR.value = CIDR;
CIDRtoPool(CIDR);
}
function int32toIPv4String(int32) {
let ipv4 = '';
ipv4 = ((int32 & 0xff000000)>>>24).toString();
ipv4 += '.' + ((int32 & 0x00ff0000)>>>16).toString();
ipv4 += '.' + ((int32 & 0x0000ff00)>>>8).toString();
ipv4 += '.' + (int32 & 0x000000ff).toString();
return ipv4;
}
function CIDRtoPool(CIDR) {
const [start, prefix] = CIDR.split('/');
if (undefined !== start && undefined !== prefix &&
prefix > 0 && prefix < 33 &&
/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(start)
){
const host32 = ((1 << (32 - parseInt(prefix))) - 1) >>> 0;
const net = start.split('.').map(oct => {return parseInt(oct)});
let net32 = 0 >>> 0;
net32 = (net[0]<<24) + (net[1]<<16) + (net[2]<<8) + (net[3]);
net32 &= ~host32;
bcast32 = net32 + host32;
const networkCIDR = document.getElementById('networkCIDR');
const poolStart = document.getElementById('poolStart');
const poolEnd = document.getElementById('poolEnd');
networkCIDR.value = int32toIPv4String(net32) + '/' + prefix;
poolStart.value = int32toIPv4String(net32 + 1);
poolEnd.value = int32toIPv4String(bcast32 - 1);
} else {
poolStart.value = 'Invalid network CIDR';
poolEnd.value = 'Invalid network CIDR';
}
}
if message
.alert.alert-info
strong= message
form(method='POST' action='')
.form-group
button.btn.btn-link.float-right(type='button' data-toggle='collapse' data-target='#help') Help
.collapse(id='help')
p Please note that this utility only supports IPv4 at this stage.
p Use the following button to automatically generate a random network address, otherwise fill in the network address CIDR manually and the IP assignment pool will be automatically calculated for you. You can manually alter these calculated values.
.form-group
button.btn.btn-primary(id='genIPv4' type='button' onclick='randomIPv4()') Generate network address
.form-group
label(for='networkCIDR') Network address in CIDR notation
input#networkCIDR.form-control(type='text' name='networkCIDR' onchange='CIDRtoPool(this.value)' placeholder='e.g. 10.11.12.0/24' value=(undefined===network.routes[0]? '' : network.routes[0].target))
.form-group
label(for='poolStart') Start of IP assignment pool
input#poolStart.form-control(type='text' name='poolStart' placeholder='e.g. 10.11.12.1' value=(undefined===network.ipAssignmentPools[0]? '' : network.ipAssignmentPools[0].ipRangeStart))
.form-group
label(for='poolEnd') End of IP assignment pool
input#poolEnd.form-control(type='text' name='poolEnd' placeholder='e.g. 10.11.12.254' value=(undefined===network.ipAssignmentPools[0]? '' : network.ipAssignmentPools[0].ipRangeEnd))
.form-group(style='padding-top: 10px')
button.btn.btn-primary(type='submit') Submit
= ' '
a.btn.btn-default(href='/controller/networks' name='cancel' role='button') Cancel
if errors
ul
for err in errors
li!= err.msg

19
views/network_layout.pug Normal file
View File

@ -0,0 +1,19 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends controller_layout
block content
if error
b #{error}
else
.row
.col-sm-12
h2
a(href='/controller/network/' + network.nwid) #{network.name}
| (#{network.nwid}):
h3= title
block net_content

47
views/networks.pug Normal file
View File

@ -0,0 +1,47 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends controller_layout
block content
h1= title
if error
b #{error}
else
table.table.table-responsive.table-striped.table-hover
tr
td(width='3%')
= ''
td(width='20%')
| Network name
td(width='10%')
| Network ID
td(width='7%')
= ''
td(width='10%')
= ''
td(width='50%')
= ''
each network in networks
tr
td
a(href='/controller/network/' + network.nwid + '/delete')
i.glyphicon.glyphicon-trash
td
a(href='/controller/network/' + network.nwid + '/name') #{network.name}
td
= network.nwid
td
a(href='/controller/network/' + network.nwid) detail
td
a(href='/controller/network/' + network.nwid + '/easy') easy setup
td
a(href='/controller/network/' + network.nwid + '/members') members
else
tr
td There are no networks on this network controller

14
views/not_implemented.pug Normal file
View File

@ -0,0 +1,14 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
block net_content
- if (member !== undefined)
h4 for member
a(href='../' + member.address) #{member.address}
h4 Editing of
b #{title}
| has not been implemented

60
views/password.pug Normal file
View File

@ -0,0 +1,60 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends users_layout
block users_content
if message
.row
.col-sm-12
.alert.alert-info
strong= message
form.form-horizontal(method='POST' action='')
.form-group.row
.col-sm-2
label(for='username') Username:
.col-sm-10
.input-group
span.input-group-addon
i.glyphicon.glyphicon-user
input#username.form-control(type='text' name='username' placeholder='Enter username' value=user.name readonly=readonly)
.form-group.row
.col-sm-2
label(for='password1') Enter new password:
.col-sm-10
.input-group
span.input-group-addon
i.glyphicon.glyphicon-lock
input#password1.form-control(type='password' name='password1' placeholder='Enter new password' value=(undefined===user.password1? '' : user.password1))
.form-group.row
.col-sm-2
label(for='password2') Re-enter password:
.col-sm-10
.input-group
span.input-group-addon
i.glyphicon.glyphicon-lock
input#password2.form-control(type='password' name='password2' placeholder='Re-enter password' value=(undefined===user.password2? '' : user.password2))
.form-group.row
.col-sm-2
label(for='pass_set') Change password on next login:
.col-sm-10
input#pass_set(type='checkbox' name='pass_set' value='check')
.form-group.row
.col-sm-12
button.btn.btn-primary(type='submit') Set password
= ' '
a.btn.btn-default(href='/users' name='cancel' role='button') Cancel
if errors
.form-group.row
.col-sm-12
ul
for err in errors
li!= err.msg

52
views/routes.pug Normal file
View File

@ -0,0 +1,52 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
block net_content
.row
.col-sm-12
table.table.table-responsive.table-striped.table-hover
tr
th
th Target
th Gateway
each route in network.routes
tr
td(width='3%')
a(href='/controller/network/' + network.nwid + '/routes/' + route.target + '/delete')
i.glyphicon.glyphicon-trash
td= route.target
td= route.via
.row
.col-sm-12
h3 Add new route:
form(method='POST' action='/controller/network/' + network.nwid + '/routes')
.form-group.row
.col-sm-2
label(for='target') Target:
.col-sm-12
input#target.form-control(type='text' name='target' placeholder='e.g. 10.11.12.0/24' value=(undefined===route? '' : route.target))
.form-group.row
.col-sm-2
label(for='via') Gateway:
.col-sm-12
input#via.form-control(type='text' name='via' placeholder='e.g. 172.16.2.1 or leave blank if the target is the ZT network' value=(undefined===route? '' : route.via))
.form-group.row
.col-sm-2
button.btn.btn-primary(type='submit') Submit
= ' '
a.btn.btn-default(href='/controller/network/' + network.nwid name='cancel' role='button') Cancel
if errors
.row
.col-sm-12
ul
for err in errors
li!= err.msg

32
views/user_delete.pug Normal file
View File

@ -0,0 +1,32 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends users_layout
block users_content
if user === null
.alert.alert-warning
strong No such user
else if self_delete === true
.alert.alert-danger
strong You may not delete yourself
else if deleted
.alert.alert-success
strong #{user.name} was deleted
else
.alert.alert-danger
strong Warning! Deleting a user cannot be undone
form(method='POST' action='')
button.btn.btn-danger(type='submit', name='delete' value='delete') Delete #{user.name}
= ' '
a.btn.btn-default(href='/users', name='cancel', role='button') Cancel
if errors
ul
for err in errors
li!= err.msg

22
views/users.pug Normal file
View File

@ -0,0 +1,22 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends users_layout
block users_content
table.table.table-responsive.table-striped.table-hover
each user in users
tr
td(width='3%')
a(href='/users/' + user.name + '/delete')
i.glyphicon.glyphicon-trash
td(width='15%')
a(href='/users/' + user.name + '/password') #{user.name}
td(width='82%')
a(href='/users/' + user.name + '/password') set password
else
tr
td There are no users on this system

38
views/users_layout.pug Normal file
View File

@ -0,0 +1,38 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends head_layout
block body_content
nav.navbar.navbar-inverse.navbar-fixed-top
.container-fluid
.navbar-header
button.navbar-toggle(type='button' data-toggle='collapse' data-target='#BarNav')
span.icon-bar
span.icon-bar
span.icon-bar
a.navbar-brand(href='https://key-networks.com' target='_blank') Key Networks
.collapse.navbar-collapse(id='BarNav')
ul.nav.navbar-nav
li(class=(page === 'home'? 'active' : ''))
a(href='/controller') Home
li(class=(page === 'users'? 'active' : ''))
a(href='/users') Users
li(class=(page === 'create_user'? 'active' : ''))
a(href='/users/create') Create user
ul.nav.navbar-nav.navbar-right
li
a(href='/logout')
span.glyphicon.glyphicon-log-out
| Logout
.container(style='margin-top:50px')
.row
.col-sm-12
if error
b #{error}
else
h1= title
block users_content

29
views/v4AssignMode.pug Normal file
View File

@ -0,0 +1,29 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
block net_content
p Let ZT assign IPv4 addresses?
form(method='POST' action='')
.radio
label
input(type='radio' name='zt' value='true' checked=network.v4AssignMode.zt)
| Yes
.radio
label
input(type='radio' name='zt' value='false' checked=!network.v4AssignMode.zt)
| No
.form-group(style='padding-top: 10px')
button.btn.btn-primary(type='submit') Submit
= ' '
a.btn.btn-default(href='/controller/network/' + network.nwid name='cancel' role='button') Cancel
if errors
ul
for err in errors
li!= err.msg

54
views/v6AssignMode.pug Normal file
View File

@ -0,0 +1,54 @@
//-
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
extends network_layout
block net_content
form(method='POST' action='')
table.table.table-responsive.table-striped.table-hover
tr
th(width='25%')
th(width='2%') Yes
th(width='73%') No
tr
td ZT 6plane (/80 routable for each device)
td
.radio
label
input(type='radio' name='6plane' value='true' checked=network.v6AssignMode['6plane'])
td
.radio
label
input(type='radio' name='6plane' value='false' checked=!network.v6AssignMode['6plane'])
tr
td ZT rfc4193 (/128 for each device)
td
.radio
label
input(type='radio' name='rfc4193' value='true' checked=network.v6AssignMode.rfc4193)
td
.radio
label
input(type='radio' name='rfc4193' value='false' checked=!network.v6AssignMode.rfc4193)
tr
td Auto-assign from IP Assignment Pool
td
.radio
label
input(type='radio' name='zt' value='true' checked=network.v6AssignMode.zt)
td
.radio
label
input(type='radio' name='zt' value='false' checked=!network.v6AssignMode.zt)
.form-group(style='padding-top: 10px')
button.btn.btn-primary(type='submit') Submit
= ' '
a.btn.btn-default(href='/controller/network/' + network.nwid name='cancel' role='button') Cancel
if errors
ul
for err in errors
li!= err.msg