Commit 9d896637 authored by deuce's avatar deuce
Browse files

Initial support for new "UseFTNDomains" boolean INI option.

With this option enabled, zone/domain mappings from ctrl/ftn_domains.ini are
used to get the outbound directory name, and the orig/dest domains for type
2.2 packets.

This allows supporting 5D addressing in sbbsecho when zones do no overlap
between domains (the normal case).
parent b5676c98
......@@ -180,6 +180,24 @@ int main(int argc, char **argv)
}
SAFECOPY(cfg.cfgfile,str);
p=getenv("SBBSCTRL");
if(!p) {
p=getenv("SBBSNODE");
if(!p) {
printf("usage: echocfg [cfg_file]\n");
exit(1);
}
strcpy(str,p);
backslash(str);
strcat(str,"../ctrl/ftn_domains.ini");
}
else {
strcpy(str,p);
backslash(str);
strcat(str,"ftn_domains.ini");
}
SAFECOPY(cfg.ftndomainsfile,str);
if(!sbbsecho_read_ini(&cfg)) {
fprintf(stderr, "ERROR %d (%s) reading %s\n", errno, strerror(errno), cfg.cfgfile);
exit(1);
......
......@@ -218,6 +218,7 @@ void get_default_echocfg(sbbsecho_cfg_t* cfg)
cfg->delete_netmail = true;
cfg->echomail_notify = true;
cfg->kill_empty_netmail = true;
cfg->use_ftn_domains = false;
}
char* pktTypeStringList[] = {"2+", "2.2", "2", NULL};
......@@ -252,6 +253,7 @@ bool sbbsecho_read_ini(sbbsecho_cfg_t* cfg)
cfg->bsy_timeout = (ulong)iniGetDuration(ini, ROOT_SECTION, "BsyTimeout", cfg->bsy_timeout);
cfg->bso_lock_attempts = iniGetLongInt(ini, ROOT_SECTION, "BsoLockAttempts", cfg->bso_lock_attempts);
cfg->bso_lock_delay = (ulong)iniGetDuration(ini, ROOT_SECTION, "BsoLockDelay", cfg->bso_lock_delay);
cfg->use_ftn_domains = iniGetBool(ini, ROOT_SECTION, "UseFTNDomains", cfg->use_ftn_domains);
/* EchoMail options: */
cfg->maxbdlsize = (ulong)iniGetBytes(ini, ROOT_SECTION, "BundleSize", 1, cfg->maxbdlsize);
......@@ -362,6 +364,35 @@ bool sbbsecho_read_ini(sbbsecho_cfg_t* cfg)
cfg->maxbdlsize=DFLT_BDL_SIZE;
strListFree(&ini);
if(cfg->use_ftn_domains) {
if((fp=iniOpenFile(cfg->ftndomainsfile, /* create: */false))==NULL)
return false;
ini = iniReadFile(fp);
iniCloseFile(fp);
str_list_t domains = iniGetSectionList(ini, NULL);
const char* domain;
while((domain = strListPop(&domains)) != NULL) {
str_list_t zones = iniGetStringList(ini, domain, "Zones", ",", NULL);
const char* zone;
while((zone = strListPop(&zones)) != NULL) {
char path[MAX_PATH+1];
struct zone_mapping *mapping = (struct zone_mapping *)malloc(sizeof(struct zone_mapping));
if (mapping == NULL) {
strListFree(&zones);
strListFree(&domains);
return false;
}
mapping->zone = strtol(zone, NULL, 10);
mapping->domain = strdup(domain);
mapping->root = strdup(iniGetString(ini, domain, "OutboundRoot", cfg->outbound, path));
mapping->next = cfg->zone_map;
cfg->zone_map = mapping;
}
}
}
return true;
}
......@@ -413,6 +444,7 @@ bool sbbsecho_write_ini(sbbsecho_cfg_t* cfg)
iniSetBool(&ini, ROOT_SECTION, "IgnoreNetmailDestAddr" ,cfg->ignore_netmail_dest_addr ,NULL);
iniSetBool(&ini, ROOT_SECTION, "IgnoreNetmailRecvAttr" ,cfg->ignore_netmail_recv_attr ,NULL);
iniSetBool(&ini, ROOT_SECTION, "IgnoreNetmailLocalAttr" ,cfg->ignore_netmail_local_attr ,NULL);
iniSetBool(&ini, ROOT_SECTION, "UseFTNDomains" ,cfg->use_ftn_domains ,NULL);
style.key_prefix = "\t";
......
......@@ -100,6 +100,36 @@ str_list_t locked_bso_nodes;
int mv(const char *insrc, const char *indest, bool copy);
void export_echomail(const char *sub_code, const nodecfg_t*, bool rescan);
const char default_domain[] = "fidonet";
const char* zone_domain(uint16_t zone)
{
struct zone_mapping *i;
if (!cfg.use_ftn_domains)
return default_domain;
for (i=cfg.zone_map; i; i=i->next)
if (i->zone == zone)
return i->domain;
return default_domain;
}
const char* zone_root_outbound(uint16_t zone)
{
struct zone_mapping *i;
if (!cfg.use_ftn_domains)
return cfg.outbound;
for (i=cfg.zone_map; i; i=i->next)
if (i->zone == zone)
return i->root;
return cfg.outbound;
}
/* FTN-compliant "Program Identifier"/PID (also used as a "Tosser Identifier"/TID) */
const char* sbbsecho_pid(void)
{
......@@ -311,7 +341,7 @@ int get_outbound(fidoaddr_t dest, char* outbound, size_t maxlen, bool fileboxes)
{
nodecfg_t* nodecfg;
strncpy(outbound,cfg.outbound,maxlen);
strncpy(outbound,zone_root_outbound(dest.zone),maxlen);
if(fileboxes &&
(nodecfg = findnodecfg(&cfg, dest, /* exact */true)) != NULL
&& nodecfg->outbox[0])
......@@ -604,8 +634,8 @@ bool new_pkthdr(fpkthdr_t* hdr, fidoaddr_t orig, fidoaddr_t dest, const nodecfg_
if(pkt_type == PKT_TYPE_2_2) {
hdr->type2_2.subversion = 2; /* 2.2 */
strncpy((char*)hdr->type2_2.origdomn,"fidonet",sizeof(hdr->type2_2.origdomn));
strncpy((char*)hdr->type2_2.destdomn,"fidonet",sizeof(hdr->type2_2.destdomn));
strncpy((char*)hdr->type2_2.origdomn,zone_domain(orig.zone),sizeof(hdr->type2_2.origdomn));
strncpy((char*)hdr->type2_2.destdomn,zone_domain(dest.zone),sizeof(hdr->type2_2.destdomn));
return true;
}
......@@ -4985,6 +5015,9 @@ int main(int argc, char **argv)
if(!cfg.cfgfile[0])
SAFEPRINTF(cfg.cfgfile,"%ssbbsecho.ini",scfg.ctrl_dir);
if(!cfg.ftndomainsfile[0])
SAFEPRINTF(cfg.ftndomainsfile,"%sftn_domains.ini",scfg.ctrl_dir);
if(!sbbsecho_read_ini(&cfg)) {
fprintf(stderr, "ERROR %d (%s) reading %s\n", errno, strerror(errno), cfg.cfgfile);
bail(1);
......
......@@ -121,6 +121,13 @@ typedef struct {
char filename[MAX_PATH+1]; /* The full path to the attached file */
} attach_t;
struct zone_mapping {
uint16_t zone;
const char* root;
const char* domain;
struct zone_mapping *next;
};
typedef struct {
char inbound[MAX_PATH+1]; /* Inbound directory */
char secure_inbound[MAX_PATH+1]; /* Secure Inbound directory */
......@@ -128,6 +135,7 @@ typedef struct {
char areafile[MAX_PATH+1]; /* AREAS.BBS path/filename */
char logfile[MAX_PATH+1]; /* LOG path/filename */
char cfgfile[MAX_PATH+1]; /* Configuration path/filename */
char ftndomainsfile[MAX_PATH+1]; /* ftn_domains.ini path/filename */
char temp_dir[MAX_PATH+1]; /* Temporary file directory */
str_list_t sysop_alias_list; /* List of sysop aliases */
ulong maxpktsize /* Maximum size for packets */
......@@ -162,11 +170,13 @@ typedef struct {
bool ignore_netmail_dest_addr;
bool ignore_netmail_recv_attr;
bool ignore_netmail_local_attr;
bool use_ftn_domains;
ulong bsy_timeout;
ulong bso_lock_attempts;
ulong bso_lock_delay; /* in seconds */
ulong max_netmail_age;
ulong max_echomail_age;
struct zone_mapping *zone_map; //
} sbbsecho_cfg_t;
char* pktTypeStringList[4];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment