Initial Upload

pull/1/head
John Hays 9 months ago
parent 5e26b25cfb
commit eee9c02c36

@ -0,0 +1,28 @@
body {
background-color : LightGrey;
font-family: sans-serif;
}
td {
text-align: center;
}
#lhtable {
border: 1px solid black;
background-color: PowderBlue;
}
#linktable {
border: 1px solid black;
background-color: Lime;
}
#lhtable caption , #linktable caption {
font-weight : bold;
font-size : 2em;
color : white;
background-color : black;
}
#linktable {
width: 100%;
}
#lhtable {
width: 100%;
}

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<script src="/socket.io/socket.io.js"></script>
<script src="/script.js"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"
integrity="sha256-lSjKY0/srUM9BE3dPm+c4fBo1dky2v27Gdjm2uoZaL0="
crossorigin="anonymous"></script>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="dashboard.css">
<title>Dashboard</title>
</head>
<body>
<h1 id="intro">Hi from the Dashboard</h1>
<div>
<div id="instruct"></div>
<div id="links"></div>
<div id="lastheard"></div>
</div>
</body>
</html>

@ -0,0 +1,45 @@
const socket = io();
socket.addEventListener("connect", () => {
socket.emit("Hello from script.js");
});
socket.addEventListener("message", data => {
console.log(data[0]);
$("#intro").text(data);
});
socket.addEventListener("title", data => {
console.log(data);
$("title").text(data);
$("#intro").text(data);
});
socket.addEventListener("links", data => {
// console.log("links " + data);
$("#links").empty();
$("#links").append("<table id=\"linktable\"><caption>Links</caption>");
$("#linktable").append("<tr><th>Repeater</th><th>Reflector</th><th>Protocol</th>" +
"<th>Device</th><th>Direction</th><th>Timestamp</th></tr>");
$.each(data, function(index,val){
$("#linktable").append("<tr><td>" + val.repeater + "</td><td>" + val.reflector +
"</td><td>" + val.protocol + "</td><td>" + val.device + "</td><td>" +
val.direction + "</td><td>" + val.timestamp + "</td></tr>");
// console.log(index, val);
});
});
socket.addEventListener("lastheard", data => {
// console.log("lastheard " + data);
$("#lastheard").empty();
$("#lastheard").append("<table id=\"lhtable\"><caption>Last Heard</caption>");
$("#lhtable").append("<tr><th>MYcall</th><th>URcall</th><th>Rpt1</th><th>Rpt2</th><th>Source</th><th>Date</th><th>Time</th></tr>");
$.each(data, function(index,val){
// console.log(index, val);
var mcall = val.mycall;
if (val.msg1 != "") mcall += " / " + val.msg1;
$("#lhtable").append("<tr><td>" + mcall + "</td><td>"+ val.urcall +
"</td><td>" + val.rpt1 + "</td><td>" + val.rpt2 +
"</td><td>" + val.source + "</td><td>" + val.date + "</td><td>" + val.time + "</td></tr>");
})
});

@ -0,0 +1,14 @@
[logs]
headers=/var/log/dstargateway/Headers.log
links=/var/log/dstargateway/Links.log
[config]
dgwconfig=/usr/local/etc/dstargateway.cfg
host=kf7ufz.ampr.org
port=443
[urls]
sponsor=https://groups.io/g/gkrc
registration=https://regist.dstargateway.org
ircddblive=http://live3.ircddb.net:8080/ircddblive5.html
[params]
linkqueue=10
heardqueue=20

@ -0,0 +1,130 @@
const https = require("https");
const fs = require("fs");
const ini = require("ini");
const lineReader = require('line-reader');
const express = require("express");
const socketio = require('socket.io');
const path = require('path');
const Tail = require('tail-file');
const CircularBuffer = require("circular-buffer");
const inifile = ini.parse(fs.readFileSync('./dashboard.ini', 'utf-8'));
const host = inifile.config.host;
const port = inifile.config.port;
const links = inifile.logs.links;
const linkqueue = parseInt(inifile.params.linkqueue);
const heardqueue = parseInt(inifile.params.heardqueue);
const headers = inifile.logs.headers;
const dgwconfig = ini.parse(fs.readFileSync(inifile.config.dgwconfig, 'utf-8'));
const app = express();
const buf = new CircularBuffer(heardqueue);
const linklist = new CircularBuffer(linkqueue);
linklist.push({'timestamp':'0000-00-00 00:00:00' , 'protocol': 'none' , 'device':'none',
'repeater': 'none', 'reflector': 'none' , 'direction' : '' });
updatelinks();
const server = https
.createServer(
{
key: fs.readFileSync("key.pem"),
cert: fs.readFileSync("cert.pem"),
},
app
)
.listen(443, ()=>{
console.log('server is running at port 443')
});
app.get('/', (req,res)=>{
res.sendFile(path.resolve(__dirname, 'client', 'index.html'));
});
app.use(express.static(path.resolve(__dirname, 'client')));
const io = socketio(server);
function senddata(dest,data,socket) {
console.log("Enter Senddata -> " + dest);
socket.emit(dest,data);
// console.log(dest,JSON.stringify(data));
console.log("Leave Senddata -> " + dest);
}
function updatelinks() {
console.log("Entering updatelinks");
const linksregex = /(.*) (.*) (.*) - Type: (.*) Rptr: (.*) Refl: (.*) Dir: (.*)/;
const linkfile = fs.readFileSync(links).toString();
const lines = linkfile.split(/\n|\r\n/);
console.log("Queue Size in: " + linklist.size());
while (linklist.size() > 0) {
linklist.deq();
};
console.log("Queue Size out: " + linklist.size());
console.log("File Length: " + lines.length);
let i = 0;
while (i < lines.length) {
if(lines[i] != "") {
var mylinks = lines[i].match(linksregex);
console.log(JSON.stringify(lines[i]));
var linkrec = {'timestamp':mylinks[1].substr(0,19) , 'protocol':mylinks[2] , 'device':mylinks[4],
'repeater':mylinks[5] , 'reflector':mylinks[6] , 'direction' : mylinks[7] };
linklist.push(linkrec);
}
i++;
}
// console.log("From updatelinks() " + JSON.stringify(linklist.toarray()));
// senddata("links",linklist.toarray(),io);
console.log("Leaving updatelinks");
}
io.on('connection', (socket) => {
console.log('WS New connection');
senddata("lastheard",buf.toarray(),socket);
senddata("links",linklist.toarray(),socket);
senddata("title",host + " Dashboard",socket);
console.log("leaving connection");
});
// io.on('message', (socket) => {
// console.log('New Message' + JSON.stringify(socket))
//});
fs.watch(headers, (curr, prev)=>{
console.log(headers + ' file changed');
// console.log("from fs.watch headers " + JSON.stringify(buf.toarray()));
senddata("lastheard",buf.toarray(),io);
});
fs.watch(links, (curr, prev)=>{
console.log(links + ' file changed');
// console.log("from fs.watch links " + JSON.stringify(linklist.toarray()));
updatelinks();
// console.log("from fs.watch links " + JSON.stringify(linklist.toarray()));
senddata("links",linklist.toarray(),io);
console.log("Leaving links watch");
});
const tailheaders = new Tail(headers, {startPos : 'end'}, line => {
const headerregex = /(.*) (.*) header.*My: (.*) Your: (.*) *Rpt1: (.*) *Rpt2: (.*) Flags.*\((.*)\)/;
const groups = line.match(headerregex);
// console.log(JSON.stringify(groups));
if (groups) {
var ipport = groups[7].split(':');
var my = groups[3].split('/');
var [dstamp,tstamp] = groups[1].split(" ");
var record = {'date':dstamp,'time':tstamp.substr(0,8),
'source':groups[2].trim(),'mycall':my[0].trim(),'msg1':my[1].trim(),
'urcall':groups[4].trim(),'rpt1':groups[5].trim(),'rpt2':groups[6].trim(),
'srcip':ipport[0],'srcport':ipport[1]};
buf.push(record);
senddata("lastheard",buf.toarray(),io);
// console.log(JSON.stringify(record));
}
});
tailheaders.start();

1705
package-lock.json generated

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save