update Di 26. Mai 16:01:01 CEST 2020
This commit is contained in:
parent
0a47010425
commit
85834350fb
@ -3,26 +3,25 @@ module.exports = function (io, io_api, sql, app_cfg, waip) {
|
|||||||
// Module laden
|
// Module laden
|
||||||
const io_api = require('socket.io-client');
|
const io_api = require('socket.io-client');
|
||||||
|
|
||||||
|
// Socket.IO API (anderer Server stellt Verbindung her und sendet Daten)
|
||||||
// Socket.IO API
|
|
||||||
|
|
||||||
if (app_cfg.api.enabled) {
|
if (app_cfg.api.enabled) {
|
||||||
|
// Namespace API
|
||||||
var nsp_api = io.of('/api');
|
var nsp_api = io.of('/api');
|
||||||
|
|
||||||
nsp_api.on('connection', function (socket) {
|
nsp_api.on('connection', function (socket) {
|
||||||
// versuche Remote-IP zu ermitteln
|
// versuche Remote-IP zu ermitteln
|
||||||
var remote_ip = socket.handshake.headers["x-real-ip"] || socket.handshake.headers['x-forwarded-for'] || socket.request.connection.remoteAddress;
|
var remote_ip = socket.handshake.headers["x-real-ip"] || socket.handshake.headers['x-forwarded-for'] || socket.request.connection.remoteAddress;
|
||||||
|
|
||||||
//TODO pruefen ob Verbindung mit passendem Geheimnis und aus IP-Bereich
|
//TODO pruefen ob Verbindung mit passendem Geheimnis und aus IP-Bereich
|
||||||
//secret: 'asdfwert1234567890#',
|
|
||||||
//access_list: ['192.168.2.20', '192.168.2.30']
|
|
||||||
|
|
||||||
// in Liste der Clients mit aufnehmen
|
// in Liste der Clients mit aufnehmen
|
||||||
sql.db_update_client_status(socket, 'api');
|
sql.db_update_client_status(socket, 'api');
|
||||||
// Neuen Einsatz speichern
|
// Neuen Einsatz speichern
|
||||||
socket.on('new_waip', function (data) {
|
socket.on('new_waip', function (data) {
|
||||||
sql.db_log('API', 'Neuer Einsatz von ' + remote_ip + ': ' + data);
|
|
||||||
waip.einsatz_speichern(data);
|
waip.einsatz_speichern(data);
|
||||||
|
sql.db_log('API', 'Neuer Einsatz von ' + remote_ip + ': ' + data);
|
||||||
});
|
});
|
||||||
|
// neue externe Rueckmeldung speichern
|
||||||
socket.on('new_rmld', function (data) {
|
socket.on('new_rmld', function (data) {
|
||||||
sql.db_save_rmld(data, function (result) {
|
sql.db_save_rmld(data, function (result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user