1.2.0 release notes and a few final tweaks and cleanup.
This commit is contained in:
parent
f99b62c48d
commit
1ef3069a7e
6 changed files with 90 additions and 46 deletions
|
@ -3,3 +3,6 @@ ZeroTier Rules Compiler
|
|||
|
||||
This script converts ZeroTier rules in human-readable format into rules suitable for import into a ZeroTier network controller. It's the script that is used in the rules editor on [ZeroTier Central](https://my.zerotier.com/).
|
||||
|
||||
A command line interface is included that may be invoked as: `node cli.js <rules script>`.
|
||||
|
||||
See the [manual](https://www.zerotier.com/manual.shtml) for information about the rules engine and rules script syntax.
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
var RuleCompiler = require('./rule-compiler.js');
|
||||
|
||||
if (process.argv.length < 3) {
|
||||
|
@ -9,21 +8,39 @@ if (process.argv.length < 3) {
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
var src = fs.readFileSync(process.argv[2]).toString();
|
||||
|
||||
var rules = [];
|
||||
var caps = {};
|
||||
var tags = {};
|
||||
var err = RuleCompiler.compile(src,rules,caps,tags);
|
||||
var err = RuleCompiler.compile(fs.readFileSync(process.argv[2]).toString(),rules,caps,tags);
|
||||
|
||||
if (err) {
|
||||
console.log('ERROR parsing '+process.argv[2]+' line '+err[0]+' column '+err[1]+': '+err[2]);
|
||||
console.error('ERROR parsing '+process.argv[2]+' line '+err[0]+' column '+err[1]+': '+err[2]);
|
||||
process.exit(1);
|
||||
} else {
|
||||
let capsArray = [];
|
||||
let capabilitiesByName = {};
|
||||
for(let n in caps) {
|
||||
capsArray.push(caps[n]);
|
||||
capabilitiesByName[n] = caps[n].id;
|
||||
}
|
||||
let tagsArray = [];
|
||||
for(let n in tags) {
|
||||
let t = tags[n];
|
||||
tagsArray.push({
|
||||
'id': t.id,
|
||||
'default': t['default']||null
|
||||
});
|
||||
}
|
||||
|
||||
console.log(JSON.stringify({
|
||||
rules: rules,
|
||||
caps: caps,
|
||||
tags: tags
|
||||
},null,2));
|
||||
config: {
|
||||
rules: rules,
|
||||
capabilities: capsArray,
|
||||
tags: tagsArray
|
||||
},
|
||||
capabilitiesByName: capabilitiesByName,
|
||||
tagsByName: tags
|
||||
},null,1));
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "zerotier-rule-compiler",
|
||||
"version": "1.1.17-3",
|
||||
"version": "1.2.0-1",
|
||||
"description": "ZeroTier Rule Script Compiler",
|
||||
"main": "cli.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue