Compare commits

...

2 Commits

8 changed files with 445 additions and 16 deletions

View File

@ -1143,6 +1143,8 @@
// Semaphore calls to SaveConfig
// Include SERVIC as valid from call (for Winlink Service messages) (49)
// Attempt to detect line draw characters in Webmail (50)
// Fix sending ampr.org mail when RMS is not enabled (51)
// Send forwarding info to packetnodes.spots.radio database (51)
#include "bpqmail.h"
#include "winstdint.h"
@ -1161,6 +1163,8 @@ FARPROCZ pGetLOC;
FARPROCX pRefreshWebMailIndex;
FARPROCX pRunEventProgram;
FARPROCX pGetPortFrequency;
FARPROCX pSendWebRequest;
FARPROCX pGetLatLon;
BOOL WINE = FALSE;
@ -1385,6 +1389,7 @@ char * CheckToAddress(CIRCUIT * conn, char * Addr);
BOOL CheckifPacket(char * Via);
int GetHTMLForms();
VOID GetPGConfig();
void SendBBSDataToPktMap();
struct _EXCEPTION_POINTERS exinfox;
@ -1936,6 +1941,8 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
pRefreshWebMailIndex = GetProcAddress(ExtDriver,"_RefreshWebMailIndex@0");
pRunEventProgram = GetProcAddress(ExtDriver,"_RunEventProgram@8");
pGetPortFrequency = GetProcAddress(ExtDriver,"_GetPortFrequency@8");
pSendWebRequest = GetProcAddress(ExtDriver,"_SendWebRequest@16");
pGetLatLon = GetProcAddress(ExtDriver,"_GetLatLon@8");
if (pGetLOC)
@ -2183,6 +2190,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Debugprintf("|Enter HouseKeeping");
DoHouseKeeping(FALSE);
}
if (APIClock < NOW)
{
SendBBSDataToPktMap();
APIClock = NOW + 7200; // Every 2 hours
}
tm = gmtime(&NOW);
if (tm->tm_wday == 0) // Sunday
@ -3057,7 +3071,6 @@ static PSOCKADDR_IN psin;
SOCKET sock;
BOOL Initialise()
{
int i, len;
@ -3383,6 +3396,9 @@ BOOL Initialise()
CreatePipeThread();
GetPGConfig();
APIClock = 0;
return TRUE;
}

19
Bpq32.c
View File

@ -1086,7 +1086,7 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
// Add ? and * wildcards to NODES command (74)
// Add Port RADIO config parameter (74)
// Version 6.0.24.1 August 2024
// Version 6.0.24.1 August 2023
// Apply NODES command wildcard to alias as well a call (2)
// Add STOPPORT/STARTPORT to VARA Driver (2)
@ -1234,6 +1234,8 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
// Add optional ATTACH time limit for VARA (48)
// API format fixes (48)
// AGWAPI Add protection against accidental connects from a non-agw application (50)
// Save MH and NODES every hour (51)
// Fix handling long unix device names (now max 250 bytes) (52)
#define CKernel
@ -1374,6 +1376,9 @@ extern struct _LINKTABLE * LINKS;
extern int LINK_TABLE_LEN;
extern int MAXLINKS;
extern double LatFromLOC;
extern double LonFromLOC;
extern int BPQHOSTAPI();
extern int INITIALISEPORTS();
@ -3068,7 +3073,7 @@ SkipInit:
if (AttachedProcesses < 2)
{
if (AUTOSAVE == 1)
if (AUTOSAVE)
SaveNodes();
if (AUTOSAVEMH)
SaveMH();
@ -6621,11 +6626,19 @@ int GetListeningPortsPID(int Port)
return 0; // Not found
}
DllExport char * APIENTRY GetLOC()
DllExport char * APIENTRY GetLOC()
{
return LOC;
}
DllExport void APIENTRY GetLatLon(double * lat, double * lon)
{
*lat = LatFromLOC;
*lon = LonFromLOC;
return;
}
// UZ7HO Dll PTT interface
// 1 ext_PTT_info

View File

@ -471,7 +471,7 @@ VOID * HALExtInit(EXTPORTDATA * PortEntry)
int port;
char * ptr;
int len;
char Msg[80];
char Msg[512];
#ifndef LINBPQ
HWND x;
#endif
@ -548,7 +548,7 @@ VOID * HALExtInit(EXTPORTDATA * PortEntry)
TNC->WebWinX = 510;
TNC->WebWinY = 280;
TNC->WEB_COMMSSTATE = zalloc(100);
TNC->WEB_COMMSSTATE = zalloc(512);
TNC->WEB_TNCSTATE = zalloc(100);
strcpy(TNC->WEB_TNCSTATE, "Free");
TNC->WEB_MODE = zalloc(100);

View File

@ -735,7 +735,7 @@ VOID SerialReleasePort(struct TNCINFO * TNC)
VOID * SerialExtInit(EXTPORTDATA * PortEntry)
{
int port;
char Msg[255];
char Msg[512];
char * ptr;
struct TNCINFO * TNC;
char * TempScript;

View File

@ -10,14 +10,14 @@
#endif
#define KVers 6,0,24,50
#define KVerstring "6.0.24.50\0"
#define KVers 6,0,24,52
#define KVerstring "6.0.24.52\0"
#ifdef CKernel
#define Vers KVers
#define Verstring KVerstring
#define Datestring "October 2024"
#define Datestring "November 2024"
#define VerComments "G8BPQ Packet Switch (C Version)" KVerstring
#define VerCopyright "Copyright © 2001-2024 John Wiseman G8BPQ\0"
#define VerDesc "BPQ32 Switch\0"

View File

@ -182,7 +182,7 @@ char * stristr (char *ch1, char *ch2);
VOID Consoleprintf(const char * format, ...)
{
char Mess[255];
char Mess[512];
va_list(arglist);
va_start(arglist, format);
@ -2397,11 +2397,11 @@ int doSerialPortName(int i, char * value, char * rec)
{
rec += 8;
if (strlen(rec) > 79)
if (strlen(rec) > 250)
{
Consoleprintf("Serial Port Name too long - Truncated");
Consoleprintf("%s\r\n",rec);
rec[79] = 0;
rec[250] = 0;
}
strlop(rec, ' ');

4
kiss.c
View File

@ -209,7 +209,7 @@ VOID EnableFLDIGIReports(struct PORTCONTROL * PORT)
VOID ASYDISP(struct PORTCONTROL * PortVector)
{
char Msg[80];
char Msg[512];
if (PortVector->PORTIPADDR.s_addr || PortVector->KISSTCP)
@ -235,7 +235,7 @@ VOID ASYDISP(struct PORTCONTROL * PortVector)
int ASYINIT(int comport, int speed, struct PORTCONTROL * PortVector, char Channel )
{
char Msg[80];
char Msg[256];
NPASYINFO npKISSINFO;
int BPQPort = PortVector->PORTNUMBER;

402
mailapi.c
View File

@ -705,4 +705,404 @@ packetmail_queue_length{partner="GB7NOT"} 0 1729090716916
packetmail_queue_length{partner="GB7NWL"} 0 1729090716916
packetmail_queue_length{partner="GM8BPQ"} 0 1729090716916
*/
*/
// Stuff send to packetnodes.spots.radio/api/bbsdata/{bbsCall}
//https://nodes.ukpacketradio.network/swagger/index.html
/*
BbsData{
callsign* [...]
time* [...]
hroute* [...]
peers [...]
software* [...]
version* [...]
mailQueues [...]
messages [...]
latitude [...]
longitude [...]
locator [...]
location [...]
unroutable [...]
}
[
{
"callsign": "GE8PZT",
"time": "2024-11-25T10:07:41+00:00",
"hroute": ".#24.GBR.EU",
"peers": [
"GB7BBS",
"VE2PKT",
"GB7NXT",
"VA2OM"
],
"software": "XrLin",
"version": "504a",
"mailQueues": [],
"messages": [
{
"to": "TECH@WW",
"mid": "20539_GB7CIP",
"rcvd": "2024-11-24T09:27:59+00:00",
"routing": [
"R:241124/0927Z @:GE8PZT.#24.GBR.EU [Lamanva] #:2315 XrLin504a",
{
"to": "TNC@WW",
"mid": "37_PA2SNK",
"rcvd": "2024-11-18T21:56:55+00:00",
"routing": [
"R:241118/2156Z @:GE8PZT.#24.GBR.EU [] #:2215 XrLin504a",
"R:241118/2156Z 12456@VE2PKT.#TRV.QC.CAN.NOAM BPQ6.0.24",
"R:241118/2130Z 51539@VE3KPG.#ECON.ON.CAN.NOAM BPQK6.0.23",
"R:241118/2130Z 26087@VE3CGR.#SCON.ON.CAN.NOAM LinBPQ6.0.24",
"R:241118/2130Z 37521@PA8F.#ZH1.NLD.EURO LinBPQ6.0.24",
"R:241118/2129Z 48377@PI8LAP.#ZLD.NLD.EURO LinBPQ6.0.24",
"R:241118/2129Z @:PD0LPM.FRL.EURO.NLD #:33044 [Joure] $:37_PA2SNK"
]
}
],
"latitude": 50.145832,
"longitude": -5.125,
"locator": "IO70KD",
"location": "Lamanva",
"unroutable": [
{
"type": "P",
"at": "WW"
},
{
"type": "P",
"at": "G8PZT-2"
},
{
"type": "P",
"at": "g8pzt._24.gbr.eu"
},
{
"type": "P",
"at": "G8PZT.#24.GBR.EU"
},
{
"type": "P",
"at": "GE8PZT.#24.GBR.EU"
},
{
"type": "P",
"at": "G8PZT.#24.GBR.EURO"
}
]
},
*/
// https://packetnodes.spots.radio/swagger/index.html
// "unroutable": [{"type": "P","at": "WW"}, {"type": "P", "at": "G8PZT.#24.GBR.EURO"}]
char * ViaList[100000]; // Pointers to the Message Header field
char TypeList[100000];
int unroutableCount = 0;
void CheckifRoutable(struct MsgInfo * Msg)
{
char NextBBS[64];
int n;
if (Msg->status == 'K')
return;
if (Msg->via[0] == 0) // No routing
return;
strcpy(NextBBS, Msg->via);
strlop(NextBBS, '.');
if (strcmp(NextBBS, BBSName) == 0) // via this BBS
return;
if ((memcmp(Msg->fbbs, zeros, NBMASK) != 0) || (memcmp(Msg->forw, zeros, NBMASK) != 0)) // Has Forwarding Info
return;
// See if we already have it
for (n = 0; n < unroutableCount; n++)
{
if ((TypeList[n] == Msg->type) && strcmp(ViaList[n], Msg->via) == 0)
return;
}
// Add to list
TypeList[unroutableCount] = Msg->type;
ViaList[unroutableCount] = Msg->via;
unroutableCount++;
}
extern char LOC[7];
DllExport VOID WINAPI SendWebRequest(char * Host, char * Request, char * Params, char * Return);
#ifdef LINBPQ
extern double LatFromLOC;
extern double LonFromLOC;
#else
typedef int (WINAPI FAR *FARPROCX)();
extern FARPROCX pSendWebRequest;
extern FARPROCX pGetLatLon;
double LatFromLOC = 0;
double LonFromLOC = 0;
#endif
void SendBBSDataToPktMap()
{
char Return[4096];
char Request[64];
char * Params;
char * ptr;
int paramLen;
struct MsgInfo * Msg;
struct UserInfo * ourBBSRec = LookupCall(BBSName);
struct UserInfo * USER;
char Time[64];
struct tm * tm;
time_t Date = time(NULL);
char Peers[2048] = "[]";
char MsgQueues[16000] = "[]";
char * Messages = malloc(1000000);
char * Unroutables;
int m;
char * MsgBytes;
char * Rlineptr;
char * Rlineend;
char * RLines;
char * ptr1, * ptr2;
int n;
#ifndef LINBPQ
if (pSendWebRequest == 0)
return; // Old Version of bpq32.dll
pGetLatLon(&LatFromLOC, &LonFromLOC);
#endif
if (ourBBSRec == 0)
return; // Wot!!
// Get peers and Mail Queues
ptr = &Peers[1];
ptr1 = &MsgQueues[1];
for (USER = BBSChain; USER; USER = USER->BBSNext)
{
if (strcmp(USER->Call, BBSName) != 0)
{
int Bytes;
int Count = CountMessagestoForward(USER);
ptr += sprintf(ptr, "\"%s\",", USER->Call);
if (Count)
{
Bytes = CountBytestoForward(USER);
ptr1 += sprintf(ptr1, "{\"peerCall\": \"%s\", \"numQueued\": %d, \"bytesQueued\": %d},",
USER->Call, Count, Bytes);
}
}
}
if ((*ptr) != ']') // Have some entries
{
ptr--; // over trailing comms
*(ptr++) = ']';
*(ptr) = 0;
}
if ((*ptr1) != ']') // Have some entries
{
ptr1--; // over trailing comms
*(ptr1++) = ']';
*(ptr1) = 0;
}
// Get Messages
strcpy(Messages, "[]");
ptr = &Messages[1];
for (m = LatestMsg; m >= 1; m--)
{
if (ptr > &Messages[999000])
break; // protect buffer
Msg = GetMsgFromNumber(m);
if (Msg == 0 || Msg->type == 0 || Msg->status == 0)
continue; // Protect against corrupt messages
// Paula suggests including H and K but limit it to the last 30 days or the last 100 messages, whichever is the smaller.
// if (Msg->status == 'K' || Msg->status == 'H')
// continue;
if ((Date - Msg->datereceived) > 30 * 86400) // Too old
continue;
CheckifRoutable(Msg);
tm = gmtime(&Msg->datereceived);
sprintf(Time, "%04d-%02d-%02dT%02d:%02d:%02d+00:00",
tm->tm_year + 1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
// Get Routing
MsgBytes = ReadMessageFile(Msg->number);
RLines = malloc(Msg->length * 2); // Very unlikely to need so much but better safe..
strcpy(RLines, "[]");
ptr2 = &RLines[1];
// Need to skip B2 header if B2 Message
Rlineptr = MsgBytes;
// If it is a B2 Message, Must Skip B2 Header
if (Msg->B2Flags & B2Msg)
{
Rlineptr = strstr(Rlineptr, "\r\n\r\n");
if (Rlineptr)
Rlineptr += 4;
else
Rlineptr = MsgBytes;
}
// We have to process R: lines one at a time as we need to send each one as a separate string
while (memcmp(Rlineptr, "R:", 2) == 0)
{
// Have R Lines
Rlineend = strstr(Rlineptr, "\r\n");
Rlineend[0] = 0;
ptr2 += sprintf(ptr2, "\"%s\",", Rlineptr);
Rlineptr = Rlineend + 2; // over crlf
}
if ((*ptr2) == ']') // no entries
continue;
ptr2--; // over trailing comms
*(ptr2++) = ']';
*(ptr2) = 0;
ptr += sprintf(ptr, "{\"to\": \"%s\", \"mid\": \"%s\", \"rcvd\": \"%s\", \"routing\": %s},",
Msg->to, Msg->bid, Time, RLines);
free(MsgBytes);
free(RLines);
}
if ((*ptr) != ']') // Have some entries?
{
ptr--; // over trailing comms
*(ptr++) = ']';
*(ptr) = 0;
}
// Get unroutables
Unroutables = malloc((unroutableCount + 1) * 100);
strcpy(Unroutables, "[]");
ptr = &Unroutables[1];
for (n = 0; n < unroutableCount; n++)
{
ptr += sprintf(ptr, "{\"type\": \"%c\",\"at\": \"%s\"},", TypeList[n], ViaList[n]);
}
if ((*ptr) != ']') // Have some entries?
{
ptr--; // over trailing comms
*(ptr++) = ']';
*(ptr) = 0;
}
/*
char * ViaList[100000]; // Pointers to the Message Header field
char TypeList[100000];
int unroutableCount = 0;
"unroutable": [{"type": "P","at": "WW"}, {"type": "P", "at": "G8PZT.#24.GBR.EURO"}]
*/
tm = gmtime(&Date);
sprintf(Time, "%04d-%02d-%02dT%02d:%02d:%02d+00:00",
tm->tm_year + 1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
paramLen = strlen(Peers) + strlen(MsgQueues) + strlen(Messages) + strlen(Unroutables);
Params = malloc(paramLen + 1000);
if (Params == 0)
{
free(Messages);
free(Unroutables);
return;
}
ptr = Params;
sprintf(Request, "/api/bbsdata/%s", BBSName);
ptr += sprintf(ptr, "{\"callsign\": \"%s\",\r\n", BBSName);
ptr += sprintf(ptr, "\"time\": \"%s\",\r\n", Time);
ptr += sprintf(ptr, "\"hroute\": \"%s\",\r\n", HRoute);
ptr += sprintf(ptr, "\"peers\": %s,\r\n", Peers);
#ifdef LINBPQ
ptr += sprintf(ptr, "\"software\": \"%s\",\r\n", "linbpq");
#else
ptr += sprintf(ptr, "\"software\": \"%s\",\r\n", "BPQMail");
#endif
ptr += sprintf(ptr, "\"version\": \"%s\",\r\n", VersionString);
ptr += sprintf(ptr, "\"mailQueues\": %s,\r\n", MsgQueues);
ptr += sprintf(ptr, "\"messages\": %s,\r\n", Messages);
ptr += sprintf(ptr, "\"latitude\": %1.6f,\r\n", LatFromLOC);
ptr += sprintf(ptr, "\"longitude\": %.6f,\r\n", LonFromLOC);
ptr += sprintf(ptr, "\"locator\": \"%s\",\r\n", LOC);
ptr += sprintf(ptr, "\"location\": \"%s\",\r\n", ourBBSRec->Address);
ptr += sprintf(ptr, "\"unroutable\": %s\r\n}\r\n", Unroutables);
SendWebRequest("packetnodes.spots.radio", Request, Params, Return);
free(Messages);
free(Unroutables);
free(Params);
}