forked from apxtri/apxtri
change conf.json to adminapi/objects/tribes/itm/adminapi.conf to harmonize all tribes management
This commit is contained in:
parent
053b45c81c
commit
92132e4ae7
BIN
.package.json.swp
Normal file
BIN
.package.json.swp
Normal file
Binary file not shown.
46
apxchat.js
Normal file
46
apxchat.js
Normal file
@ -0,0 +1,46 @@
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const http = require('http');
|
||||
const server = http.createServer(app);
|
||||
const { Server } = require("socket.io");
|
||||
const io = new Server(server);
|
||||
const nodepgp = require('node-pgp'); // ou une autre bibliothèque PGP
|
||||
const openpgp = require("openpgp");
|
||||
// ... (initialisation de nodepgp)
|
||||
|
||||
io.on('connection', (socket) => {
|
||||
// Gestion de la connexion d'un utilisateur
|
||||
// ...
|
||||
|
||||
socket.on('message', async (data) => {
|
||||
// Vérifier si le destinataire est connecté
|
||||
// ...
|
||||
|
||||
// Générer une nouvelle clé de session
|
||||
const sessionKey = await nodepgp.generateKey({
|
||||
bits: 2048,
|
||||
type: 'rsa'
|
||||
});
|
||||
|
||||
// Chiffrer le message avec la clé publique du destinataire et la clé de session
|
||||
const encryptedMessage = await nodepgp.encrypt({
|
||||
message: data.message,
|
||||
publicKeys: [destinataire.publicKey],
|
||||
signingKeys: [sessionKey.privateKey]
|
||||
});
|
||||
|
||||
// Envoyer la clé de session chiffrée avec la clé publique du destinataire
|
||||
// et le message chiffré au destinataire
|
||||
socket.to(destinataire.id).emit('message', {
|
||||
message: encryptedMessage,
|
||||
sessionKey: await nodepgp.encrypt({
|
||||
message: sessionKey.publicKey,
|
||||
publicKeys: [destinataire.publicKey]
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(3030, () => {
|
||||
console.log('apxchat listening on *:3030');
|
||||
});
|
24
apxtri.js
24
apxtri.js
@ -18,37 +18,38 @@ if (!fs.existsSync("/etc/nginx/nginx.conf")) {
|
||||
console.log(
|
||||
"\x1b[31m Check documentation, nginx have to be installed on this server first, no /etc/nginx/nginx.conf available, install then rerun yarn command.");
|
||||
}
|
||||
if (!fs.existsSync("../../conf.json")) {
|
||||
if (!fs.existsSync("../objects/tribes/itm/adminapi.json")) {
|
||||
console.log("Warning, this is a first install you must run 'node setup.js dns=domainename user=sudoerlinux'")
|
||||
process.exit();
|
||||
}
|
||||
|
||||
const conf = require(path.resolve(`../../conf.json`));
|
||||
const conf = require(path.resolve("../objects/tribes/itm/adminapi.json"));
|
||||
let doms = conf.dns; // only dns of town during the init process
|
||||
const currentmod = "apxtri";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
|
||||
let tribelist = {};
|
||||
if (fs.existsSync(`../../idx/tribeId_all.json`)) {
|
||||
tribelist = fs.readJsonSync(`../../idx/tribeId_all.json`);
|
||||
if (fs.existsSync(`../../adminapi/objects/tribes/idx/tribes_dns.json`)) {
|
||||
tribelist = fs.readJsonSync(`../../adminapi/objects/tribes/idx/tribes_dns.json`);
|
||||
}
|
||||
console.log(tribelist)
|
||||
let tribeIds = Object.keys(tribelist);
|
||||
// context is store in /itm/tribename.json ={contexte:{routes:[],models:[{model:,tplstringslg:[]}]}
|
||||
// routes={url,route} check how to add plugin tribe route later
|
||||
// keep only the 2 last part (.) of domain name to validate cors with it (generic domain)
|
||||
let routes = []
|
||||
tribeIds.forEach((t) => {
|
||||
tribelist[t].dns.forEach((d) => {
|
||||
tribelist[t].forEach((d) => {
|
||||
const dm = d.split(".").slice(-2).join(".");
|
||||
if (!doms.includes(dm)) doms.push(dm);
|
||||
console.log("dns", t)
|
||||
})
|
||||
//reindex database
|
||||
if (t == "smatchit" || true) {
|
||||
glob.sync(`../../${t}/objects/*`).forEach(o => {
|
||||
console.log('objetc:', o)
|
||||
console.log(t, o)
|
||||
Odmdb.runidx(o)
|
||||
})
|
||||
}
|
||||
});
|
||||
const context = {};
|
||||
const pathtr = path.resolve(`../../${t}`);
|
||||
context.routes = []
|
||||
@ -64,7 +65,7 @@ tribeIds.forEach((t) => {
|
||||
tplstrings: glob.sync(`${pathtr}/objects/tplstrings/${modname}_*.json`).map(l => path.basename(l, '.json').split("_")[1])
|
||||
}
|
||||
})
|
||||
const conft = `../../itm/${t}.json`
|
||||
const conft = `../../adminapi/objects/tribes/itm/${t}.json`
|
||||
const ctx = fs.readJsonSync(conft)
|
||||
ctx.context = context
|
||||
fs.outputJSONSync(conft, ctx, { spaces: 2 });
|
||||
@ -77,9 +78,9 @@ Object.keys(conf.api.appset).forEach((p) => {
|
||||
});
|
||||
// To set depending of data form or get size to send
|
||||
app.use(bodyParser.urlencoded(conf.api.bodyparse.urlencoded));
|
||||
// To set depending of post put json data size to send
|
||||
app.use(express.json({ limit: '10mb', type: 'application/json', rawBody: true }));
|
||||
app.use(bodyParser.json(conf.api.bodyparse.json));
|
||||
// To set depending of post put json data size to send
|
||||
app.use(express.json(conf.api.json));
|
||||
app.disable("x-powered-by"); // for security
|
||||
app.locals.tribeids = tribeIds;
|
||||
if (log) {
|
||||
@ -112,6 +113,7 @@ app.use((req, res, next) => {
|
||||
"testcors:",
|
||||
cor, "headers allowed: [", conf.api.exposedHeaders.join(','), "] match with reg:", regtxt
|
||||
);
|
||||
if (!cor) console.log(`The domain name ${req.headers.origin} is not allow to access for CORS settings, add it in itm/tribename.json in dns`)
|
||||
cors({
|
||||
origin: cor,
|
||||
allowedHeaders: conf.api.exposedHeaders,
|
||||
|
@ -1,4 +1,4 @@
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod='checkHeaders';
|
||||
const log = conf.api.activelog.includes(currentmod)
|
||||
/**
|
||||
|
@ -112,8 +112,8 @@ Accessible with https://dns/api/tribename/routename/
|
||||
```plaintext
|
||||
// Example of a route
|
||||
const tribe="smatchit";
|
||||
const conftrib = require(`../../../itm/${tribe}.json`);
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conftrib = require(`../../../adminapi/objects/tribes/itm/${tribe}.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const express = require(`../../../adminapi/apxtri/node_modules/express`);
|
||||
const fs = require(`../../../adminapi/apxtri/node_modules/fs-extra`);
|
||||
const Nofications = require(`../../../adminapi/apxtri/models/Notifications.js`);
|
||||
|
@ -6,7 +6,7 @@ const glob = require("glob");
|
||||
// const openpgp = require("/media/phil/usbfarm/apxtri/node_modules/openpgp/dist/node/openpgp.js");
|
||||
const openpgp = require("openpgp");
|
||||
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod='isAuthenticated';
|
||||
const log = conf.api.activelog.includes(currentmod)
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@ const glob = require("glob");
|
||||
const jwt = require("jwt-simple");
|
||||
const axios = require("axios");
|
||||
const path = require("path");
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const Odmdb = require("./Odmdb.js");
|
||||
// lowercase 1st letter is normal
|
||||
const towns = require("./Towns.js");
|
||||
|
@ -7,7 +7,7 @@ const Mustache = require('mustache');
|
||||
const Checkjson = require(`./Checkjson.js`);
|
||||
//const smtp = require("smtp-client");
|
||||
const nodemailer = require("nodemailer");
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod = "Notifications";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
/**
|
||||
@ -153,9 +153,9 @@ Notifications.sendsms = async (data, tribeId) => {
|
||||
};
|
||||
}
|
||||
let confsms = conf.sms;
|
||||
if (fs.existsSync(`../../itm/${req.session.header.xtribe}.json`)) {
|
||||
if (fs.existsSync(`../../adminapi/objects/tribes/itm/${req.session.header.xtribe}.json`)) {
|
||||
const conftrib = fs.readJSONSync(
|
||||
`../../itm/${req.session.header.xtribe}.json`
|
||||
`../../adminapi/objects/tribes/itm/${req.session.header.xtribe}.json`
|
||||
);
|
||||
if (conftrib.sms) confsms = conftrib.sms;
|
||||
}
|
||||
@ -332,7 +332,7 @@ Notifications.sendmail = async (data, tribe) => {
|
||||
};
|
||||
}
|
||||
let confsmtp = conf.smtp;
|
||||
const conftribfile = `../../itm/${tribe}.json`;
|
||||
const conftribfile = `../../adminapi/objects/tribes/itm/${tribe}.json`;
|
||||
if (fs.existsSync(conftribfile)) {
|
||||
const conftrib = fs.readJSONSync(conftribfile);
|
||||
if (!conftrib.emailcontact){
|
||||
|
@ -3,7 +3,7 @@ const path = require("path");
|
||||
const fs = require("fs-extra");
|
||||
const dayjs = require("dayjs");
|
||||
const axios = require("axios");
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const Checkjson = require(`./Checkjson.js`);
|
||||
const { promiseHooks } = require("v8");
|
||||
const currentmod = "Odmdb";
|
||||
|
@ -8,7 +8,7 @@ const openpgp = require("openpgp");
|
||||
const Notifications = require("./Notifications.js");
|
||||
const Odmdb = require("./Odmdb.js");
|
||||
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod = "Pagans";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
/**
|
||||
|
@ -8,7 +8,7 @@ const openpgp = require("openpgp");
|
||||
const Notifications = require("./Notifications.js");
|
||||
const Odmdb = require("./Odmdb.js");
|
||||
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod = "Pagans";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@ const glob = require("glob");
|
||||
const moment = require("moment");
|
||||
const jwt = require("jwt-simple");
|
||||
const UUID = require("uuid");
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const Checkjson = require(`./Checkjson.js`);
|
||||
const Odmdb = require("./Odmdb.js");
|
||||
|
||||
|
@ -3,7 +3,7 @@ const path = require("path");
|
||||
const fs = require("fs-extra");
|
||||
const dayjs = require("dayjs");
|
||||
const axios = require("axios");
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const Checkjson = require(`./Checkjson.js`);
|
||||
|
||||
const Trackings = {}
|
||||
|
@ -10,7 +10,7 @@ const jwt = require( 'jwt-simple' );
|
||||
const moment = require( 'moment' );
|
||||
const UUID = require( 'uuid' );
|
||||
const Pagans = require( './Pagans.js' );
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const Checkjson = require( `./Checkjson.js`);
|
||||
/*
|
||||
tribeid manager
|
||||
|
@ -4,7 +4,7 @@ const dnsSync = require("dns-sync");
|
||||
const mustache = require("mustache");
|
||||
const readlineSync = require("readline-sync");
|
||||
const Odmdb = require("./Odmdb.js");
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const Wwws = {};
|
||||
|
||||
Wwws.initlocalwco=(tribwco,profils,lg)=>{
|
||||
@ -83,10 +83,11 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
||||
if (loc.itms){
|
||||
Object.keys(loc.itms).forEach((r) => {
|
||||
const src = `../../${loc.itms[r]}.json`;
|
||||
console.log("hhhhhhhhhhhhhh",path.resolve(src))
|
||||
if (fs.existsSync(src)) {
|
||||
localstorage.itms[r] = fs.readJSONSync(src);
|
||||
} else {
|
||||
localstorage.itms[r] = `Check your ${fileparam} for itms in ${pagename} and ${r}`;
|
||||
localstorage.itms[r] = `Check your ${fileparam}.json for itms in ${pagename} and ${r}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -98,7 +99,7 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
||||
} else {
|
||||
localstorage.ref[
|
||||
r
|
||||
] = `Check your ${fileparam} for ref in ${pagename} and ${r}`;
|
||||
] = `Check your ${fileparam}.json for ref in ${pagename} and ${r}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
"restartapx": "pm2 restart apxtri.js --log-date-format 'DD-MM HH:mm:ss.SSS'",
|
||||
"dev": "NODE_MODE=dev node apxtri.js",
|
||||
"unittest": "node unittest.js",
|
||||
"tar2prod": "rm ../objects/wwws/cdn/share/apxtriV* && tar -czf ../objects/wwws/cdn/share/apxtriV$version.tar --exclude='node_modules' --exclude='.git' ../../adminapi/apxtri ../../adminapi/schema ../../adminapi/objects ../../adminapi/template ../../itm/adminapi.json",
|
||||
"tar2prod": "rm ../objects/wwws/cdn/share/apxtriV* && tar -czf ../objects/wwws/cdn/share/apxtriV$version.tar --exclude='node_modules' --exclude='.git' ../../adminapi/apxtri ../../adminapi/schema ../../adminapi/objects ../../adminapi/template ../../adminapi/objects/tribes/itm/adminapi.json",
|
||||
"apidoc": "apidoc -c ../../$tribe/apxtri/apidoc_$tribe.json -o ../../$tribe/objects/wwws/apidoc/",
|
||||
"publishtestwall": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@wall-ants://home/phil/apxtowns/testwall-ants/tribes/$space/..",
|
||||
"publishwall": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@wall-ants://home/phil/apxtowns/wall-ants/tribes/$space/..",
|
||||
|
@ -1,6 +1,6 @@
|
||||
const express = require( 'express' );
|
||||
const fs=require('fs-extra');
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
|
||||
// Classes
|
||||
const Nations = require( '../models/Nations.js' );
|
||||
|
@ -2,7 +2,7 @@ const express = require("express");
|
||||
const glob = require("glob");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const Odmdb = require("../models/Odmdb.js");
|
||||
// Middlewares
|
||||
const checkHeaders = require("../middlewares/checkHeaders.js");
|
||||
|
@ -9,7 +9,7 @@ const Odmdb = require("../models/Odmdb.js");
|
||||
const checkHeaders = require("../middlewares/checkHeaders.js");
|
||||
const isAuthenticated = require("../middlewares/isAuthenticated.js");
|
||||
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod = "pagans";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
|
||||
|
@ -2,7 +2,7 @@ const express = require("express");
|
||||
const glob = require("glob");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const Odmdb = require("../models/Odmdb.js");
|
||||
// Middlewares
|
||||
const checkHeaders = require("../middlewares/checkHeaders");
|
||||
|
@ -2,7 +2,7 @@ const express = require( 'express' );
|
||||
const fs = require( 'fs-extra' );
|
||||
const path = require( 'path' );
|
||||
const glob = require('glob');
|
||||
const conf = require(`../../../conf.json`);
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
|
||||
// Classes
|
||||
const Tribes = require( '../models/Tribes.js' );
|
||||
@ -31,7 +31,7 @@ router.get('/config/:tribe', checkHeaders,isAuthenticated,(req,res)=>{
|
||||
req.session.header.accessrights.data[ req.params.tribe ].tribeid.includes( 'R' )
|
||||
*/
|
||||
if("authorize"=="authorize"){
|
||||
const tribconf=`../../itm/${req.params.tribe}.json`
|
||||
const tribconf=`../../adminapi/objects/tribes/itm/${req.params.tribe}.json`
|
||||
if (!fs.existsSync(tribconf)){
|
||||
res.status(404).json({status:404,ref:"Tribes",msg:"tribedoesnotexist", data:{tribe:req.params.tribe}})
|
||||
}else{
|
||||
|
2
setup.js
2
setup.js
@ -141,7 +141,7 @@ Setup.addtribe = (tribeId, town, nation) => {
|
||||
};
|
||||
idxtrib[tribeId] = tribdata;
|
||||
fs.outputJSON(idxtribf, idxtrib, { spaces: 2 });
|
||||
fs.outputJSON("../../itm/${tribeId}.json", tribdata, { space: 2 });
|
||||
fs.outputJSON("../../adminapi/objects/tribes/itm/${tribeId}.json", tribdata, { space: 2 });
|
||||
[
|
||||
`../../${tribeId}/nginx`,
|
||||
`../../${tribeId}/logs/nginx`,
|
||||
|
Loading…
x
Reference in New Issue
Block a user