Added useful URLs

only_http
John Hays 10 months ago
parent c3b3df5d32
commit 1b89a4c491

@ -9,15 +9,19 @@ td , caption , th {
border: 1px solid black; border: 1px solid black;
background-color: PowderBlue; background-color: PowderBlue;
} }
#repeaters { #rptrtable {
border: 1px solid black; border: 1px solid black;
background-color: Yellow; background-color: Yellow;
} }
#urltable {
border: 1px solid black;
background-color: White;
}
#linktable { #linktable {
border: 1px solid black; border: 1px solid black;
background-color: Lime; background-color: Lime;
} }
#lhtable caption , #linktable caption , #rptrtable caption { #lhtable caption , #linktable caption , #rptrtable caption , #urltable caption{
font-weight : bold; font-weight : bold;
font-size : 2em; font-size : 2em;
color : white; color : white;
@ -25,6 +29,6 @@ td , caption , th {
width : 100%; width : 100%;
} }
#linktable , #lhtable , #rptrtable { #linktable , #lhtable , #rptrtable , #urltable {
width: 100%; width: 100%;
} }

@ -19,10 +19,10 @@
<h1 id="intro">Dashboard</h1> <h1 id="intro">Dashboard</h1>
<div> <div>
<div id="instruct"></div>
<div id="repeaters"></div>
<div id="links"></div> <div id="links"></div>
<div id="lastheard"></div> <div id="lastheard"></div>
<div id="repeaters"></div>
<div id="instruct"></div>
</div> </div>
</body> </body>
</html> </html>

@ -4,13 +4,24 @@ socket.addEventListener("connect", () => {
socket.emit("Hello from script.js"); socket.emit("Hello from script.js");
}); });
socket.addEventListener("message", data => { socket.addEventListener("info", indata => {
console.log(data[0]); // console.log(indata);
$("#intro").text(data); const data = JSON.parse(indata);
$("#instruct").empty();
$("#instruct").append("<table id=\"urltable\"><caption>Helpful URLs</caption>");
$("#urltable").append("<tr><th>Sponsor</th><th>Live</th><th>Utilities</th></tr>");
$("#urltable").append("<tr><td><a target=\"sponsor\" href=\"" + data.sponsor + "\">" +
data.sponsorname + "</a></td><td><a target=\"live\" href=\"" + data.live_1 + "\">" +
data.livename_1 + "</a></td><td><a target=\"register\" href=\"" + data.registration +
"\">" + data.registersite + "</a></td></tr>");
$("#urltable").append("<tr><td><a target=\"sponsor\" href=\"" + data.cosponsor + "\">" +
data.cosponsorname + "</a></td><td><a target=\"live\" href=\"" + data.live_2 + "\">" +
data.livename_2 + "</a></td><td></td></tr>");
}); });
socket.addEventListener("title", data => { socket.addEventListener("title", data => {
console.log(data); // console.log(data);
$("title").text(data); $("title").text(data);
$("#intro").text(data); $("#intro").text(data);
}); });

@ -3,7 +3,7 @@ headers=/var/log/dstargateway/Headers.log
links=/var/log/dstargateway/Links.log links=/var/log/dstargateway/Links.log
[config] [config]
dgwconfig=/usr/local/etc/dstargateway.cfg dgwconfig=/usr/local/etc/dstargateway.cfg
host=nw7dr.ampr.org host=kf7ufz.ampr.org
port=443 port=443
[urls] [urls]
sponsorname=Greater Kingston Radio Club sponsorname=Greater Kingston Radio Club
@ -18,4 +18,4 @@ livename_2=Openquad Live
live_2=https://openquad.net/last.php live_2=https://openquad.net/last.php
[params] [params]
linkqueue=10 linkqueue=10
heardqueue=20 heardqueue=15

@ -20,6 +20,9 @@ const dgwconfig = ini.parse(fs.readFileSync(inifile.config.dgwconfig, 'utf-8'));
const app = express(); const app = express();
const buf = new CircularBuffer(heardqueue); const buf = new CircularBuffer(heardqueue);
const linklist = new CircularBuffer(linkqueue); const linklist = new CircularBuffer(linkqueue);
const urls = inifile.urls;
var repeaterlist = []; var repeaterlist = [];
linklist.push({'timestamp':'0000-00-00 00:00:00' , 'protocol': 'none' , 'device':'none', linklist.push({'timestamp':'0000-00-00 00:00:00' , 'protocol': 'none' , 'device':'none',
@ -50,10 +53,7 @@ app.use(express.static(path.resolve(__dirname, 'client')));
const io = socketio(server); const io = socketio(server);
function senddata(dest,data,socket) { function senddata(dest,data,socket) {
//console.log("Enter Senddata -> " + dest);
socket.emit(dest,data); socket.emit(dest,data);
// console.log(dest,JSON.stringify(data));
// console.log("Leave Senddata -> " + dest);
} }
@ -72,22 +72,15 @@ function buildrepeaters(){
'description2':rptr.description2,'latitude':rptr.latitude, 'longitude': rptr.longitude}); 'description2':rptr.description2,'latitude':rptr.latitude, 'longitude': rptr.longitude});
} }
} }
// console.log(JSON.stringify(repeaterlist));
} }
function updatelinks() { function updatelinks() {
// console.log("Entering updatelinks");
const linksregex = /(.*) (.*) (.*) - Type: (.*) Rptr: (.*) Refl: (.*) Dir: (.*)/; const linksregex = /(.*) (.*) (.*) - Type: (.*) Rptr: (.*) Refl: (.*) Dir: (.*)/;
const linkfile = fs.readFileSync(links).toString(); const linkfile = fs.readFileSync(links).toString();
const lines = linkfile.split(/\n|\r\n/); const lines = linkfile.split(/\n|\r\n/);
// console.log("Queue Size in: " + linklist.size());
while (linklist.size() > 0) { while (linklist.size() > 0) {
linklist.deq(); linklist.deq();
}; };
// console.log("Queue Size out: " + linklist.size());
// console.log("File Length: " + lines.length);
let i = 0; let i = 0;
while (i < lines.length) { while (i < lines.length) {
if(lines[i] != "") { if(lines[i] != "") {
@ -99,9 +92,6 @@ function updatelinks() {
} }
i++; i++;
} }
// console.log("From updatelinks() " + JSON.stringify(linklist.toarray()));
// senddata("links",linklist.toarray(),io);
// console.log("Leaving updatelinks");
} }
@ -109,6 +99,7 @@ function updatelinks() {
io.on('connection', (socket) => { io.on('connection', (socket) => {
// console.log('WS New connection'); // console.log('WS New connection');
buildrepeaters(); buildrepeaters();
senddata("info",JSON.stringify(urls),socket);
senddata("lastheard",buf.toarray(),socket); senddata("lastheard",buf.toarray(),socket);
senddata("links",linklist.toarray(),socket); senddata("links",linklist.toarray(),socket);
senddata("title",host + " Dashboard",socket); senddata("title",host + " Dashboard",socket);
@ -116,29 +107,20 @@ io.on('connection', (socket) => {
// console.log("leaving connection"); // console.log("leaving connection");
}); });
// io.on('message', (socket) => {
// console.log('New Message' + JSON.stringify(socket))
//});
fs.watch(headers, (curr, prev)=>{ 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); senddata("lastheard",buf.toarray(),io);
}); });
fs.watch(links, (curr, prev)=>{ fs.watch(links, (curr, prev)=>{
// console.log(links + ' file changed');
// console.log("from fs.watch links " + JSON.stringify(linklist.toarray()));
updatelinks(); updatelinks();
// console.log("from fs.watch links " + JSON.stringify(linklist.toarray()));
senddata("links",linklist.toarray(),io); senddata("links",linklist.toarray(),io);
// console.log("Leaving links watch");
}); });
const tailheaders = new Tail(headers, {startPos : 'end'}, line => { const tailheaders = new Tail(headers, {startPos : 'end'}, line => {
const headerregex = /(.*) (.*) header.*My: (.*) Your: (.*) *Rpt1: (.*) *Rpt2: (.*) Flags.*\((.*)\)/; const headerregex = /(.*) (.*) header.*My: (.*) Your: (.*) *Rpt1: (.*) *Rpt2: (.*) Flags.*\((.*)\)/;
const groups = line.match(headerregex); const groups = line.match(headerregex);
// console.log(JSON.stringify(groups));
if (groups) { if (groups) {
var ipport = groups[7].split(':'); var ipport = groups[7].split(':');
var my = groups[3].split('/'); var my = groups[3].split('/');
@ -149,7 +131,6 @@ const tailheaders = new Tail(headers, {startPos : 'end'}, line => {
'srcip':ipport[0],'srcport':ipport[1]}; 'srcip':ipport[0],'srcport':ipport[1]};
buf.push(record); buf.push(record);
senddata("lastheard",buf.toarray(),io); senddata("lastheard",buf.toarray(),io);
// console.log(JSON.stringify(record));
} }
}); });

Loading…
Cancel
Save