mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2025-07-30 19:40:45 -07:00
feat: es6+mods
This commit is contained in:
parent
773b64ea30
commit
19c92ed244
19 changed files with 179 additions and 245 deletions
|
@ -1,4 +1,4 @@
|
|||
exports.defaultRulesSource = `
|
||||
export const defaultRulesSource = `
|
||||
# This is a default rule set that allows IPv4 and IPv6 traffic but otherwise
|
||||
# behaves like a standard Ethernet switch.
|
||||
|
||||
|
@ -26,7 +26,7 @@ drop
|
|||
accept;
|
||||
`;
|
||||
|
||||
exports.defaultRules = `
|
||||
export const defaultRules = `
|
||||
[
|
||||
{
|
||||
"type": "MATCH_ETHERTYPE",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const axios = require("axios");
|
||||
const fs = require("fs");
|
||||
import axios from "axios";
|
||||
import fs from "node:fs";
|
||||
|
||||
const baseURL = process.env.ZU_CONTROLLER_ENDPOINT || "http://localhost:9993/";
|
||||
|
||||
|
@ -10,7 +10,7 @@ if (process.env.ZU_CONTROLLER_TOKEN) {
|
|||
token = fs.readFileSync("/var/lib/zerotier-one/authtoken.secret", "utf8");
|
||||
}
|
||||
|
||||
module.exports = axios.create({
|
||||
export const api = axios.create({
|
||||
baseURL: baseURL,
|
||||
responseType: "json",
|
||||
headers: {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
const low = require("lowdb");
|
||||
const FileSync = require("lowdb/adapters/FileSync");
|
||||
import low from "lowdb";
|
||||
import FileSync from "lowdb/adapters/FileSync.js";
|
||||
|
||||
const adapter = new FileSync(process.env.ZU_DATAPATH || "data/db.json");
|
||||
|
||||
const db = low(adapter);
|
||||
|
||||
module.exports = db;
|
||||
export const db = low(adapter);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const crypto = require("crypto");
|
||||
const hashPassword = require("pbkdf2-wrapper/hashText");
|
||||
import crypto from "crypto";
|
||||
import hashPassword from "pbkdf2-wrapper/hashText.js";
|
||||
|
||||
module.exports = async function () {
|
||||
export async function initAdmin() {
|
||||
if (!process.env.ZU_DEFAULT_PASSWORD || !process.env.ZU_DEFAULT_USERNAME) {
|
||||
console.error("ZU_DEFAULT_PASSWORD or ZU_DEFAULT_USERNAME not found!");
|
||||
process.exit(1);
|
||||
|
@ -13,4 +13,4 @@ module.exports = async function () {
|
|||
password_hash: hash,
|
||||
token: crypto.randomBytes(16).toString("hex"),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
const _ = require("lodash");
|
||||
import _ from "lodash";
|
||||
|
||||
const api = require("./controller-api");
|
||||
const db = require("./db");
|
||||
import { api } from "./controller-api.js";
|
||||
import { db } from "./db.js";
|
||||
|
||||
async function pingAll(network) {
|
||||
export async function pingAll(network) {
|
||||
await Promise.all(
|
||||
network.members.map(async (member) => {
|
||||
console.debug("Processing member " + member.id);
|
||||
|
@ -29,5 +29,3 @@ async function pingAll(network) {
|
|||
})
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = pingAll;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const api = require("../utils/controller-api");
|
||||
import { api } from "../utils/controller-api.js";
|
||||
|
||||
module.exports = async function () {
|
||||
export async function getZTAddress() {
|
||||
try {
|
||||
const res = await api.get("status");
|
||||
return res.data.address;
|
||||
|
@ -10,4 +10,4 @@ module.exports = async function () {
|
|||
"Couldn't connect to the controller on " + err.config.baseURL
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue