update So 7. Jun 19:01:01 CEST 2020
This commit is contained in:
parent
98c68cb660
commit
1bd357bcd6
@ -38,13 +38,14 @@ app.use(bodyParser.urlencoded({
|
||||
// Scripte einbinden
|
||||
var sql_cfg = require('./server/sql_cfg')(fs, bcrypt, app_cfg);
|
||||
var sql = require('./server/sql_qry')(sql_cfg, uuidv4, app_cfg);
|
||||
var api = require('./server/sql_qry')(sql_cfg, uuidv4, app_cfg);
|
||||
var api = require('./server/api')(sql_cfg, uuidv4, app_cfg);
|
||||
var brk = require('./server/broker')(app_cfg, sql, uuidv4);
|
||||
var waip = require('./server/waip')(io, sql, brk, async, app_cfg, api);
|
||||
var proof = require('./server/proof')(app_cfg, sql);
|
||||
var waip = require('./server/waip')(io, sql, brk, async, app_cfg, api, proof);
|
||||
var socket = require('./server/socket')(io, sql, app_cfg, waip);
|
||||
var udp = require('./server/udp')(app_cfg, waip, sql);
|
||||
var auth = require('./server/auth')(app, app_cfg, sql_cfg, async, bcrypt, passport, io);
|
||||
var routes = require('./server/routing')(app, sql, uuidv4, app_cfg, passport, auth, waip, udp);
|
||||
var routes = require('./server/routing')(app, sql, uuidv4, app_cfg, passport, auth, waip, udp, proof);
|
||||
|
||||
// Server starten
|
||||
webserver.listen(app_cfg.global.https_port, function() {
|
||||
|
||||
@ -19,7 +19,7 @@ module.exports = function (io, sql, app_cfg, waip) {
|
||||
// versuche Remote-IP zu ermitteln
|
||||
var remote_ip = socket.handshake.headers["x-real-ip"] || socket.handshake.headers['x-forwarded-for'] || socket.request.connection.remoteAddress;
|
||||
|
||||
//TODO Verschlüsselung: pruefen ob Verbindung mit passendem Geheimnis und aus IP-Bereich, das Ergebnis loggen
|
||||
//TODO API: Eingehende Verbindung nur mit passendem Geheimnis und aus passendem IP-Bereich zulassen, das Ergebnis loggen
|
||||
|
||||
// in Liste der Clients mit aufnehmen
|
||||
sql.db_client_update_status(socket, 'api');
|
||||
@ -93,7 +93,7 @@ module.exports = function (io, sql, app_cfg, waip) {
|
||||
|
||||
if (app_cfg.endpoint.enabled) {
|
||||
// Verbindung zu anderem Server aufbauen
|
||||
// TODO Verschlüsselung: Verbindungsaufbau mit passendem Geheimnis absichern
|
||||
// TODO API: Verbindungsaufbau mit passendem Geheimnis absichern, IP-Adresse senden
|
||||
var remote_api = io_api.connect(app_cfg.endpoint.host, {
|
||||
reconnect: true
|
||||
});
|
||||
|
||||
22
server/proof.js
Executable file
22
server/proof.js
Executable file
@ -0,0 +1,22 @@
|
||||
module.exports = function (app_cfg, sql) {
|
||||
|
||||
// Module laden
|
||||
const test = 'test';
|
||||
|
||||
function validate_waip(data, callback) {
|
||||
// TODO Validierung: Einsatzdaten auf Validität prüfen
|
||||
callback && callback(true);
|
||||
// SQL-Log
|
||||
};
|
||||
|
||||
function validate_rmld(data, callback) {
|
||||
// TODO Validierung: Rueckmeldung auf plausibilität
|
||||
callback && callback(true);
|
||||
// SQL-Log
|
||||
};
|
||||
|
||||
return {
|
||||
validate_waip: validate_waip,
|
||||
validate_rmld: validate_rmld
|
||||
};
|
||||
};
|
||||
@ -1,4 +1,4 @@
|
||||
module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp) {
|
||||
module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp, proof) {
|
||||
|
||||
/* ########################### */
|
||||
/* ##### Statische Seiten #### */
|
||||
@ -247,7 +247,8 @@ module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp)
|
||||
|
||||
// Rueckmeldung entgegennehmen
|
||||
app.post('/rmld/:waip_uuid/:rmld_uuid', function (req, res) {
|
||||
// TODO Validierung: Rueckmeldung auf Validiteat pruefen
|
||||
proof.validate_rmld(req.body, function (valid) {
|
||||
if (valid) {
|
||||
var waip_uuid = req.body.waip_uuid;
|
||||
var rmld_uuid = req.body.rmld_uuid;
|
||||
waip.rmld_speichern(req.body, null, function (result) {
|
||||
@ -259,6 +260,8 @@ module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp)
|
||||
res.redirect('/rmld/' + waip_uuid + '/' + rmld_uuid);
|
||||
};
|
||||
});
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/* ########################## */
|
||||
|
||||
@ -83,11 +83,11 @@ module.exports = function (fs, bcrypt, app_cfg) {
|
||||
user_agent TEXT,
|
||||
reset_timestamp DATETIME)`);
|
||||
// Rueckmelde-Tabelle erstellen
|
||||
// TODO: ALIAS-Spalte hinterlegen, abfragen nochmals prüfen ob mit übermittelt, ggf. mit Konfig
|
||||
db.run(`CREATE TABLE waip_response (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
waip_uuid TEXT,
|
||||
rmld_uuid TEXT,
|
||||
alias TEXT,
|
||||
einsatzkraft INTEGER,
|
||||
maschinist INTEGER,
|
||||
fuehrungskraft INTEGER,
|
||||
@ -129,6 +129,7 @@ module.exports = function (fs, bcrypt, app_cfg) {
|
||||
waip_wachen_id INTEGER,
|
||||
tw_account_id INTEGER,
|
||||
tw_account_list TEXT,
|
||||
bkp_recipient TEXT,
|
||||
FOREIGN KEY(waip_wachen_id) REFERENCES waip_wachen(id),
|
||||
FOREIGN KEY(tw_account_id) REFERENCES waip_twitter_accounts(id))`);
|
||||
// Log erstellen
|
||||
|
||||
@ -751,7 +751,7 @@ module.exports = function (db, uuidv4, app_cfg) {
|
||||
|
||||
function db_vmtl_get_list(waip_id, callback) {
|
||||
// Pruefen ob fuer eine Wache im Einsatz ein Verteilerliste hinterlegt ist
|
||||
db.get(`select t.waip_wachen_id, t.tw_account_id, t.tw_account_list from waip_vmlt_tw_wachen t
|
||||
db.get(`select t.waip_wachen_id, t.tw_account_id, t.tw_account_list from waip_vmtl_tw_wachen t
|
||||
where waip_wachen_id = (select distinct w.id wachen_id from waip_wachen w left join waip_einsatzmittel em on em.wachenname = w.name_wache
|
||||
where em.waip_einsaetze_ID = ?)`, [waip_id], function (err, twitter_liste) {
|
||||
if (err == null && twitter_liste) {
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
module.exports = function (io, sql, brk, async, app_cfg, api) {
|
||||
module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
||||
|
||||
// Einsatzmeldung in Datenbank speichern
|
||||
function einsatz_speichern(einsatz_rohdaten, app_id) {
|
||||
// TODO Validierung: Einsatzdaten auf Validität prüfen
|
||||
proof.validate_waip(einsatz_rohdaten, function (valid) {
|
||||
if (valid) {
|
||||
|
||||
// Einsatzmeldung (JSON) speichern
|
||||
sql.db_einsatz_speichern(einsatz_rohdaten, function (waip_id) {
|
||||
sql.db_log('WAIP', 'DEBUG: Neuer Einsatz mit der ID ' + waip_id);
|
||||
@ -44,6 +46,8 @@ module.exports = function (io, sql, brk, async, app_cfg, api) {
|
||||
api.server_to_client_new_waip(einsatz_rohdaten, app_id);
|
||||
api.client_to_server_new_waip(einsatz_rohdaten, app_id);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
// Einsatz an Client verteilen
|
||||
function waip_verteilen(waip_id, socket, wachen_nr) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user