Update upstream source from tag 'upstream/6.0.24.51.3+repack+really50'

Update to upstream version '6.0.24.51.3+repack+really50'
with Debian dir 0b34b91ce1
This commit is contained in:
Hibby 2024-11-30 11:27:30 +00:00
commit d09a168608
21 changed files with 89 additions and 13206 deletions

125
AGWAPI.c
View File

@ -1017,7 +1017,6 @@ int AGWDataSocket_Read(struct AGWSocketConnectionInfo * sockptr, SOCKET sock)
{
int i;
int DataLength;
struct AGWHeader * AGW = &sockptr->AGWRXHeader;
ioctlsocket(sock,FIONREAD,&DataLength);
@ -1029,83 +1028,18 @@ int AGWDataSocket_Read(struct AGWSocketConnectionInfo * sockptr, SOCKET sock)
return 0;
}
if (DataLength < 36) // A header
{
// If we don't get a header within a few ms assume a rogue connection and close it
int n = 50;
while (n--)
{
Sleep(10);
ioctlsocket(sock,FIONREAD,&DataLength);
if (DataLength >= 36)
break;
}
if (n < 1)
{
Debugprintf("Corrupt AGW Packet Received");
AGWDataSocket_Disconnect(sockptr);
return 0;
}
}
// Have a header
i=recv(sock,(char *)&sockptr->AGWRXHeader, 36, 0);
if (i == SOCKET_ERROR)
{
i=WSAGetLastError();
AGWDataSocket_Disconnect(sockptr);
}
sockptr->MsgDataLength = sockptr->AGWRXHeader.DataLength;
// Validate packet to protect against accidental (or malicious!) connects from a non-agw application
if (AGW->Port > 64 || AGW->filler2 != 0 || AGW->filler3 != 0 || AGW->DataLength > 400)
{
Debugprintf("Corrupt AGW Packet Received");
AGWDataSocket_Disconnect(sockptr);
return 0;
}
if (sockptr->MsgDataLength == 0)
ProcessAGWCommand (sockptr);
else
sockptr->GotHeader = TRUE; // Wait for data
ioctlsocket(sock,FIONREAD,&DataLength); // See if more data
if (sockptr->GotHeader)
{
// Received a header, without sufficient data bytes
if (DataLength < sockptr->MsgDataLength)
{
// Fiddle - seem to be problems somtimes with un-Neagled hosts so wait a few ms
// if we don't get a full packet assume a rogue connection and close it
// Fiddle - seem to be problems somtimes with un-Neagled hosts
Sleep(500);
int n = 50;
while (n--)
{
Sleep(10);
ioctlsocket(sock,FIONREAD,&DataLength);
if (DataLength >= sockptr->MsgDataLength)
break;
}
if (n < 1)
{
Debugprintf("Corrupt AGW Packet Received");
AGWDataSocket_Disconnect(sockptr);
return 0;
}
ioctlsocket(sock,FIONREAD,&DataLength);
}
if (DataLength >= sockptr->MsgDataLength)
@ -1118,9 +1052,60 @@ int AGWDataSocket_Read(struct AGWSocketConnectionInfo * sockptr, SOCKET sock)
ProcessAGWCommand (sockptr);
free(sockptr->MsgData);
sockptr->GotHeader = FALSE;
}
// Not Enough Data - wait
}
else // Not got header
{
if (DataLength > 35)// A header
{
struct AGWHeader * AGW = &sockptr->AGWRXHeader;
i=recv(sock,(char *)&sockptr->AGWRXHeader, 36, 0);
if (i == SOCKET_ERROR)
{
i=WSAGetLastError();
AGWDataSocket_Disconnect(sockptr);
}
sockptr->MsgDataLength = sockptr->AGWRXHeader.DataLength;
// Validate packet to protect against accidental (or malicious!) connects from a non-agw application
if (AGW->Port > 64 || AGW->filler2 != 0 || AGW->filler3 != 0 || AGW->DataLength > 400)
{
Debugprintf("Corrupt AGW Packet Received");
AGWDataSocket_Disconnect(sockptr);
return 0;
}
if (sockptr->MsgDataLength > 500)
OutputDebugString("Corrupt AGW message");
if (sockptr->MsgDataLength == 0)
{
ProcessAGWCommand (sockptr);
}
else
{
sockptr->GotHeader = TRUE; // Wait for data
}
}
// not got 36 bytes
}
return 0;
}

View File

@ -88,7 +88,7 @@ double myDistance(double laa, double loa, BOOL KM);
struct STATIONRECORD * FindStation(char * Call, BOOL AddIfNotFound);
int DecodeAPRSPayload(char * Payload, struct STATIONRECORD * Station);
BOOL KillOldTNC(char * Path);
int FromLOC(char * Locator, double * pLat, double * pLon);
BOOL ToLOC(double Lat, double Lon , char * Locator);
BOOL InternalSendAPRSMessage(char * Text, char * Call);
void UndoTransparency(char * input);
@ -104,7 +104,6 @@ void ClearSavedMessages();
void GetSavedAPRSMessages();
static VOID GPSDConnect(void * unused);
int CanPortDigi(int Port);
int FromLOC(char * Locator, double * pLat, double * pLon);
extern int SemHeldByAPI;
extern int APRSMONDECODE();

View File

@ -5566,19 +5566,14 @@ BOOL CreateMessage(CIRCUIT * conn, char * From, char * ToCall, char * ATBBS, cha
{
if (_memicmp(ToCall, "rms:", 4) == 0)
{
// Could be ampr.org message
if (!isAMPRMsg(ToCall))
if (!FindRMS())
{
if (!FindRMS())
{
nodeprintf(conn, "*** Error - Forwarding via RMS is not configured on this BBS\r");
return FALSE;
}
nodeprintf(conn, "*** Error - Forwarding via RMS is not configured on this BBS\r");
return FALSE;
}
via=strlop(ToCall, ':');
_strupr(ToCall);
}
else if (_memicmp(ToCall, "rms/", 4) == 0)
{
@ -6882,7 +6877,7 @@ int CountMessagestoForward (struct UserInfo * user)
if ((Msg->status != 'H') && (Msg->status != 'D') && Msg->type && check_fwd_bit(Msg->fbbs, BBSNumber))
{
n++;
continue; // So we dont count twice if Flag set and NTS MPS
continue; // So we dont count twice in Flag set and NTS MPS
}
// if an NTS MPS, also check for any matches
@ -6923,66 +6918,6 @@ int CountMessagestoForward (struct UserInfo * user)
return n;
}
int CountBytestoForward (struct UserInfo * user)
{
// See if any messages are queued for this BBS. If so return total bytes queued
int m, n=0;
struct MsgInfo * Msg;
int BBSNumber = user->BBSNumber;
int FirstMessage = FirstMessageIndextoForward;
if ((user->flags & F_NTSMPS))
FirstMessage = 1;
for (m = FirstMessage; m <= NumberofMessages; m++)
{
Msg=MsgHddrPtr[m];
if ((Msg->status != 'H') && (Msg->status != 'D') && Msg->type && check_fwd_bit(Msg->fbbs, BBSNumber))
{
n += Msg->length;
continue; // So we dont count twice if Flag set and NTS MPS
}
// if an NTS MPS, also check for any matches
if (Msg->type == 'T' && (user->flags & F_NTSMPS))
{
struct BBSForwardingInfo * ForwardingInfo = user->ForwardingInfo;
int depth;
if (Msg->status == 'N' && ForwardingInfo)
{
depth = CheckBBSToForNTS(Msg, ForwardingInfo);
if (depth > -1 && Msg->Locked == 0)
{
n += Msg->length;
continue;
}
depth = CheckBBSAtList(Msg, ForwardingInfo, Msg->via);
if (depth && Msg->Locked == 0)
{
n += Msg->length;
continue;
}
depth = CheckBBSATListWildCarded(Msg, ForwardingInfo, Msg->via);
if (depth > -1 && Msg->Locked == 0)
{
n += Msg->length;
continue;
}
}
}
}
return n;
}
int ListMessagestoForward(CIRCUIT * conn, struct UserInfo * user)
{
// See if any messages are queued for this BBS
@ -15888,11 +15823,6 @@ void SendMessageReadEvent(char * call, struct MsgInfo * Msg)
}
}
void SendMessageForwardedToM0LTE(char * call, struct MsgInfo * Msg)
{
}
void SendNewMessageEvent(char * call, struct MsgInfo * Msg)
{
if (reportMailEvents)

View File

@ -1143,8 +1143,6 @@
// 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 tp packetnodes.spots.radio database (51)
#include "bpqmail.h"
#include "winstdint.h"
@ -1163,8 +1161,6 @@ FARPROCZ pGetLOC;
FARPROCX pRefreshWebMailIndex;
FARPROCX pRunEventProgram;
FARPROCX pGetPortFrequency;
FARPROCX pSendWebRequest;
FARPROCX pGetLatLon;
BOOL WINE = FALSE;
@ -1389,7 +1385,6 @@ char * CheckToAddress(CIRCUIT * conn, char * Addr);
BOOL CheckifPacket(char * Via);
int GetHTMLForms();
VOID GetPGConfig();
void SendBBSDataToPktMap();
struct _EXCEPTION_POINTERS exinfox;
@ -1941,8 +1936,6 @@ 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)
@ -2190,13 +2183,6 @@ 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
@ -3071,6 +3057,7 @@ static PSOCKADDR_IN psin;
SOCKET sock;
BOOL Initialise()
{
int i, len;
@ -3396,9 +3383,6 @@ BOOL Initialise()
CreatePipeThread();
GetPGConfig();
APIClock = 0;
return TRUE;
}

18
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 2023
// Version 6.0.24.1 August 2024
// Apply NODES command wildcard to alias as well a call (2)
// Add STOPPORT/STARTPORT to VARA Driver (2)
@ -1234,7 +1234,6 @@ 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)
#define CKernel
@ -1375,9 +1374,6 @@ extern struct _LINKTABLE * LINKS;
extern int LINK_TABLE_LEN;
extern int MAXLINKS;
extern double LatFromLOC;
extern double LonFromLOC;
extern int BPQHOSTAPI();
extern int INITIALISEPORTS();
@ -3072,7 +3068,7 @@ SkipInit:
if (AttachedProcesses < 2)
{
if (AUTOSAVE)
if (AUTOSAVE == 1)
SaveNodes();
if (AUTOSAVEMH)
SaveMH();
@ -6625,19 +6621,11 @@ 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

@ -398,7 +398,6 @@ extern int REALTIMETICKS;
extern time_t CurrentSecs;
extern time_t lastSlowSecs;
extern time_t lastSaveSecs;
// SNMP Variables

File diff suppressed because it is too large Load Diff

View File

@ -4912,7 +4912,7 @@ SOCKET OpenHTTPSock(char * Host)
{
err = WSAGetLastError();
Debugprintf("Resolve Failed for %s %d %x", Host, err, err);
Debugprintf("Resolve Failed for %s %d %x", "api.winlink.org", err, err);
return 0 ; // Resolve failed
}
@ -4945,7 +4945,7 @@ SOCKET OpenHTTPSock(char * Host)
}
static char HeaderTemplate[] = "POST %s HTTP/1.1\r\n"
"Accept: app N B lication/json\r\n"
"Accept: application/json\r\n"
// "Accept-Encoding: gzip,deflate,gzip, deflate\r\n"
"Content-Type: application/json\r\n"
"Host: %s:%d\r\n"
@ -4955,24 +4955,14 @@ static char HeaderTemplate[] = "POST %s HTTP/1.1\r\n"
"\r\n";
DllExport VOID WINAPI SendWebRequest(char * Host, char * Request, char * Params, char * Return)
VOID SendWebRequest(SOCKET sock, char * Host, char * Request, char * Params, int Len, char * Return)
{
SOCKET sock;
int InputLen = 0;
int inptr = 0;
char Buffer[4096];
char Header[256];
char * ptr, * ptr1;
int Sent;
int Len = strlen(Params);
if (M0LTEMap == 0)
return;
sock = OpenHTTPSock(Host);
if (sock == 0)
return;
#ifdef LINBPQ
sprintf(Header, HeaderTemplate, Request, Host, 80, Len, "linbpq/", VersionString, Params);
@ -4986,7 +4976,6 @@ DllExport VOID WINAPI SendWebRequest(char * Host, char * Request, char * Params,
{
int Err = WSAGetLastError();
Debugprintf("Error %d from Web Update send()", Err);
closesocket(sock);
return;
}
@ -4998,10 +4987,12 @@ DllExport VOID WINAPI SendWebRequest(char * Host, char * Request, char * Params,
{
int Err = WSAGetLastError();
Debugprintf("Error %d from Web Update recv()", Err);
closesocket(sock);
return;
}
// As we are using a persistant connection, can't look for close. Check
// for complete message
inptr += InputLen;
Buffer[inptr] = 0;
@ -5044,7 +5035,6 @@ DllExport VOID WINAPI SendWebRequest(char * Host, char * Request, char * Params,
Debugprintf("Map Update failed - %s", Buffer);
}
closesocket(sock);
return;
}
}
@ -5056,7 +5046,6 @@ DllExport VOID WINAPI SendWebRequest(char * Host, char * Request, char * Params,
{
// Just accept anything until I've sorted things with Lee
Debugprintf("%s", ptr1);
closesocket(sock);
Debugprintf("Web Database update ok");
return;
}
@ -5595,11 +5584,19 @@ void SendDataToPktMap(char *Msg)
}
],
*/
// "contact": "string",
// "neighbours": [{"node": "G7TAJ","port": "30"}]
SendWebRequest("packetnodes.spots.radio", Request, Params, Return);
sock = OpenHTTPSock("packetnodes.spots.radio");
if (sock == 0)
return;
SendWebRequest(sock, "packetnodes.spots.radio", Request, Params, strlen(Params), Return);
closesocket(sock);
}
// ="{\"neighbours\": [{\"node\": \"G7TAJ\",\"port\": \"30\"}]}";

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -76,7 +76,6 @@ void SaveAIS();
void initAIS();
void DRATSPoll();
VOID GetPGConfig();
void SendBBSDataToPktMap();
extern uint64_t timeLoadedMS;
@ -1282,10 +1281,6 @@ int main(int argc, char * argv[])
printf("Mail Started\n");
Logprintf(LOG_BBS, NULL, '!', "Mail Starting");
APIClock = 0;
SendBBSDataToPktMap();
}
}
@ -1584,13 +1579,6 @@ int main(int argc, char * argv[])
DoHouseKeeping(FALSE);
}
if (APIClock < NOW)
{
SendBBSDataToPktMap();
APIClock = NOW + 7200; // Every 2 hours
}
tm = gmtime(&NOW);
if (tm->tm_wday == 0) // Sunday

View File

@ -205,7 +205,6 @@ int MailForInterval = 0;
char zeros[NBMASK]; // For forward bitmask tests
time_t MaintClock; // Time to run housekeeping
time_t APIClock; // Time to sent to MOLTE's Database
struct MsgInfo * MsgnotoMsg[100000]; // Message Number to Message Slot List.

View File

@ -2897,8 +2897,6 @@ SocketConn * SMTPConnect(char * Host, int Port, BOOL AMPR, struct MsgInfo * Msg,
sinx.sin_addr.s_addr = INADDR_ANY;
sinx.sin_port = 0;
sockptr->Timeout = 0;
if (bind(sockptr->socket, (LPSOCKADDR) &sinx, addrlen) != 0 )
{
//
@ -3592,6 +3590,7 @@ VOID ProcessPOP3ClientMessage(SocketConn * sockptr, char * Buffer, int Len)
if (sockptr->POP3MsgCount > sockptr->POP3MsgNum++)
{
sockprintf(sockptr, "RETR %d", sockptr->POP3MsgNum);
sockptr->State = WaitingForRETRResponse;
}
else

View File

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

1
adif.c
View File

@ -609,6 +609,7 @@ VOID ADIFWriteFreqList()
fprintf(Handle, "[Channels]\r\n");
for (i = 0; i < freqCount; i++)
fprintf(Handle, "Frequency %d=%lld\r\n" , i + 1, Freqs[i]);

View File

@ -1191,7 +1191,6 @@ BOOL FBBDoForward(CIRCUIT * conn);
BOOL FindMessagestoForward(CIRCUIT * conn);
BOOL SeeifMessagestoForward(int BBSNumber, CIRCUIT * Conn);
int CountMessagestoForward(struct UserInfo * user);
int CountBytestoForward(struct UserInfo * user);
VOID * GetMultiLineDialogParam(HWND hDialog, int DLGItem);
@ -1634,8 +1633,6 @@ extern char ** SendWPAddrs; // Replacers WP To and VIA
extern BOOL DontCheckFromCall;
extern time_t APIClock;;
// YAPP stuff
#define SOH 1

17
cMain.c
View File

@ -50,7 +50,6 @@ VOID SendSmartID(struct PORTCONTROL * PORT);
int CanPortDigi(int Port);
int KissEncode(UCHAR * inbuff, UCHAR * outbuff, int len);
void MQTTTimer();
void SaveMH();
#include "configstructs.h"
@ -1508,7 +1507,7 @@ BOOL Start()
upnpInit();
lastSaveSecs = CurrentSecs = lastSlowSecs = time(NULL);
CurrentSecs = lastSlowSecs = time(NULL);
return 0;
}
@ -2106,19 +2105,7 @@ VOID TIMERINTERRUPT()
}
*/
}
// Check Autosave Nodes and MH timer
if (CurrentSecs - lastSaveSecs >= 3600) // 1 per hour
{
lastSaveSecs = CurrentSecs;
if (AUTOSAVE == 1)
SaveNodes();
if (AUTOSAVEMH == 1)
SaveMH();
}
if (L4TIMERFLAG >= 10) // 1 PER SEC
{
L4TIMERFLAG -= 10;

View File

@ -174,16 +174,11 @@ extern BOOL Loopflag;
extern char NodeMapServer[80];
extern char ChatMapServer[80];
double LatFromLOC;
double LonFromLOC;
VOID * zalloc(int len);
int WritetoConsoleLocal(char * buff);
char * stristr (char *ch1, char *ch2);
int FromLOC(char * Locator, double * pLat, double * pLon);
VOID Consoleprintf(const char * format, ...)
{
@ -347,7 +342,7 @@ static int routine[] =
14, 14, 14, 14,
14, 14 ,14, 14,
15, 0, 2, 9, 9,
2, 2, 1, 2, 2, 2,
2, 2, 2, 2, 2, 2,
2, 2, 0, 1, 20, 20} ; // Routine to process param
int PARAMLIM = sizeof(routine)/sizeof(int);
@ -929,21 +924,11 @@ NextAPRS:
strcat(LOCATOR, ":");
strcat(LOCATOR, ptr2);
ToLOC(atof(ptr1), atof(ptr2), LOC);
LatFromLOC = atof(ptr1);
LonFromLOC = atof(ptr2);
}
else
{
if (strlen(ptr1) == 6)
{
strcpy(LOC, ptr1);
FromLOC(LOC, &LatFromLOC, &LonFromLOC);
// Randomise in square
LatFromLOC += ((rand() / 24.0) / RAND_MAX);
LonFromLOC += ((rand() / 12.0) / RAND_MAX);
}
}
}
return 0;

View File

@ -49,9 +49,6 @@ char MAPCOMMENT[250] = "";
char LOC[7] = ""; // Must be in shared mem// Maidenhead Locator for Reporting
char ReportDest[7];
double LatFromLOC = 0;
double LonFromLOC = 0;
UCHAR BPQDirectory[260] = ".";
UCHAR ConfigDirectory[260] = ".";
UCHAR LogDirectory[260] = "";
@ -65,7 +62,6 @@ UCHAR L3KEEP[7] = {'K'+'K','E'+'E','E'+'E','P'+'P','L'+'L','I'+'I', 0xe0}; // K
time_t CurrentSecs;
time_t lastSlowSecs;
time_t lastSaveSecs;
char WL2KCall[10] = "";
char WL2KLoc[7] = "";

View File

@ -768,9 +768,6 @@ BOOL CheckifPacket(char * Via)
if (FindContinent(ptr1))
return TRUE; // Packet
if (FindCountry(ptr1))
return TRUE; // Packet
if ((_stricmp(ptr1, "MARS") == 0) || (_stricmp(ptr1, "USA") == 0)) // MARS used both
return TRUE; // Packet

402
mailapi.c
View File

@ -705,404 +705,4 @@ 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);
}
*/