diff options
-rw-r--r-- | pttbbs/UPDATING | 12 | ||||
-rw-r--r-- | pttbbs/common/bbs/cache.c | 42 | ||||
-rw-r--r-- | pttbbs/include/config.h | 4 | ||||
-rw-r--r-- | pttbbs/include/pttstruct.h | 11 | ||||
-rw-r--r-- | pttbbs/mbbsd/mbbsd.c | 32 | ||||
-rw-r--r-- | pttbbs/pttbbs.mk | 2 |
6 files changed, 20 insertions, 83 deletions
diff --git a/pttbbs/UPDATING b/pttbbs/UPDATING index a0747cc4..251752cc 100644 --- a/pttbbs/UPDATING +++ b/pttbbs/UPDATING @@ -23,6 +23,18 @@ https://opensvn.csie.org/traccgi/pttbbs/changeset/2273 make r4871_uflag ----------------------------------------------------------------------------- +r5663: [fromd/where] +中文故鄉 (pttbbs.conf:WHERE) 改由 FROMD 來提供,移除原 cache + mbbsd 的機制. +好處是: (1) 減少 reload cache 所花時間 (2) 避免 duplicated code. + +若想使用故鄉功能,請: + (1) 編輯 pttbs.conf, 加上 #define FROMD + (2) cd ~/pttbbs; make clean; make # mbbsd 跟 common 都要重編 + (3) 在開機的 script 加上 ~bbs/daemon/fromd/fromd + 若不想重開機,請順手執行一次上面的命令。 + (4) bbsctl restart ,連線進去測試看看。 +故鄉的定義檔一樣是 etc/domain_name_query.cidr ,格式也一樣。 + r5662: [banip] banip 的 record size 由 unsigned long 改為 in_addr_t. 在 64-bit 環境上使用的人請全部 (common, util, mbbsd) make clean 再 make all. diff --git a/pttbbs/common/bbs/cache.c b/pttbbs/common/bbs/cache.c index 3ce422a9..bfdef1a8 100644 --- a/pttbbs/common/bbs/cache.c +++ b/pttbbs/common/bbs/cache.c @@ -861,48 +861,6 @@ reload_fcache(void) FILE *fp; SHM->Fbusystate = 1; - bzero(SHM->home_ip, sizeof(SHM->home_ip)); - if ((fp = fopen("etc/domain_name_query.cidr", "r"))) { - char buf[256], *ip, *mask; - char *strtok_pos; - - SHM->home_num = 0; - while (fgets(buf, sizeof(buf), fp)) { - if (!buf[0] || buf[0] == '#' || buf[0] == ' ' || buf[0] == '\n') - continue; - - if (buf[0] == '@') { - SHM->home_ip[0] = 0; - SHM->home_mask[0] = 0xFFFFFFFF; - SHM->home_num++; - continue; - } - - ip = strtok_r(buf, " \t", &strtok_pos); - if ((mask = strchr(ip, '/')) != NULL) { - int shift = 32 - atoi(mask + 1); - SHM->home_ip[SHM->home_num] = ipstr2int(ip); - SHM->home_mask[SHM->home_num] = (0xFFFFFFFF >> shift ) << shift; - } - else { - SHM->home_ip[SHM->home_num] = ipstr2int(ip); - SHM->home_mask[SHM->home_num] = 0xFFFFFFFF; - } - ip = strtok_r(NULL, " \t", &strtok_pos); - if (ip == NULL) { - strcpy(SHM->home_desc[SHM->home_num], "雲深不知處"); - } - else { - strlcpy(SHM->home_desc[SHM->home_num], ip, - sizeof(SHM->home_desc[SHM->home_num])); - chomp(SHM->home_desc[SHM->home_num]); - } - (SHM->home_num)++; - if (SHM->home_num == MAX_FROM) - break; - } - fclose(fp); - } SHM->max_user = 0; /* 等所有資料更新後再設定 uptime */ diff --git a/pttbbs/include/config.h b/pttbbs/include/config.h index af447ee9..01ff5b8a 100644 --- a/pttbbs/include/config.h +++ b/pttbbs/include/config.h @@ -468,10 +468,6 @@ #define DOTIMEOUT /* 處理閒置時間 */ #endif -#ifndef NO_WHERE -#define WHERE /* 是否有故鄉功能 */ -#endif - #ifndef NO_INTERNET_EMAIL #define INTERNET_EMAIL /* 支援 InterNet Email 功能(含 Forward) */ #endif diff --git a/pttbbs/include/pttstruct.h b/pttbbs/include/pttstruct.h index 49ec901c..b72a45fe 100644 --- a/pttbbs/include/pttstruct.h +++ b/pttbbs/include/pttstruct.h @@ -592,12 +592,11 @@ typedef struct { /* statistic */ int statistic[STAT_MAX]; - // TODO XXX 有 fromd 後可以拔掉了。 - /* 故鄉 fromcache */ - unsigned int home_ip[MAX_FROM]; - unsigned int home_mask[MAX_FROM]; - char home_desc[MAX_FROM][32]; - int home_num; + // 從前作為故鄉使用 (fromcache). 現已被 daemon/fromd 取代。 + unsigned int _deprecated_home_ip[MAX_FROM]; + unsigned int _deprecated_home_mask[MAX_FROM]; + char _deprecated_home_desc[MAX_FROM][32]; + int _deprecated_home_num; int max_user; time4_t max_time; diff --git a/pttbbs/mbbsd/mbbsd.c b/pttbbs/mbbsd/mbbsd.c index 8f31dc84..449c9d76 100644 --- a/pttbbs/mbbsd/mbbsd.c +++ b/pttbbs/mbbsd/mbbsd.c @@ -883,24 +883,6 @@ login_query(char *ruid) #endif } -#if defined(WHERE) && !defined(FROMD) -static int -where(const char *from) -{ - int i; - uint32_t ipaddr = ipstr2int(from); - - resolve_fcache(); - - for (i = 0; i < SHM->home_num; i++) { - if ((SHM->home_ip[i] & SHM->home_mask[i]) == (ipaddr & SHM->home_mask[i])) { - return i; - } - } - return 0; -} -#endif - static void check_BM(void) { @@ -970,13 +952,11 @@ setup_utmp(int mode) strip_nonebig5((unsigned char *)currutmp->nickname, sizeof(currutmp->nickname)); strip_nonebig5((unsigned char *)currutmp->mind, sizeof(currutmp->mind)); +#ifdef FROMD // resolve fromhost -#if defined(WHERE) - -# ifdef FROMD { int fd; - if ( (fd = toconnect(FROMD_ADDR)) >= 0 ) { + if ((fd = toconnect(FROMD_ADDR)) >= 0) { write(fd, fromhost, strlen(fromhost)); // zero and reuse uinfo.from to check real data memset(uinfo.from, 0, sizeof(uinfo.from)); @@ -987,14 +967,6 @@ setup_utmp(int mode) strlcpy(currutmp->from, uinfo.from, sizeof(currutmp->from)); } } -# else // !FROMD - { - int desc = where(fromhost); - if (desc > 0) - strlcpy(currutmp->from, SHM->home_desc[desc], sizeof(currutmp->from)); - } -# endif // !FROMD - #endif // WHERE /* Very, very slow friend_load. */ diff --git a/pttbbs/pttbbs.mk b/pttbbs/pttbbs.mk index 92b1ed2e..c0463882 100644 --- a/pttbbs/pttbbs.mk +++ b/pttbbs/pttbbs.mk @@ -32,7 +32,7 @@ PTT_CFLAGS:= $(PTT_WARN) -pipe -DBBSHOME='"$(BBSHOME)"' -I$(SRCROOT)/include PTT_CXXFLAGS:= $(PTT_WARN) -pipe -DBBSHOME='"$(BBSHOME)"' -I$(SRCROOT)/include PTT_LDFLAGS:= -Wl,--as-needed .if $(CLANG) -PTT_CFLAGS+= -Qunused-arguments -Wno-parentheses-equality +PTT_CFLAGS+= -Qunused-arguments -Wno-parentheses-equality -fcolor-diagnostics .endif # enable assert() |