new config interface + presets/profiles

master
cheetah 2 years ago
parent 0159915b4f
commit 26becf3407

@ -1,74 +1,74 @@
{ {
"general": { "general": {
"amqp": [ "amqp": [
"amqp://daemon:daemon@10.13.37.37:5672/" "amqp://daemon:daemon@127.0.0.1:5672/"
], ],
"port": 3000, "port": 3000,
"configPort": 3001, "configPort": 3001,
"configWebInterfaceEnabled": true "configWebInterfaceEnabled": true
}, },
"connectors": { "connectors": {
"dummy": { "dummy": {
"enabled": true, "enabled": true,
"duplexTimeout": 300 "duplexTimeout": 300
}, },
"pagernetzAT": { "pocsag": {
"enabled": true, "enabled": true,
"duplexTimeout": 300 "duplexTimeout": 300
}, },
"pocsag": { "pagernetzAT": {
"enabled": true, "enabled": true,
"duplexTimeout": 300 "duplexTimeout": 300
}, },
"ecityruf": { "ecityruf": {
"enabled": false, "enabled": true,
"duplexTimeout": 180 "duplexTimeout": 180
}, },
"emPuppettering": { "emPuppettering": {
"enabled": true, "enabled": true,
"duplexTimeout": 180 "duplexTimeout": 360
}, },
"emessage": { "emessage": {
"enabled": false, "enabled": true,
"username": "", "username": "",
"password": "", "password": "",
"duplexTimeout": 60, "duplexTimeout": 180,
"responseTimeout": 320, "responseTimeout": 320,
"startInterval": 5, "startInterval": 5,
"2wayS_BackChannel": true "2wayS_BackChannel": true
}, },
"lorawan": { "lorawan": {
"enabled": true, "enabled": false,
"duplexTimeout": 1800, "duplexTimeout": 1800,
"mqttserver": "mqtt://eu.thethings.network:1883", "mqttserver": "mqtt://eu1.cloud.thethings.network:1883",
"username": "TTN_v2_APP_ID___OR___v3_MQTT_Username", "username": "",
"password": "TTN_v2_APP_APIKEY__OR__TTN_v3_MQTT_Password" "password": ""
}, },
"dapnet": { "dapnet": {
"enabled": true, "enabled": true,
"endpoint": "http://hampager.de:8080/calls", "endpoint": "http://10.13.0.180:8080/calls",
"username": "DAPNET_Username", "username": "test",
"password": "DAPNET_Passwort", "password": "testsucks",
"duplexTimeout": 300 "duplexTimeout": 300
} }
}, },
"pagers": { "pagers": {
"birdyslim": { "birdyslim": {
"enabled": true, "enabled": true,
"rxchain": { "rxchain": {
"lorawan": true, "lorawan": true,
"events": { "events": {
"webhook": false, "webhook": false,
"mqtt": false "mqtt": false
}
},
"boskrypt": {
"enabled": true,
"keys": {
"42001A": "6e6a31fdb56cfd03f52599dec12d75daae0fb027d791b109c872a6ba8fffa403",
"42001B": "da281a96c138ca40c810157c75c38f27c08671ee346e2bc7d9be8f7f0b2c5c38"
} }
} }
} }
} },
"boskrypt": {
"enabled": true,
"keys": {
}
},
"deliveryPresets": {
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

File diff suppressed because one or more lines are too long

@ -0,0 +1,413 @@
<!DOCTYPE html>
<html>
<head>
<title>Dispatcher Configuration</title>
<!-- <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet"> -->
<link href="css/materialdesignicons.min.css" rel="stylesheet">
<link href="css/vuetify.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>
<body>
<div id="app">
<v-app>
<v-app-bar app>
<v-toolbar-title>Dispatcher Configuration</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn color="success" @click="storeConfig()">Store & Restart</v-btn>
<v-checkbox label="Expert Mode" v-model="EXPERTMODE"></v-checkbox>
</v-app-bar>
<v-content>
<v-form>
<v-tabs v-model="configTab" next-icon="mdi-arrow-right-bold-box-outline"
prev-icon="mdi-arrow-left-bold-box-outline" show-arrows>
<v-tabs-slider></v-tabs-slider>
<v-tab key="profiles">Profiles</v-tab>
<v-tab key="gateways">Gateway Config</v-tab>
<v-tab key="devices">Device Config</v-tab>
<v-tab key="boskrypt">
<v-img src="boskrypt.gif" max-width="64px" max-height="32px"></v-img>
</v-tab>
<!-- <v-tab v-show="EXPERTMODE" key="notificationConfig">Notification Configuration</v-tab> -->
</v-tabs>
<v-tabs-items v-model="configTab">
<v-tab-item key="profiles">
<v-container>
<v-row>
<v-btn color="green" fab dark small icon @click="addProfile()">
<v-icon>mdi-plus</v-icon>
</v-btn>
</v-row>
<v-row v-for="(deliveryPreset, index) in configData.deliveryPresets"
:key="deliveryPreset._id" style="border-bottom: 2px solid black;">
<v-col cols="12" sm="12" md="12">
<pre>Index: {{ index }}</pre>
<v-btn color="error" @click="deleteProfile(index)" icon>
<v-icon>mdi-delete</v-icon>
</v-btn>
</v-col>
<v-col cols="6" sm="6" md="4">
<v-text-field v-model="deliveryPreset.name" label="Name"></v-text-field>
<v-select :items="pagerTypes" v-model="deliveryPreset.params.type" item-text="k"
item-value="v" label="Delivery Type"></v-select>
<v-select :items="deviceType" v-model="deliveryPreset.params.routing.device"
item-text="k" item-value="v" label="Device"></v-select>
</v-col>
<v-col>
<b>Delivery Targets:</b>
<v-btn color="success" @click="addDeliveryTarget(index)">Add</v-btn>
<v-row v-for="(connector, index) in deliveryPreset.params.routing.connectors"
:key="index">
<v-col cols="6" sm="6" md="6">
<v-select :items="connectorTypes" v-model="connector[0]" item-text="k"
item-value="v" label="Gateway"></v-select>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-text-field v-model="connector[1]" label="Call ID">
<v-btn slot="append" color="error"
@click="deliveryPreset.params.routing.connectors.splice(index, 1)"
icon>
<v-icon>mdi-delete</v-icon>
</v-btn>
</v-text-field>
</v-col>
</v-row>
</v-col>
</v-row>
<v-row>
</v-row>
</v-container>
</v-tab-item>
<v-tab-item key="gateways">
<v-container>
<v-list three-line>
<v-list-item> <!-- Dummy-->
<v-list-item-content>
<v-list-item-title>Dummy</v-list-item-title>
<v-list-item-action>
<v-row cols="12">
<v-col cols="6" sm="6" md="6">
<v-switch v-model="configData.connectors.dummy.enabled" label="Enabled"></v-switch>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-text-field type="number" :rules="validNumberRules" label="Duplex Timeout in seconds" v-model="configData.connectors.dummy.duplexTimeout"></v-text-field>
</v-col>
</v-row>
</v-list-item-action>
</v-list-item-content>
</v-list-item>
<v-divider></v-divider>
<v-list-item> <!-- POCSAG-GW-->
<v-list-item-content>
<v-list-item-title>POCSAG-GW</v-list-item-title>
<v-list-item-action>
<v-row cols="12">
<v-col cols="6" sm="6" md="6">
<v-switch v-model="configData.connectors.pocsag.enabled" label="Enabled"></v-switch>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-text-field type="number" :rules="validNumberRules" label="Duplex Timeout in seconds" v-model="configData.connectors.pocsag.duplexTimeout"></v-text-field>
</v-row>
</v-row>
</v-list-item-action>
</v-list-item-content>
</v-list-item>
<v-divider></v-divider>
<v-list-item> <!-- DAPNET-->
<v-list-item-content>
<v-list-item-title>DAPNET</v-list-item-title>
<v-list-item-action>
<v-row cols="12">
<v-col cols="6" sm="6" md="6">
<v-switch v-model="configData.connectors.dapnet.enabled" label="Enabled"></v-switch>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-text-field type="number" :rules="validNumberRules" label="Duplex Timeout in seconds" v-model="configData.connectors.dapnet.duplexTimeout"></v-text-field>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-text-field label="Username" v-model="configData.connectors.dapnet.username"></v-text-field>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-text-field label="Password" type="password" v-model="configData.connectors.dapnet.password"></v-text-field>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-text-field label="Endpoint" v-model="configData.connectors.dapnet.endpoint"></v-text-field>
</v-col>
</v-row>
</v-list-item-action>
</v-list-item-content>
</v-list-item>
<v-divider></v-divider>
<v-list-item> <!-- e*Cityruf (inetgw) -->
<v-list-item-content>
<v-list-item-title>e*Cityruf (inetgw)</v-list-item-title>
<v-list-item-action>
<v-row cols="12">
<v-col cols="6">
<v-switch v-model="configData.connectors.ecityruf.enabled" label="Enabled"></v-switch>
</v-col>
<v-col cols="6">
<v-text-field type="number" :rules="validNumberRules" label="Duplex Timeout in seconds" v-model="configData.connectors.ecityruf.duplexTimeout"></v-text-field>
</v-col>
</v-row>
</v-list-item-action>
</v-list-item-content>
</v-list-item>
<v-divider></v-divider>
<v-list-item> <!-- e*Message Puppeteering -->
<v-list-item-content>
<v-list-item-title>e*Message Puppeteering</v-list-item-title>
<v-list-item-action>
<v-row cols="12">
<v-col cols="6">
<v-switch v-model="configData.connectors.emPuppettering.enabled" label="Enabled"></v-switch>
</v-col>
<v-col cols="6">
<v-text-field type="number" :rules="validNumberRules" label="Duplex Timeout in seconds" v-model="configData.connectors.emPuppettering.duplexTimeout"></v-text-field>
</v-col>
</v-row>
</v-list-item-action>
</v-list-item-content>
</v-list-item>
<v-divider></v-divider>
<v-list-item> <!-- e*Message alertManager -->
<v-list-item-content>
<v-list-item-title>e*Message alertManager</v-list-item-title>
<v-list-item-action>
<v-row cols="12">
<v-col cols="6">
<v-switch v-model="configData.connectors.emessage.enabled" label="Enabled"></v-switch>
</v-col>
<v-col cols="6">
<v-text-field type="number" :rules="validNumberRules" label="Duplex Timeout in seconds" v-model="configData.connectors.emessage.duplexTimeout"></v-text-field>
</v-col>
<v-col cols="6">
<v-text-field type="number" :rules="validNumberRules" label="Response Timeout in seconds" v-model="configData.connectors.emessage.responseTimeout"></v-text-field>
</v-col>
<v-col cols="6">
<v-text-field type="number" :rules="validNumberRules" label="Start Interval in seconds" v-model="configData.connectors.emessage.startInterval"></v-text-field>
</v-col>
<v-col cols="6">
<v-text-field label="Username" v-model="configData.connectors.emessage.username"></v-text-field>
</v-col>
<v-col cols="6">
<v-text-field label="Password" type="password" v-model="configData.connectors.emessage.password"></v-text-field>
</v-col>
<v-col cols="6">
<v-switch v-model="configData.connectors.emessage['2wayS_BackChannel']" label="2wayS BackChannel"></v-switch>
</v-col>
</v-row>
</v-list-item-action>
</v-list-item-content>
</v-list-item>
<v-divider></v-divider>
<v-list-item> <!-- pagernetz.at -->
<v-list-item-content>
<v-list-item-title>pagernetz.at</v-list-item-title>
<v-list-item-action>
<v-row cols="12">
<v-col cols="6">
<v-switch v-model="configData.connectors.pagernetzAT.enabled" label="Enabled"></v-switch>
</v-col>
<v-col cols="6">
<v-text-field type="number" :rules="validNumberRules" label="Duplex Timeout in seconds" v-model="configData.connectors.pagernetzAT.duplexTimeout"></v-text-field>
</v-col>
</v-row>
</v-list-item-action>
</v-list-item-content>
</v-list-item>
<v-divider></v-divider>
</v-list>
</v-container>
</v-tab-item>
<v-tab-item key="devices">
<v-container>
<v-list three-line>
<v-list-item> <!-- Birdy Slim IoT -->
<v-list-item-content>
<v-list-item-title>Birdy Slim IoT</v-list-item-title>
<v-list-item-action>
<v-row cols="12">
<v-col cols="6" sm="6" md="6">
<v-switch v-model="configData.pagers.birdyslim.enabled" label="Enabled"></v-switch>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-switch v-model="configData.pagers.birdyslim.rxchain.lorawan" label="RXChain LoRaWAN Enabled"></v-switch>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-switch v-model="configData.pagers.birdyslim.rxchain.events.mqtt" label="MQTT Events Enabled"></v-switch>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-switch v-model="configData.pagers.birdyslim.rxchain.events.webhook" label="Webhook Enabled"></v-switch>
</v-col>
</v-row>
</v-list-item-action>
</v-list-item-content>
</v-list-item>
</v-list>
</v-container>
</v-tab-item>
<v-tab-item key="boskrypt">
<v-container>
<v-row v-for="(boskryptKey, index) in configData.boskrypt.keys" :key="index">
<v-col cols="6" sm="4" md="4">
<v-text-field v-model="boskryptKey.identifier" label="Identifier">
</v-text-field>
</v-col>
<v-col cols="8" sm="8" md="8">
<v-text-field v-model="boskryptKey.value" label="Key">
<v-btn slot="append" color="error"
@click="configData.boskrypt.keys.splice(index, 1)" icon>
<v-icon>mdi-delete</v-icon>
</v-btn>
</v-text-field>
</v-col>
</v-row>
</v-container>
</v-tab-item>
</v-tabs-items>
</v-form>
</v-content>
</v-app>
</div>
<script src="js/vue/vue.js"></script>
<script src="js/vue/vuetify.js"></script>
<script src="js/vue/vue-resource_1.5.1.js"></script>
<script>
new Vue({
el: '#app',
vuetify: new Vuetify(),
http: { root: '/' },
data() {
return {
EXPERTMODE: false,
configTab: null,
validNumberRules: [
v => !isNaN(parseInt(v)) || 'is not a valid number'
],
pagerTypes: [
{ k: 'Simple', v: 'simple' },
{ k: 'Duplex', v: 'duplex' },
],
deviceType: [
{ k: 'Generic', v: 'generic' },
{ k: 'Birdy Slim (IoT)', v: 'birdyslim' },
],
connectorTypes: [
{ k: 'Dummy', v: 'dummy' },
{ k: 'POCSAG GW', v: 'pocsag' },
{ k: 'DAPNET', v: 'dapnet' },
{ k: 'e*Cityruf inetgw', v: 'ecityruf' },
{ k: 'e*Cityruf Puppeteer', v: 'em-p-cityruf' },
{ k: 'e*Cityruf alertManager', v: 'em-a-cityruf' },
{ k: 'e*2wayS Puppeteer', v: 'em-p-twoways' },
{ k: 'e*2wayS alertManager', v: 'em-a-twoways' },
{ k: 'LoRaWAN TTNv3', v: 'lorawan' },
],
configData: {
boskrypt: {
keys: []
},
pagers: {
birdyslim: {
enabled: true,
rxchain: {
lorawan: true,
events: {
webhook: false,
mqtt: false
}
}
}
},
connectors: {
dummy: {
enabled: null, duplexTimeout: null,
},
pocsag: {
enabled: null, duplexTimeout: null,
},
dapnet: {
enabled: null, duplexTimeout: null,
},
ecityruf: {
enabled: null, duplexTimeout: null,
},
}
},
}
},
created() {
this.loadConfig()
},
methods: {
loadConfig() {
this.$http.get('/config').then(response => {
const newConfig = response.body
Object.keys(newConfig.deliveryPresets)
.map(_key => {
newConfig.deliveryPresets[_key]._id = btoa(JSON.stringify(newConfig.deliveryPresets[_key]))
})
if (!!newConfig.boskrypt)
newConfig.boskrypt.keys = Object.keys(newConfig.boskrypt.keys)
.map(_key => {
return {
identifier: _key,
value: newConfig.boskrypt.keys[_key]
}
})
this.configData = newConfig
}, response => {
})
},
storeConfig() {
const storeConfig = JSON.parse(JSON.stringify(this.configData))
const oldBK = storeConfig.boskrypt.keys
storeConfig.boskrypt.keys = Object.values(oldBK).reduce((total, keyData) => {
total[ keyData.identifier ] = keyData.value
return total
}, {})
this.$http.post('/config', storeConfig).then(response => {
})
.then(this.$http.post('/restart'))
.then(() => {
document.body.style = 'display:none'
setTimeout(() => window.location.reload(), 1e3)
})
},
addDeliveryTarget(index) {
this.configData.deliveryPresets[index].params.routing.connectors.push(["dummy", "12345"])
},
addProfile() {
this.configData.deliveryPresets = Object.assign({}, this.configData.deliveryPresets, {
[new Date().valueOf().toString(16)]: {
name: "Name",
params: {
type: "simple",
routing: {
device: "generic",
connectors: []
}
}
}
})
},
deleteProfile(index) {
delete this.configData.deliveryPresets[index]
this.configData.deliveryPresets = Object.assign({}, this.configData.deliveryPresets)
},
}
})
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -82,8 +82,8 @@ Last LoRaWAN Packet:
<v-toolbar-title>New Message</v-toolbar-title> <v-toolbar-title>New Message</v-toolbar-title>
<v-spacer></v-spacer> <v-spacer></v-spacer>
</v-toolbar> </v-toolbar>
<v-container> <v-container v-if="EXPERTMODE">
<b>Routing Paramters:</b> <b>Routing Parameters:</b>
<v-row> <v-row>
<v-col cols="12" sm="12" md="6"> <v-col cols="12" sm="12" md="6">
<v-select :items="pagerTypes" v-model="newMSGData.pager.params.type" item-text="k" item-value="v" label="Delivery Type"></v-select> <v-select :items="pagerTypes" v-model="newMSGData.pager.params.type" item-text="k" item-value="v" label="Delivery Type"></v-select>
@ -118,6 +118,33 @@ Last LoRaWAN Packet:
</v-col> </v-col>
</v-row> </v-row>
</v-container> </v-container>
<v-container v-else>
<v-row>
<v-col cols="12" sm="12" md="6">
<v-autocomplete
v-model="newMSGData.preset"
:items="presetSearchItems"
:loading="!presetSearchItems.length > 0"
color="white"
hide-no-data
dense
label="Profile"
placeholder="Start typing to Search"
prepend-icon="mdi-database-search"
></v-autocomplete>
</v-col>
</v-row>
<v-row>
<v-col cols="12" sm="12" md="6">
<v-textarea v-model="newMSGData.pager.payload" label="Message"></v-select>
</v-col>
</v-row>
<v-row>
<v-col cols="12" sm="12" md="6">
<v-btn color="success" dark text @click="testMsg_send()">Send</v-btn>
</v-col>
</v-row>
</v-container>
</v-card> </v-card>
</v-dialog> </v-dialog>
</v-toolbar> </v-toolbar>
@ -151,7 +178,7 @@ Last LoRaWAN Packet:
EXPERTMODE:false, EXPERTMODE:false,
dialogNewMessage: false, dialogNewMessage: false,
presetSearchItems: [],
loadingD: true, loadingD: true,
loadingM: true, loadingM: true,
@ -219,6 +246,7 @@ Last LoRaWAN Packet:
}, },
"payload": "Test Message", "payload": "Test Message",
}, },
"preset": null,
} }
} }
}, },
@ -228,6 +256,17 @@ Last LoRaWAN Packet:
this.refreshMessages() this.refreshMessages()
setInterval(this.refreshMessages, 1e3) setInterval(this.refreshMessages, 1e3)
this.$http.get('/api/deliveryPresets')
.then(response => {
console.log(response.body)
this.presetSearchItems = response.body.map(x => { return {
text: x.name,
value: x.key,
//Description
}})
}, response => {
})
}, },
methods: { methods: {
refreshDevices() { refreshDevices() {
@ -276,11 +315,20 @@ Last LoRaWAN Packet:
this.newMSGData.pager.params.routing.connectors.push(["dummy","1234"]) this.newMSGData.pager.params.routing.connectors.push(["dummy","1234"])
}, },
testMsg_send() { testMsg_send() {
this.$http.post('/api/message/advanced/', if (this.EXPERTMODE) {
Object.assign({ ...this.newMSGData.pager.params }, { payload: this.newMSGData.pager.payload }) this.$http.post('/api/message/advanced/',
).then(x=>{ Object.assign({ ...this.newMSGData.pager.params }, { payload: this.newMSGData.pager.payload })
this.dialogNewMessage = false ).then(x=>{
}) this.dialogNewMessage = false
})
} else {
console.log(this.newMSGData.preset)
this.$http.post('/api/message/preset/',
Object.assign({ preset: this.newMSGData.preset }, { payload: this.newMSGData.pager.payload })
).then(x=>{
this.dialogNewMessage = false
})
}
} }
} }

@ -2,6 +2,7 @@ const amqp = require('amqp-connection-manager')
const fs = require('fs') const fs = require('fs')
const config = require('./config.json') const config = require('./config.json')
// Create a connetion manager // Create a connetion manager
const connection = amqp.connect(config.general.amqp) const connection = amqp.connect(config.general.amqp)
connection.on('connect', () => console.log('Connected to AMQP.')) connection.on('connect', () => console.log('Connected to AMQP.'))
@ -52,8 +53,23 @@ app.use(express.static('html_main'))
app.use(express.static(__dirname + '/node_modules/@mdi/font')) app.use(express.static(__dirname + '/node_modules/@mdi/font'))
appConfig.use(express.json()) appConfig.use(express.json())
appConfig.use(express.static('html')) appConfig.use(express.static('html_config'))
appConfig.use(express.static(__dirname + '/node_modules/@mdi/font'))
app.post('/api/message/preset', async (req, res) => {
if (!req.body.preset) return res.status(500).json("ERROR: no msg preset")
if (!req.body.payload) return res.status(500).json("ERROR: no msg payload")
if (!config.deliveryPresets[ req.body.preset ]) return res.status(500).json("ERROR: delivery Preset does not exist")
let id = await types.MessageManager.New(
config.deliveryPresets[ req.body.preset ].params.type,
config.deliveryPresets[ req.body.preset ].params.routing,
req.body.payload
)
await types.MessageManager.Deliver(id)
return res.json(id)
})
app.post('/api/message/advanced', async (req, res) => { app.post('/api/message/advanced', async (req, res) => {
if (!req.body.type) return res.status(500).json("ERROR: no msg type(simple,duplex)") if (!req.body.type) return res.status(500).json("ERROR: no msg type(simple,duplex)")
if (!req.body.payload) return res.status(500).json("ERROR: no msg payload") if (!req.body.payload) return res.status(500).json("ERROR: no msg payload")
@ -63,7 +79,6 @@ app.post('/api/message/advanced', async (req, res) => {
await types.MessageManager.Deliver(id) await types.MessageManager.Deliver(id)
return res.json(id) return res.json(id)
}) })
app.post('/api/message/advanced/menu', async (req, res) => { app.post('/api/message/advanced/menu', async (req, res) => {
if (!req.body.payload) return res.status(500).json("ERROR: no msg payload") if (!req.body.payload) return res.status(500).json("ERROR: no msg payload")
if (!req.body.options) return res.status(500).json("ERROR: no msg options") if (!req.body.options) return res.status(500).json("ERROR: no msg options")
@ -80,6 +95,8 @@ app.post('/api/message/advanced/menu', async (req, res) => {
await types.MessageManager.Deliver(id) await types.MessageManager.Deliver(id)
return res.json(id) return res.json(id)
}) })
app.get('/api/message/status/:id/menu', async (req, res) => { //TODO: make this fancy app.get('/api/message/status/:id/menu', async (req, res) => { //TODO: make this fancy
return res.json(types.MessageManager.messages[ req.params.id ]) return res.json(types.MessageManager.messages[ req.params.id ])
}) })
@ -125,6 +142,18 @@ app.get('/api/device/:id', async (req, res) => {
app.get('/api/devices', async (req, res) => { app.get('/api/devices', async (req, res) => {
return res.json(types.DeviceRegistry.DeviceStates) return res.json(types.DeviceRegistry.DeviceStates)
}) })
app.get('/api/deliveryPresets', async (req, res) => {
return res.json(
Object.keys(config.deliveryPresets)
.map(key => {
return {
key,
name: config.deliveryPresets[ key ].name
}
})
)
})
const io = require('socket.io')(appServer) const io = require('socket.io')(appServer)
io.on("connection", socket => { io.on("connection", socket => {
@ -143,7 +172,25 @@ types.DeviceRegistry.events.on('event', (deviceType, deviceId, eventData) => {
/** CONFIG Routes */ /** CONFIG Routes */
appConfig.get('/config', async (req, res) => { appConfig.get('/config', async (req, res) => {
return res.json(JSON.parse(fs.readFileSync('config.json'))) const parsedConfig = JSON.parse(fs.readFileSync('config.json'))
parsedConfig.deliveryPresets = parsedConfig.deliveryPresets || {
'example': {
"name": "Normal",
"params": {
"type": "duplex",
"routing": {
"device": "generic",
"connectors": [
[
"dummy",
"1234"
]
]
}
},
}
}
return res.json(parsedConfig)
}) })
appConfig.post('/config', async (req, res) => { appConfig.post('/config', async (req, res) => {
if (!(!!req.body.general)) return res.status(403).json(false) if (!(!!req.body.general)) return res.status(403).json(false)

@ -17,6 +17,7 @@
}, },
"homepage": "https://github.com/smartpager-network/pocsag-daemon#readme", "homepage": "https://github.com/smartpager-network/pocsag-daemon#readme",
"dependencies": { "dependencies": {
"@mdi/font": "^7.0.96",
"@supercharge/strings": "^1.18.0", "@supercharge/strings": "^1.18.0",
"amqp-connection-manager": "^3.2.2", "amqp-connection-manager": "^3.2.2",
"amqplib": "^0.7.0", "amqplib": "^0.7.0",

@ -42,9 +42,9 @@ class POCSAGConnector extends Connector {
const $device = msg.routingParams.device const $device = msg.routingParams.device
// todo centralize this in a encryptionManager to then make it easier to integrate with eCitryruf // todo centralize this in a encryptionManager to then make it easier to integrate with eCitryruf
const boskryptSupport = require("../DeviceRegistry").Devices[ $device ].supportBOSkrypt || false const boskryptSupport = require("../DeviceRegistry").Devices[ $device ].supportBOSkrypt || false
if (boskryptSupport && !!config.pagers[ $device ] && config.pagers[ $device ].boskrypt.enabled) { if (boskryptSupport && !!config.boskrypt && config.boskrypt.enabled) {
//payloadBuffer //payloadBuffer
const keyTable = config.pagers[ $device ].boskrypt.keys const keyTable = config.boskrypt.keys
if (!!keyTable[ RIC ]) { if (!!keyTable[ RIC ]) {
payloadBuffer = Buffer.from(boskrypt.encrypt(payloadBuffer, keyTable[ RIC ], 0)) payloadBuffer = Buffer.from(boskrypt.encrypt(payloadBuffer, keyTable[ RIC ], 0))
} }

@ -18,9 +18,9 @@ class eCityrufConnector extends Connector {
const $device = msg.routingParams.device const $device = msg.routingParams.device
let payloadBuffer = Buffer.from(msg.payload) let payloadBuffer = Buffer.from(msg.payload)
const boskryptSupport = require("../DeviceRegistry").Devices[ $device ].supportBOSkrypt || false const boskryptSupport = require("../DeviceRegistry").Devices[ $device ].supportBOSkrypt || false
if (boskryptSupport && !!config.pagers[ $device ] && config.pagers[ $device ].boskrypt.enabled) { if (boskryptSupport && !!config.boskrypt && config.boskrypt.enabled) {
//payloadBuffer //payloadBuffer
const keyTable = config.pagers[ $device ].boskrypt.keys const keyTable = config.boskrypt.keys
const FunkrufNummer = "em-"+params[ 0 ] const FunkrufNummer = "em-"+params[ 0 ]
if (!!keyTable[ FunkrufNummer ]) { if (!!keyTable[ FunkrufNummer ]) {
payloadBuffer = Buffer.from(boskrypt.encrypt(payloadBuffer, keyTable[ FunkrufNummer ], 0)) payloadBuffer = Buffer.from(boskrypt.encrypt(payloadBuffer, keyTable[ FunkrufNummer ], 0))

@ -23,9 +23,9 @@ class eMessageAlertManagerConnectorBase extends Connector {
const $device = msg.routingParams.device const $device = msg.routingParams.device
let payloadBuffer = Buffer.from(msg.payload) let payloadBuffer = Buffer.from(msg.payload)
const boskryptSupport = require("../DeviceRegistry").Devices[ $device ].supportBOSkrypt || false const boskryptSupport = require("../DeviceRegistry").Devices[ $device ].supportBOSkrypt || false
if (boskryptSupport && !!config.pagers[ $device ] && config.pagers[ $device ].boskrypt.enabled) { if (boskryptSupport && !!config.boskrypt && config.boskrypt.enabled) {
//payloadBuffer //payloadBuffer
const keyTable = config.pagers[ $device ].boskrypt.keys const keyTable = config.boskrypt.keys
const FunkrufNummer = "em-"+identifier const FunkrufNummer = "em-"+identifier
if (!!keyTable[ FunkrufNummer ]) { if (!!keyTable[ FunkrufNummer ]) {
payloadBuffer = Buffer.from(boskrypt.encrypt(payloadBuffer, keyTable[ FunkrufNummer ], 0)) payloadBuffer = Buffer.from(boskrypt.encrypt(payloadBuffer, keyTable[ FunkrufNummer ], 0))

@ -27,9 +27,9 @@ class eMessagePuppeteerConnectorBase extends Connector {
let payloadBuffer = Buffer.from(msg.payload) let payloadBuffer = Buffer.from(msg.payload)
const boskryptSupport = require("../DeviceRegistry").Devices[ $device ].supportBOSkrypt || false const boskryptSupport = require("../DeviceRegistry").Devices[ $device ].supportBOSkrypt || false
console.log('device supports boskrypt', boskryptSupport) console.log('device supports boskrypt', boskryptSupport)
if (boskryptSupport && !!config.pagers[ $device ] && config.pagers[ $device ].boskrypt.enabled) { if (boskryptSupport && !!config.boskrypt && config.boskrypt.enabled) {
//payloadBuffer //payloadBuffer
const keyTable = config.pagers[ $device ].boskrypt.keys const keyTable = config.boskrypt.keys
const FunkrufNummer = "em-"+identifier const FunkrufNummer = "em-"+identifier
console.log('LUT ', FunkrufNummer, 'key=', keyTable[ FunkrufNummer ]) console.log('LUT ', FunkrufNummer, 'key=', keyTable[ FunkrufNummer ])
if (!!keyTable[ FunkrufNummer ]) { if (!!keyTable[ FunkrufNummer ]) {

Loading…
Cancel
Save