Merge branch 'upstream/latest' of git.hibbian.org:Hibbian/linbpq into upstream/latest

This commit is contained in:
Hibby 2024-11-30 22:18:40 +00:00
commit 697fde3123
Signed by: hibby
SSH Key Fingerprint: SHA256:8HEV3623pJdfvWusnu47MzoqVh1gWhYSDeGKQJYkqNA
17 changed files with 81 additions and 12770 deletions

123
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,56 +1028,6 @@ 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)
{
@ -1086,26 +1035,11 @@ int AGWDataSocket_Read(struct AGWSocketConnectionInfo * sockptr, SOCKET sock)
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
int n = 50;
Sleep(500);
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

@ -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

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

15
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;
}
@ -2107,18 +2106,6 @@ 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