From eb0d36d3f67be13de74023adb6d30362d47805fe Mon Sep 17 00:00:00 2001 From: Dave Hibberd Date: Fri, 11 Oct 2024 15:37:11 +0100 Subject: New upstream version 6.0.24.45 --- HTTPcode.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 11 deletions(-) (limited to 'HTTPcode.c') diff --git a/HTTPcode.c b/HTTPcode.c index e1ddfbe..1e4502c 100644 --- a/HTTPcode.c +++ b/HTTPcode.c @@ -1623,23 +1623,23 @@ int InnerProcessHTTPMessage(struct ConnectionInfo * conn) char * WebSock = 0; char PortsHddr[] = "

Ports

" - ""; + ""; - char PortLine[] = ""; +// char PortLine[] = ""; char PortLineWithBeacon[] = "" - "\r\n"; + "\r\n"; char SessionPortLine[] = "" - "\r\n"; + "\r\n"; char PortLineWithDriver[] = "" - "\r\n"; + "\r\n"; char PortLineWithBeaconAndDriver[] = "" "" - "\r\n"; + "\r\n"; char RigControlLine[] = "" "\r\n"; @@ -2707,6 +2707,53 @@ doHeader: return 0; } + else if (_memicmp(NodeURL, "/portstats.txt", 15) == 0) + { + char * Compressed; + char * ptr; + int port; + struct PORTCONTROL * PORT; + + ptr = &NodeURL[15]; + + port = atoi(ptr); + + PORT = GetPortTableEntryFromPortNum(port); + + ReplyLen = 0; + + if (PORT && PORT->TX) + { + // We send the last 24 hours worth of data. Buffer is cyclic so oldest byte is at StatsPointer + + int first = PORT->StatsPointer; + int firstlen = 1440 - first; + + memcpy(&_REPLYBUFFER[0], &PORT->TX[first], firstlen); + memcpy(&_REPLYBUFFER[firstlen], PORT->TX, first); + + memcpy(&_REPLYBUFFER[1440], &PORT->BUSY[first], firstlen); + memcpy(&_REPLYBUFFER[1440 + firstlen], PORT->BUSY, first); + + ReplyLen = 2880; + } + + if (allowDeflate) + Compressed = Compressit(_REPLYBUFFER, ReplyLen, &ReplyLen); + else + Compressed = _REPLYBUFFER; + + HeaderLen = sprintf(Header, "HTTP/1.1 200 OK\r\nAccess-Control-Allow-Origin: *\r\nContent-Length: %d\r\nContent-Type: Text\r\n%s\r\n", ReplyLen, Encoding); + sendandcheck(sock, Header, HeaderLen); + sendandcheck(sock, Compressed, ReplyLen); + + if (allowDeflate) + free (Compressed); + + return 0; + } + + else if (_memicmp(NodeURL, "/Icon", 5) == 0 && _memicmp(&NodeURL[10], ".png", 4) == 0) { // APRS internal Icon @@ -2880,7 +2927,7 @@ doHeader: " {" " // The browser doesn't support WebSocket\r\n" " const div = document.getElementById('div');\r\n" - " div.innerHTML = 'WebSocket not supported by your Browser - RigControl Page not availble'\r\n" + " div.innerHTML = 'WebSocket not supported by your Browser - RigControl Page not availible'\r\n" " }" "}" "function PTT(p)" @@ -3235,6 +3282,7 @@ doHeader: int count; char DLL[20]; + char StatsURL[64]; ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], "%s", PortsHddr); @@ -3243,6 +3291,13 @@ doHeader: Port = GetPortTableEntryFromSlot(count); ExtPort = (struct _EXTPORTDATA *)Port; + // see if has a stats page + + if (Port->AVACTIVE) + sprintf(StatsURL, " Stats Graph", Port->PORTNUMBER); + else + StatsURL[0] = 0; + if (Port->PORTTYPE == 0x10) { strcpy(DLL, ExtPort->PORT_DLL_NAME); @@ -3265,20 +3320,20 @@ doHeader: { if (Port->UICAPABLE) ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], PortLineWithBeaconAndDriver, Port->PORTNUMBER, DLL, - Port->PORTDESCRIPTION, Port->PORTNUMBER, Port->PORTNUMBER, Port->TNC->WebWinX, Port->TNC->WebWinY, 200, 200); + Port->PORTDESCRIPTION, Port->PORTNUMBER, Port->PORTNUMBER, Port->TNC->WebWinX, Port->TNC->WebWinY, 200, 200, StatsURL); else ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], PortLineWithDriver, Port->PORTNUMBER, DLL, - Port->PORTDESCRIPTION, Port->PORTNUMBER, Port->TNC->WebWinX, Port->TNC->WebWinY, 200, 200); + Port->PORTDESCRIPTION, Port->PORTNUMBER, Port->TNC->WebWinX, Port->TNC->WebWinY, 200, 200, StatsURL); continue; } if (Port->PORTTYPE == 16 && Port->PROTOCOL == 10 && Port->UICAPABLE == 0) // EXTERNAL, Pactor/WINMO ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], SessionPortLine, Port->PORTNUMBER, DLL, - Port->PORTDESCRIPTION, Port->PORTNUMBER); + Port->PORTDESCRIPTION, Port->PORTNUMBER, StatsURL); else ReplyLen += sprintf(&_REPLYBUFFER[ReplyLen], PortLineWithBeacon, Port->PORTNUMBER, Port->PORTNUMBER, - DLL, DLL, Port->PORTDESCRIPTION, Port->PORTNUMBER); + DLL, DLL, Port->PORTDESCRIPTION, Port->PORTNUMBER, StatsURL); } if (RigActive) -- cgit v1.2.3
PortDriverIDBeaconsDriver Window
PortDriverIDBeaconsDriver WindowStats Graph
%d %s%s
%d %s%s
%d %s%s Beacons
 Beacons %s
%d%s%s
%s
%d%s%s Driver Window
Driver Window%s
%d%s%s BeaconsDriver Window
Driver Window%s
%d%s%s Rig Control