diff --git a/CHANGES b/CHANGES index b1ddb711..6aacaab2 100644 --- a/CHANGES +++ b/CHANGES @@ -3,7 +3,8 @@ Changes for 2.2.0: rasengan (2): Added /stats P to show listening ports (PR #134) -Ryan Smith (9): +Ryan Smith (10): +======= Override clone limits with SVSCLONE (PR #148) Updates to user hostmasking (PR #175) Do not attempt to mask the Staff_Address for opers. (PR #175) @@ -13,6 +14,7 @@ Ryan Smith (9): Send out WATCH notifications if the hostname changes due to a mode H change. (PR #175) Minor typo fixes. Show UHM variables in /INFO. + Persist the uhm_type and uhm_uhmode values to disk to handle restarts properly. Emilio Escobar (4): Fixed oper block corruption when two opers share the same IP (PR #181) diff --git a/include/h.h b/include/h.h index 87d84900..be98ff93 100644 --- a/include/h.h +++ b/include/h.h @@ -238,6 +238,9 @@ extern void terminate(void), write_pidfile(void); extern int match(char *, char *); extern char *collapse(char *); +extern int load_settings(); +extern int save_settings(); + extern int writecalls, writeb[]; #ifdef WRITEV_IOV extern int deliver_it(aClient *, struct iovec *, int); diff --git a/src/ircd.c b/src/ircd.c index e1a7c9c1..ee07e6af 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -104,6 +104,9 @@ extern void read_help(char *); /* defined in s_serv.c */ extern void init_globals(); extern int klinestore_init(int); /* defined in klines.c */ +extern int uhm_type; +extern int uhm_umodeh; + char **myargv; char configfile[PATH_MAX] = {0}; /* Server configuration file */ @@ -872,6 +875,8 @@ main(int argc, char *argv[]) } } + load_settings(); + /* init the modules, load default modules! */ init_modules(); @@ -1334,3 +1339,77 @@ memcount_ircd(MCircd *mc) return 0; } +/* load_settings - Load the persistent settings + * Returns: 1 = Success + * 0 = Failure + */ +int load_settings() +{ + FILE *fp; + char tmp[PATH_MAX]; + char line[1024]; + char *para[MAXPARA + 1]; + int parc; + + ircsprintf(tmp, "%s/settings.txt", dpath); + if(!(fp = fopen(tmp, "r"))) + return 0; /* Can't open file! */ + + while(fgets(line, sizeof(line), fp)) + { + char *tmp = strchr(line, '\n'); + if(!tmp) + break; + *tmp = '\0'; + tmp = line; + parc = 0; + while(*tmp) + { + while(*tmp==' ') + *tmp++ = '\0'; + + if(*tmp==':') + { + para[parc++] = tmp + 1; + break; + } + para[parc++] = tmp; + while(*tmp && *tmp!=' ') + tmp++; + } + para[parc + 1] = NULL; + if(!mycmp(para[0], "uhm_type") && parc > 1) + { + uhm_type = atoi(para[1]); + } + if(!mycmp(para[0], "uhm_umodeh") && parc > 1) + { + uhm_umodeh = atoi(para[1]); + } + } + fclose(fp); + + return 1; +} + +/* save_settings - Save the persistent settings file + * Returns: 1 = Success + * 0 = Failure + */ +int save_settings() +{ + char tmp[PATH_MAX]; + FILE *fp; + + ircsprintf(tmp, "%s/settings.txt", dpath); + fp = fopen(tmp, "w"); + if(!fp) + return 0; + + fprintf(fp, "uhm_type %d\n", uhm_type); + fprintf(fp, "uhm_umodeh %d\n", uhm_umodeh); + + fclose(fp); + + return 1; +} \ No newline at end of file diff --git a/src/m_services.c b/src/m_services.c index a16c3152..a9528088 100644 --- a/src/m_services.c +++ b/src/m_services.c @@ -821,6 +821,8 @@ int m_svsuhm(aClient *cptr, aClient *sptr, int parc, char *parv[]) } else sendto_serv_butone(cptr, ":%s SVSUHM %s", sptr->name, parv[1]); + save_settings(); + return 0; }