Skip to content
Snippets Groups Projects
Commit 53d31031 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

When replying to PING netmails, use the destination addr as the origaddr

As tested and reported in FIDONEWS by Michiel van der Vlist, 2:280/5555, SBBSecho would use the "best match" FidoNet AKA for the originating address when replying to PING netmail messages and not necessarily the original destination address of the ping request. For systems that have multiple addresses (AKAs) that could be considered appropriate originating addresses for the requesting node address (e.g. multiple addresses in the same zone or zone/net), this could cause a confusion for the PING requester.

The create_netmail() function now accepts an optional source (orig) address parameter and the PING response logic passes the netmail's destination address for the reply message's originating (source) address.

I noticed that AreaMgr responses also follow the same logic as PING responses (just use the best-fit AKA, not necessarily the same address as the original request's destination address) - but I did not choose to address that "issue" at this time.
parent 95281f96
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #1321 passed
......@@ -1097,7 +1097,8 @@ bool new_pkthdr(fpkthdr_t* hdr, fidoaddr_t orig, fidoaddr_t dest, const nodecfg_
If file is non-zero, will set file attachment bit (for bundles).
Returns 0 on success.
******************************************************************************/
int create_netmail(const char *to, const smbmsg_t* msg, const char *subject, const char *body, fidoaddr_t dest)
int create_netmail(const char *to, const smbmsg_t* msg, const char *subject, const char *body, fidoaddr_t dest
, fidoaddr_t* src)
{
FILE *fp;
char tmp[256];
......@@ -1155,7 +1156,9 @@ int create_netmail(const char *to, const smbmsg_t* msg, const char *subject, con
return(-1);
}
if(msg != NULL && msg->from_net.type == NET_FIDO && msg->from_net.addr != NULL)
if(src != NULL)
faddr = *src;
else if(msg != NULL && msg->from_net.type == NET_FIDO && msg->from_net.addr != NULL)
faddr = *(fidoaddr_t*)msg->from_net.addr;
else
faddr = getsysfaddr(dest);
......@@ -1320,7 +1323,7 @@ int file_to_netmail(FILE* infile, const char* title, fidoaddr_t dest, const char
}
if(ftell(infile)<l)
strcat(buf,"\r\nContinued in next message...\r\n");
if(create_netmail(to, /* msg: */NULL, title, buf, dest) == 0)
if(create_netmail(to, /* msg: */NULL, title, buf, dest, /* src: */NULL) == 0)
netmails_created++;
}
free(buf);
......@@ -1549,7 +1552,7 @@ void netmail_arealist(enum arealist_type type, fidoaddr_t addr, const char* to)
}
strListSortAlpha(area_list);
if(strListIsEmpty(area_list))
create_netmail(to, /* msg: */NULL, title, "None.", addr);
create_netmail(to, /* msg: */NULL, title, "None.", /* dest: */addr, /* src: */NULL);
else {
FILE* fp;
if((fp=tmpfile())==NULL) {
......@@ -1873,7 +1876,8 @@ void alter_areas(str_list_t add_area, str_list_t del_area, fidoaddr_t addr, cons
}
if (to != NULL) {
if (!ftell(nmfile))
create_netmail(to,/* msg: */NULL, "Area Management Request", "No changes made.", addr);
create_netmail(to,/* msg: */NULL, "Area Management Request", "No changes made."
,/* dest: */addr, /* src: */NULL);
else
file_to_netmail(nmfile, "Area Management Request", addr, to);
}
......@@ -2060,7 +2064,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to)
alter_config(nodecfg,"archive",p);
SAFEPRINTF(str, "Compression type changed to: %s", p);
lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str);
create_netmail(to, /* msg: */NULL, "Compression Type Change", str, addr);
create_netmail(to, /* msg: */NULL, "Compression Type Change", str, /* dest: */addr, /* src: */NULL);
return true;
}
......@@ -2074,7 +2078,8 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to)
sprintf(str,"Your AreaMgr password was already set to '%s'."
,nodecfg->password);
lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str);
create_netmail(to, /* msg: */NULL, "AreaMgr Password Change Request", str, addr);
create_netmail(to, /* msg: */NULL, "AreaMgr Password Change Request", str
,/* dest: */addr, /* src: */NULL);
return true;
}
if(alter_config(nodecfg,"AreaFixPwd", password)) {
......@@ -2085,7 +2090,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to)
SAFECOPY(str,"Error changing AreaMgr password");
}
lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str);
create_netmail(to, /* msg: */NULL, "AreaMgr Password Change Request", str, addr);
create_netmail(to, /* msg: */NULL, "AreaMgr Password Change Request", str, /* dest: */addr, /* src: */NULL);
return true;
}
......@@ -2099,7 +2104,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to)
sprintf(str,"Your packet password was already set to '%s'."
,nodecfg->pktpwd);
lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str);
create_netmail(to, /* msg: */NULL, "Packet Password Change Request", str, addr);
create_netmail(to, /* msg: */NULL, "Packet Password Change Request", str, /* dest: */addr, /* src: */NULL);
return true;
}
if(alter_config(nodecfg,"PacketPwd", pktpwd)) {
......@@ -2110,7 +2115,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to)
SAFECOPY(str,"Error changing packet password");
}
lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str);
create_netmail(to, /* msg: */NULL, "Packet Password Change Request", str, addr);
create_netmail(to, /* msg: */NULL, "Packet Password Change Request", str, /* dest: */addr, /* src: */NULL);
return true;
}
......@@ -2124,7 +2129,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to)
sprintf(str,"Your TIC File password was already set to '%s'."
,nodecfg->ticpwd);
lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str);
create_netmail(to, /* msg: */NULL, "TIC File Password Change Request", str, addr);
create_netmail(to, /* msg: */NULL, "TIC File Password Change Request", str, /* dest: */addr, /* src: */NULL);
return true;
}
if(alter_config(nodecfg,"TicFilePwd", ticpwd)) {
......@@ -2135,7 +2140,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to)
SAFECOPY(str,"Error changing TIC File password");
}
lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str);
create_netmail(to, /* msg: */NULL, "TIC File Password Change Request", str, addr);
create_netmail(to, /* msg: */NULL, "TIC File Password Change Request", str, /* dest: */addr, /* src: */NULL);
return true;
}
......@@ -2150,7 +2155,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to)
SAFECOPY(str,"Error changing Notify Setting");
}
lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str);
create_netmail(to, /* msg: */NULL, "Notification Messages Change Request", str, addr);
create_netmail(to, /* msg: */NULL, "Notification Messages Change Request", str, /* dest: */addr, /* src: */NULL);
return true;
}
......@@ -2159,7 +2164,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to)
export_echomail(NULL, nodecfg, true);
create_netmail(to,/* msg: */NULL, "Rescan Areas"
,"All connected areas carried by your hub have been rescanned."
,addr);
,/* dest: */addr, /* src: */NULL);
return true;
}
......@@ -2178,7 +2183,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to)
}
lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str);
create_netmail(to,/* msg: */NULL, "Rescan Area"
,str, addr);
,str, /* dest: */addr, /* src: */NULL);
return true;
}
......@@ -2206,26 +2211,26 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to)
if(stricmp(instr, "ACTIVE") == 0 || stricmp(instr, "RESUME") == 0) {
if(!nodecfg->passive) {
create_netmail(to,/* msg: */NULL,"Reconnect Disconnected (paused) Areas"
,"Your areas are already connected.",addr);
,"Your areas are already connected.", /* dest: */addr, /* src: */NULL);
return true;
}
nodecfg->passive = false;
alter_config(nodecfg,"passive","false");
create_netmail(to,/* msg: */NULL,"Reconnect Disconnected (paused) Areas"
,"Temporarily disconnected areas have been reconnected.",addr);
,"Temporarily disconnected areas have been reconnected.", /* dest: */addr, /* src: */NULL);
return true;
}
if(stricmp(instr, "PASSIVE") == 0 || stricmp(instr, "PAUSE") == 0) {
if(nodecfg->passive) {
create_netmail(to,/* msg: */NULL,"Temporarily Disconnect (pause) Areas"
,"Your areas are already temporarily disconnected.",addr);
,"Your areas are already temporarily disconnected.", /* dest: */addr, /* src: */NULL);
return true;
}
nodecfg->passive = true;
alter_config(nodecfg,"passive","true");
create_netmail(to,/* msg: */NULL,"Temporarily Disconnect (pause) Areas"
,"Your areas have been temporarily disconnected.",addr);
,"Your areas have been temporarily disconnected.", /* dest: */addr, /* src: */NULL);
return true;
}
......@@ -2291,13 +2296,15 @@ char* process_areafix(fidoaddr_t addr, char* inbuf, const char* password, const
if(nodecfg==NULL || !nodecfg->areafix) {
lprintf(LOG_NOTICE,"AreaFix (for %s) Request received, but AreaFix not enabled for this node!", smb_faddrtoa(&addr,NULL));
create_netmail(name,/* msg: */NULL,"Area Management Request"
,"Your node is not configured for AreaFix, please contact your hub sysop.\r\n",addr);
,"Your node is not configured for AreaFix, please contact your hub sysop.\r\n"
,/* dest: */addr, /* src: */NULL);
strcat(body,"This node is not configured for AreaFix operations.\r\n");
return(body);
}
if(stricmp(nodecfg->password,password)) {
create_netmail(name,/* msg: */NULL,"Area Management Request","Invalid Password.",addr);
create_netmail(name,/* msg: */NULL,"Area Management Request","Invalid Password."
,/* dest: */addr, /* src: */NULL);
sprintf(body+strlen(body), "An invalid password (%s) was supplied in the message subject.\r\n"
"The correct Area Manager password for this node is: %s\r\n"
,password
......@@ -2344,7 +2351,7 @@ char* process_areafix(fidoaddr_t addr, char* inbuf, const char* password, const
if(!cmds && strListIsEmpty(add_area) && strListIsEmpty(del_area)) {
create_netmail(name,/* msg: */NULL,"Area Management Request"
,"No commands to process.\r\nSend %HELP for help.\r\n"
,addr);
,/* dest: */addr, /* src: */NULL);
strcat(body, "No valid AreaFix commands were detected.\r\n");
strListFree(&add_area);
strListFree(&del_area);
......@@ -2538,7 +2545,8 @@ int attachment(const char *bundlename, fidoaddr_t dest, enum attachment_mode mod
,/* msg: */NULL
,/* subj: */attach.filename
,(cfg.trunc_bundles) ? "\1FLAGS TFS\r" : "\1FLAGS KFS\r"
,attach.dest))
,attach.dest
,/* src: */NULL))
error=1;
}
fclose(stream);
......@@ -2643,7 +2651,7 @@ bool pack_bundle(const char *tmp_pkt, fidoaddr_t orig, fidoaddr_t dest)
else
i=create_netmail(/* To: */NULL,/* msg: */NULL,packet
,(cfg.trunc_bundles) ? "\1FLAGS TFS\r" : "\1FLAGS KFS\r"
,dest);
,dest, /* src: */NULL);
return i==0;
}
......@@ -4478,6 +4486,12 @@ int import_netmail(const char* path, fmsghdr_t hdr, FILE* fp, const char* inboun
addr.net=hdr.orignet;
addr.node=hdr.orignode;
addr.point=hdr.origpoint;
fidoaddr_t dest = {
.zone = hdr.destzone,
.net = hdr.destnet,
.node = hdr.destnode,
.point = hdr.destpoint
};
lprintf(LOG_INFO, "%s", info);
if(stricmp(hdr.from, hdr.to) == 0)
lprintf(LOG_NOTICE, "Refusing to auto-reply to NetMail from %s", hdr.from);
......@@ -4515,7 +4529,7 @@ int import_netmail(const char* path, fmsghdr_t hdr, FILE* fp, const char* inboun
"\r======[ End received msg text ]======\r", fmsgbuf);
}
SAFEPRINTF(subj, "Pong: %s", hdr.subj);
create_netmail(/* to: */hdr.from, /* msg: */NULL, subj, body, addr);
create_netmail(/* to: */hdr.from, /* msg: */NULL, subj, body, /* dest: */addr, /* src: */&dest);
if(body != fmsgbuf) {
FREE_AND_NULL(body);
}
......@@ -5320,7 +5334,7 @@ int export_netmail(void)
continue;
}
create_netmail(msg.to, &msg, msg_subj, txt, *(fidoaddr_t*)msg.to_net.addr);
create_netmail(msg.to, &msg, msg_subj, txt, /* dest: */*(fidoaddr_t*)msg.to_net.addr, /* src: */NULL);
FREE_AND_NULL(txt);
msg.hdr.netattr |= MSG_SENT;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment