From 0664ba8b27c2cb81c346e69699ef7396031178cb Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Fri, 24 Apr 2015 05:47:42 +0000
Subject: [PATCH] New option: EchoCfg->Toggles->Fwd Circular Msgs to Links (or
 by adding NOCIRCULARFWD to your sbbsecho.cfg): When "Circular Path Detection"
 is enabled (the default), the old behavior was to still forward the message
 to any links (if there are any), but not import the circular/looped message
 (likely a dupe). Now, if you set this new option to no (or add
 "NOCIRCULARFWD" to your sbbsecho.cfg), the message will be completely ignored
 and not fowarded to any links (if there are any). If you have no downlinks or
 you have circular path detection disabled, this new option does nothing. The
 default is the old behavior (forward circular messages). Also updated the
 Toggle Options help text in echocfg (many options weren't documented.

---
 src/sbbs3/echocfg.c  | 55 ++++++++++++++++++++++++++++++++++++--------
 src/sbbs3/rechocfg.c |  7 +++++-
 src/sbbs3/sbbsecho.c |  8 ++++---
 src/sbbs3/sbbsecho.h |  3 ++-
 4 files changed, 58 insertions(+), 15 deletions(-)

diff --git a/src/sbbs3/echocfg.c b/src/sbbs3/echocfg.c
index 9aa2ff8c43..e84ea79a4c 100644
--- a/src/sbbs3/echocfg.c
+++ b/src/sbbs3/echocfg.c
@@ -8,7 +8,7 @@
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2014 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright 2015 Rob Swindell - http://www.synchro.net/copyright.html		*
  *																			*
  * This program is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU General Public License				*
@@ -772,18 +772,47 @@ int main(int argc, char **argv)
 	uifc.helpbuf=
 	"`Secure Operation` tells SBBSecho to check the AREAS.BBS file to insure\r\n"
 	"    that the packet origin exists there as well as check the password of\r\n"
-	"    that node (if configured).\r\n\r\n"
+	"    that node (if configured).\r\n"
+	"\r\n"
 	"`Convert Existing Tear Lines` tells SBBSecho to convert any tear lines\r\n"
-	"    (`---`) existing in the message text to to `===`.\r\n\r\n"
-	"`Fuzzy Zone Operation` when set to yes if SBBSecho receives an inbound\r\n"
+	"    (`---`) existing in the message text to to `===`.\r\n"
+	"\r\n"
+	"`Fuzzy Zone Operation` when set to `Yes`, if SBBSecho receives an inbound\r\n"
 	"    netmail with no international zone information, it will compare the\r\n"
 	"    net/node of the destination to the net/node information in your AKAs\r\n"
-	"    and assume the zone of a matching AKA.\r\n\r\n"
+	"    and assume the zone of a matching AKA.\r\n"
+	"\r\n"
 	"`Store PATH/SEEN-BY/Unkown Kludge Lines in Message Base` allows you to\r\n"
 	"    determine whether or not SBBSecho will store this information from\r\n"
-	"    incoming messages in the Synchronet message base.\r\n\r\n"
-	"`Allow Nodes to Add Areas in the AREAS.BBS List` when set to `YES` allows\r\n"
-	"    uplinks to add areas listed in the AREAS.BBS file\r\n";
+	"    incoming messages in the Synchronet message base (for debugging).\r\n"
+	"\r\n"
+	"`Allow Nodes to Add Areas in the AREAS.BBS List` when set to `Yes` allows\r\n"
+	"    uplinks to add areas listed in the AREAS.BBS file\r\n"
+	"\r\n"
+	"`Strip Line Feeds From Outgoing Messages` when set to `Yes` instructs\r\n"
+	"    SBBSecho to remove any line-feed (ASCII 10) characters from the body\r\n"
+	"    text of messages being exported to FidoNet EchoMail.\r\n"
+	"\r\n"
+	"`Kill/Ignore Empty NetMail Messages` will instruct SBBSecho to simply\r\n"
+	"    discard (not import or export) NetMail messages without any body.\r\n"
+	"\r\n"
+	"`Circular Path Detection` when `Enabled` will cause SBBSecho, during\r\n"
+	"    EchoMail import, to check the PATH kludge lines for any of the\r\n"
+	"    system's AKAs and if found (indicating a message loop), not import\r\n"
+	"    the message.\r\n"
+	"\r\n"
+	"`Forward Circular Messages To Links` is only valid when `Circular Path\r\n"
+	"    Detection` is enabled. When set to `No`, SBBSecho will discard\r\n"
+	"    the circular/looped message and not forward to any linked nodes.\r\n"
+	"\r\n"
+	"`Bundle Attachments` may be either `Killed` (deleted) or `Truncated` (set\r\n"
+	"    to 0-bytes in length).\r\n"
+	"\r\n"
+	"`Zone Blind SEEN-BY and PATH Lines` when `Enabled` will cause SBBSecho\r\n"
+	"    to assume that node numbers are not duplicated across zones and\r\n"
+	"    that a net/node combination in either of these Kludge lines should\r\n"
+	"    be used to identify a specific node regardless of which zone that\r\n"
+	"    node is located (thus breaking the rules of FidoNet 3D addressing).\r\n";
 				j=0;
 				while(1) {
 					i=0;
@@ -807,6 +836,8 @@ int main(int argc, char **argv)
 						"Messages",misc&KILL_EMPTY_MAIL ? "Yes":"No");
 					sprintf(opt[i++],"%-50.50s%s","Circular Path Detection"
 						,cfg.check_path ? "Enabled" : "Disabled");
+					sprintf(opt[i++],"%-50.50s%s","Forward Circular Messages to Links"
+						,cfg.check_path ? (cfg.fwd_circular ? "Yes" : "No") : "N/A");
 					sprintf(opt[i++],"%-50.50s%s","Bundle Attachments"
 						,misc&TRUNC_BUNDLES ? "Truncate" : "Kill");
 					sprintf(opt[i++],"%-50.50s%s","Zone Blind SEEN-BY and PATH Lines"
@@ -847,12 +878,14 @@ int main(int argc, char **argv)
 							cfg.check_path=!cfg.check_path;
 							break;
 						case 10:
-							misc^=TRUNC_BUNDLES;
+							cfg.fwd_circular=!cfg.fwd_circular;
 							break;
 						case 11:
+							misc^=TRUNC_BUNDLES;
+							break;
+						case 12:
 							cfg.zone_blind=!cfg.zone_blind;
 							break;
-
 					} 
 				}
 				break;
@@ -1161,6 +1194,8 @@ int main(int argc, char **argv)
 				}
 				if(!cfg.check_path)
 					fprintf(stream,"NOPATHCHECK\n");
+				if(!cfg.fwd_circular)
+					fprintf(stream,"NOCIRCULARFWD\n");
 				if(cfg.zone_blind) {
 					fprintf(stream,"ZONE_BLIND");
 					if(cfg.zone_blind_threshold != 0xffff)
diff --git a/src/sbbs3/rechocfg.c b/src/sbbs3/rechocfg.c
index b506da54f9..4fd9839268 100644
--- a/src/sbbs3/rechocfg.c
+++ b/src/sbbs3/rechocfg.c
@@ -8,7 +8,7 @@
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2014 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright 2015 Rob Swindell - http://www.synchro.net/copyright.html		*
  *																			*
  * This program is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU General Public License				*
@@ -202,6 +202,7 @@ void read_echo_cfg()
 	cfg.log=LOG_DEFAULTS;
 	cfg.log_level=LOG_INFO;
 	cfg.check_path=TRUE;
+	cfg.fwd_circular=TRUE;
 	cfg.zone_blind=FALSE;
 	cfg.zone_blind_threshold=0xffff;
 	SAFECOPY(cfg.sysop_alias,"SYSOP");
@@ -271,6 +272,10 @@ void read_echo_cfg()
 			cfg.check_path=FALSE;
 			continue;
 		}
+		if(!stricmp(tmp,"NOCIRCULARFWD")) {
+			cfg.fwd_circular=FALSE;
+			continue;
+		}
 
 		if(!stricmp(tmp,"ZONE_BLIND")) {
 			cfg.zone_blind=TRUE;
diff --git a/src/sbbs3/sbbsecho.c b/src/sbbs3/sbbsecho.c
index 6241fec34b..07355ec666 100644
--- a/src/sbbs3/sbbsecho.c
+++ b/src/sbbs3/sbbsecho.c
@@ -4756,7 +4756,7 @@ int main(int argc, char **argv)
 					continue; 
 				} 						/* On to the next message */
 
-
+				/* TODO: Should circular path detection occur before processing pass-through areas? */
 				if(cfg.check_path) {
 					for(j=0;j<scfg.total_faddrs;j++)
 						if(check_psb(&msg_path,scfg.faddr[j]))
@@ -4768,8 +4768,10 @@ int main(int argc, char **argv)
 						if(cfg.log&LOG_CIRCULAR)
 							logprintf("%s: Circular path detected for %s"
 								,areatagstr,smb_faddrtoa(&scfg.faddr[j],NULL));
-						strip_psb(fmsgbuf);
-						pkt_to_pkt(fmsgbuf,curarea,pkt_faddr,hdr,msg_seen,msg_path,0);
+						if(cfg.fwd_circular) {
+							strip_psb(fmsgbuf);
+							pkt_to_pkt(fmsgbuf,curarea,pkt_faddr,hdr,msg_seen,msg_path,0);
+						}
 						printf("\n");
 						continue; 
 					}
diff --git a/src/sbbs3/sbbsecho.h b/src/sbbs3/sbbsecho.h
index e76a93caf5..4d131780e9 100644
--- a/src/sbbs3/sbbsecho.h
+++ b/src/sbbs3/sbbsecho.h
@@ -8,7 +8,7 @@
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2014 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright 2015 Rob Swindell - http://www.synchro.net/copyright.html		*
  *																			*
  * This program is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU General Public License				*
@@ -236,6 +236,7 @@ typedef struct {
 	echolist_t *listcfg;			/* Each echolist configuration */
 	areasbbs_t *area;				/* Each area configuration */
 	BOOL		check_path;			/* Enable circular path detection */
+	BOOL		fwd_circular;		/* Allow the forwrarding of circular messages to links (defaults to true, only applicable if check_path is also true) */
 	BOOL		zone_blind;			/* Pretend zones don't matter when parsing and constructing PATH and SEEN-BY lines (per Wilfred van Velzen, 2:280/464) */
 	uint16_t	zone_blind_threshold;	/* Zones below this number (e.g. 4) will be treated as the same zone when zone_blind is enabled */
 	} config_t;
-- 
GitLab