Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

sbbsecho.h 8.97 KB
Newer Older
1
/* Synchronet FidoNet EchoMail tosser/scanner/areafix program */
rswindell's avatar
rswindell committed
2 3 4 5 6

/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
7
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
rswindell's avatar
rswindell committed
8 9 10 11 12 13 14 15 16 17 18 19 20
 *																			*
 * This program is free software; you can redistribute it and/or			*
 * modify it under the terms of the GNU General Public License				*
 * as published by the Free Software Foundation; either version 2			*
 * of the License, or (at your option) any later version.					*
 * See the GNU General Public License for more details: gpl.txt or			*
 * http://www.fsf.org/copyleft/gpl.html										*
 *																			*
 * For Synchronet coding style and modification guidelines, see				*
 * http://www.synchro.net/source.html										*
 *																			*
 * Note: If this box doesn't appear square, then you need to fix your tabs.	*
 ****************************************************************************/
21 22 23

/* Portions written by Allen Christiansen 1994-1996 						*/

rswindell's avatar
rswindell committed
24 25 26 27 28
#include <str_list.h>
#include <stdbool.h>
#include <smbdefs.h>
#include "sbbsdefs.h"
#include "fidodefs.h"
29
#include "ini_file.h"
30

rswindell's avatar
rswindell committed
31
#define SBBSECHO_VERSION_MAJOR		3
32
#define SBBSECHO_VERSION_MINOR		13
33

rswindell's avatar
rswindell committed
34
#define SBBSECHO_PRODUCT_CODE		0x12FF	/* from http://ftsc.org/docs/ftscprod.013 */
35

rswindell's avatar
rswindell committed
36 37
#define SBBSECHO_AREAMGR_NAME		"AreaFix"

rswindell's avatar
rswindell committed
38 39 40 41 42 43 44 45 46 47
#define DEFAULT_INBOUND				"../fido/nonsecure"
#define DEFAULT_SECURE_INBOUND		"../fido/inbound"
#define DEFAULT_OUTBOUND			"../fido/outbound"
#define DEFAULT_AREA_FILE			"../data/areas.bbs"
#define DEFAULT_BAD_AREA_FILE		"../data/badareas.lst"
#define DEFAULT_ECHOSTATS_FILE		"../data/echostats.ini"
#define DEFAULT_LOG_FILE			"../data/sbbsecho.log"
#define DEFAULT_LOG_TIME_FMT		"%Y-%m-%d %H:%M:%S"
#define DEFAULT_TEMP_DIR			"../temp/sbbsecho"

rswindell's avatar
rswindell committed
48 49 50 51 52
enum mail_status {
	 MAIL_STATUS_NORMAL
	,MAIL_STATUS_HOLD
	,MAIL_STATUS_CRASH
};
53

rswindell's avatar
rswindell committed
54
enum pkt_type {
rswindell's avatar
rswindell committed
55 56 57
	 PKT_TYPE_2_PLUS				/* Type-2+  Packet Header (FSC-48)		*/
	,PKT_TYPE_2_EXT					/* Type-2e  Packet Header (FSC-39)		*/
	,PKT_TYPE_2_2					/* Type-2.2 Packet Header (FSC-45)		*/
rswindell's avatar
rswindell committed
58
	,PKT_TYPE_2	 					/* Type-2   Packet Header (FTS-1)		*/
rswindell's avatar
rswindell committed
59
	,PKT_TYPES_SUPPORTED
rswindell's avatar
rswindell committed
60
};
61

rswindell's avatar
rswindell committed
62 63
#define DFLT_PKT_SIZE   (250*1024L)
#define DFLT_BDL_SIZE   (250*1024L)
64

rswindell's avatar
rswindell committed
65
#define SBBSECHO_MAX_KEY_LEN	25	/* for AreaFix/EchoList keys (previously known as "flags") */
66
#define SBBSECHO_MAX_TICPWD_LEN 40	/* FRL-1039: no restrictions on the length ... of the password */
67 68

typedef struct {
69
    uint		sub;						/* Set to INVALID_SUB if pass-thru */
70
    char*		tag;						/* AreaTag, a.k.a. 'EchoTag' */
71 72 73 74
	uint		imported; 					/* Total messages imported this run */
	uint		exported; 					/* Total messages exported this run */
	uint		circular; 					/* Total circular paths detected */
	uint		dupes;						/* Total duplicate messages detected */
rswindell's avatar
rswindell committed
75 76 77
    uint		links;						/* Total number of links for this area */
    fidoaddr_t*	link;						/* Each link */
} area_t;
78 79

typedef struct {
rswindell's avatar
rswindell committed
80 81 82
	uint			addrs; 		/* Total number of links */
	fidoaddr_t *	addr;		/* Each link */
} addrlist_t;
83 84 85 86

typedef struct {
	char name[26]				/* Short name of archive type */
		,hexid[26]				/* Hexadecimal ID to search for */
rswindell's avatar
rswindell committed
87 88
		,pack[MAX_PATH+1]		/* Pack command line */
		,unpack[MAX_PATH+1];	/* Unpack command line */
89
	uint byteloc;				/* Offset to Hex ID */
rswindell's avatar
rswindell committed
90
} arcdef_t;
91 92

typedef struct {
rswindell's avatar
rswindell committed
93
	fidoaddr_t 	addr			/* Fido address of this node */
rswindell's avatar
rswindell committed
94 95
			   ,route			/* Address to route FLO stuff through */
			   ,local_addr;		/* Preferred local address (AKA) to use when sending packets to this node */
96
	char		domain[FIDO_DOMAIN_LEN+1];
rswindell's avatar
rswindell committed
97 98
	enum pkt_type pkt_type;		/* Packet type to use for outgoing PKTs */
	char		password[FIDO_SUBJ_LEN];	/* Areafix password for this node */
99
	char		sesspwd[41];				/* Binkd's MAXPWDLEN = 40 */
rswindell's avatar
rswindell committed
100
	char		pktpwd[FIDO_PASS_LEN+1];	/* Packet password for this node */
101
    char		ticpwd[SBBSECHO_MAX_TICPWD_LEN + 1]; /* TIC File password for this node */
rswindell's avatar
rswindell committed
102
	char		comment[64];	/* Comment for this node */
rswindell's avatar
rswindell committed
103
	char		name[FIDO_NAME_LEN];
rswindell's avatar
rswindell committed
104 105 106
	char		inbox[MAX_PATH+1];
	char		outbox[MAX_PATH+1];
	str_list_t	keys;
rswindell's avatar
rswindell committed
107
	bool		areafix;
rswindell's avatar
rswindell committed
108 109 110 111 112 113
	bool		send_notify;
	bool		passive;
	bool		direct;
	enum mail_status status;
#define SBBSECHO_ARCHIVE_NONE	NULL
	arcdef_t*	archive;
114
	str_list_t	grphub;			/* This link is hub of these groups (short names */
115
	/* BinkP settings */
116
	bool		binkp_plainAuthOnly;
117 118
	bool		binkp_allowPlainAuth;
	bool		binkp_allowPlainText;
119
	bool		binkp_tls;
120 121 122 123
	bool		binkp_poll;
	uint16_t	binkp_port;
	char		binkp_host[64];
	char	 	binkp_src[32];
rswindell's avatar
rswindell committed
124
} nodecfg_t;
125 126

typedef struct {
rswindell's avatar
rswindell committed
127 128 129 130 131
	char		listpath[MAX_PATH+1];	/* Path to this echolist */
	str_list_t	keys;
	fidoaddr_t 	hub;			/* Where to forward requests */
	bool		forward;
	char		password[FIDO_SUBJ_LEN];	/* Password to use for forwarding req's */
rswindell's avatar
rswindell committed
132
	char		areamgr[FIDO_NAME_LEN];		/* Destination name for Area Manager req's */
rswindell's avatar
rswindell committed
133
} echolist_t;
134 135

typedef struct {
rswindell's avatar
rswindell committed
136 137 138
	fidoaddr_t 	dest;
	char		filename[MAX_PATH+1];	/* The full path to the attached file */
} attach_t;
139

140 141 142 143 144 145 146
struct fido_domain {
	char		name[FIDO_DOMAIN_LEN + 1];
	int*		zone_list;
	unsigned	zone_count;
	char		root[MAX_PATH + 1];
	char		nodelist[MAX_PATH + 1];
	char		dns_suffix[64];
147 148
};

149 150 151
struct robot {
	char		name[FIDO_NAME_LEN];
	char		semfile[MAX_PATH + 1];
152
	uint16_t	attr;
153 154 155
	unsigned	recv_count;
};

156
typedef struct {
rswindell's avatar
rswindell committed
157 158 159
	char		inbound[MAX_PATH+1]; 	/* Inbound directory */
	char		secure_inbound[MAX_PATH+1];		/* Secure Inbound directory */
	char		outbound[MAX_PATH+1];	/* Outbound directory */
rswindell's avatar
rswindell committed
160 161 162
	char		areafile[MAX_PATH+1];	/* Area file (default: data/areas.bbs) */
	uint		areafile_backups;		/* Number of backups to keep of area file */
	char		badareafile[MAX_PATH+1];/* Bad area file (default: data/badareas.lst) */
163
	char		echostats[MAX_PATH+1];	/* Echo statistics (default: data/echostats.ini) */
rswindell's avatar
rswindell committed
164
	char		logfile[MAX_PATH+1];	/* LOG path/filename */
165
	char		logtime[64];			/* format of log timestamp */
rswindell's avatar
rswindell committed
166
	char		cfgfile[MAX_PATH+1];	/* Configuration path/filename */
rswindell's avatar
rswindell committed
167
	uint		cfgfile_backups;		/* Number of backups to keep of cfg file */
rswindell's avatar
rswindell committed
168
	char		temp_dir[MAX_PATH+1];	/* Temporary file directory */
rswindell's avatar
rswindell committed
169
	char		outgoing_sem[MAX_PATH+1];	/* Semaphore file to create/touch when there's outgoing data */
rswindell's avatar
rswindell committed
170 171 172 173 174 175 176 177 178 179
	str_list_t	sysop_alias_list;		/* List of sysop aliases */
	ulong		maxpktsize				/* Maximum size for packets */
			   ,maxbdlsize;				/* Maximum size for bundles */
	int			log_level;				/* Highest level (lowest severity) */
	int 		badecho;				/* Area to store bad echomail msgs */
	uint		arcdefs 				/* Number of archive definitions */
			   ,nodecfgs				/* Number of nodes with configs */
			   ,listcfgs				/* Number of echolists defined */
			   ,areas					/* Number of areas defined */
			   ;
rswindell's avatar
rswindell committed
180
	uint		umask;
rswindell's avatar
rswindell committed
181 182 183 184 185 186 187 188
	char		default_recipient[LEN_ALIAS+1];
	char		areamgr[LEN_ALIAS+1];	/* User to notify of areafix activity */
	arcdef_t*	arcdef; 				/* Each archive definition */
	nodecfg_t*	nodecfg;				/* Each node configuration */
	echolist_t*	listcfg;				/* Each echolist configuration */
	area_t*		area;					/* Each area configuration */
	bool		check_path;				/* Enable circular path detection */
	bool		zone_blind;				/* Pretend zones don't matter when parsing and constructing PATH and SEEN-BY lines (per Wilfred van Velzen, 2:280/464) */
189
	uint16_t	zone_blind_threshold;	/* Zones below this number (e.g. 4) will be treated as the same zone when zone_blind is enabled */
rswindell's avatar
rswindell committed
190
	bool		secure_echomail;
191
	bool		strict_packet_passwords;	/* Packet passwords must always match the configured linked-node */
rswindell's avatar
rswindell committed
192
	bool		strip_lf;
193
	bool		strip_soft_cr;
rswindell's avatar
rswindell committed
194 195 196 197 198 199 200 201 202 203
	bool		convert_tear;
	bool		fuzzy_zone;
	bool		flo_mailer;				/* Binkley-Style-Outbound / FLO mailer */
	bool		add_from_echolists_only;
	bool		trunc_bundles;
	bool		kill_empty_netmail;
	bool		delete_netmail;
	bool		delete_packets;
	bool		echomail_notify;
	bool		ignore_netmail_dest_addr;
204
	bool		ignore_netmail_sent_attr;
rswindell's avatar
rswindell committed
205
	bool		ignore_netmail_kill_attr;
rswindell's avatar
rswindell committed
206 207
	bool		ignore_netmail_recv_attr;
	bool		ignore_netmail_local_attr;
208
	bool		relay_filtered_msgs;
209
	bool		auto_add_subs;
210
	bool		auto_add_to_areafile;
211
	bool		auto_utf8;
212
	bool		use_outboxes;
rswindell's avatar
rswindell committed
213 214 215 216 217
	ulong		bsy_timeout;
	ulong		bso_lock_attempts;
	ulong		bso_lock_delay;			/* in seconds */
	ulong		max_netmail_age;
	ulong		max_echomail_age;
218
	int64_t		min_free_diskspace;
219 220
	struct fido_domain* domain_list;
	unsigned	domain_count;
221 222
	struct robot* robot_list;
	unsigned	robot_count;
223 224
	char		binkp_caps[64];
	char		binkp_sysop[64];
225
	bool		binkp_plainAuthOnly;
226
	bool		binkp_plainTextOnly;
227
	bool		used_include;
rswindell's avatar
rswindell committed
228 229
} sbbsecho_cfg_t;

230 231
extern ini_style_t sbbsecho_ini_style;

232 233
extern char* pktTypeStringList[PKT_TYPES_SUPPORTED+1];
extern char* mailStatusStringList[4];
234 235 236 237

/***********************/
/* Function prototypes */
/***********************/
rswindell's avatar
rswindell committed
238
bool sbbsecho_read_ini(sbbsecho_cfg_t*);
239
bool sbbsecho_read_ftn_domains(sbbsecho_cfg_t*, const char*);
rswindell's avatar
rswindell committed
240
bool sbbsecho_write_ini(sbbsecho_cfg_t*);
241
void bail(int code);
rswindell's avatar
rswindell committed
242 243
fidoaddr_t atofaddr(const char *str);
const char *faddrtoa(const fidoaddr_t*);
244
bool faddr_contains_wildcard(const fidoaddr_t*);
rswindell's avatar
rswindell committed
245 246 247
int  matchnode(sbbsecho_cfg_t*, fidoaddr_t, int exact);
nodecfg_t* findnodecfg(sbbsecho_cfg_t*, fidoaddr_t, int exact);