(banfil, authfil): Remove. Matching user is useless, because the
player can send whatever he wants. Banning IPs is better done with a packet filter. That leaves restricting deity IPs. (privip): New econfig key to restrict deity IPs. (may_play): Implement it. (match_user): Unused, remove.
This commit is contained in:
parent
342d7b33ce
commit
02ddee69fb
7 changed files with 10 additions and 59 deletions
|
@ -66,8 +66,6 @@ char *downfil = "down";
|
|||
char *disablefil = "disable";
|
||||
char *telfil = "tel/tel";
|
||||
char *annfil = "ann";
|
||||
char *banfil = "ban";
|
||||
char *authfil = "auth";
|
||||
char *timestampfil = "timestamp";
|
||||
|
||||
char *listen_addr = "";
|
||||
|
|
|
@ -266,15 +266,12 @@ may_play(void)
|
|||
pr_id(player, C_CMDERR, "need country and password\n");
|
||||
return 0;
|
||||
}
|
||||
if (match_user(banfil, player)) {
|
||||
logerror("Attempted login by BANNED host %s", praddr(player));
|
||||
pr_id(player, C_EXIT, "Your login has been banned from this game\n");
|
||||
io_shutdown(player->iop, IO_READ);
|
||||
return 0;
|
||||
}
|
||||
/* TODO strstr() cheesy, compare IP against IP/BITS ... */
|
||||
np = getnatp(player->cnum);
|
||||
if (np->nat_stat == STAT_GOD && !match_user(authfil, player)) {
|
||||
logerror("NON-AUTHed Login attempted by %s", praddr(player));
|
||||
if (np->nat_stat == STAT_GOD && *privip
|
||||
&& !strstr(privip, player->hostaddr)) {
|
||||
logerror("Deity login from untrusted host attempted by %s",
|
||||
praddr(player));
|
||||
pr_id(player, C_EXIT, "You're not a deity!\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -360,37 +360,6 @@ show_motd(void)
|
|||
return RET_OK;
|
||||
}
|
||||
|
||||
int
|
||||
match_user(char *file, struct player *p)
|
||||
{
|
||||
FILE *fp;
|
||||
int match = 0;
|
||||
char host[256];
|
||||
char user[256];
|
||||
|
||||
if ((fp = fopen(file, "r")) == NULL) {
|
||||
/*logerror("Cannot find file %s", file); */
|
||||
return 0;
|
||||
}
|
||||
match = 0;
|
||||
while (!feof(fp) && !match) {
|
||||
if (fgets(host, sizeof(host), fp) == NULL)
|
||||
break;
|
||||
if (host[0] == '#')
|
||||
continue;
|
||||
if (fgets(user, sizeof(user), fp) == NULL)
|
||||
break;
|
||||
host[strlen(host) - 1] = '\0';
|
||||
user[strlen(user) - 1] = '\0';
|
||||
if (strstr(p->userid, user) &&
|
||||
(strstr(p->hostaddr, host) ||
|
||||
strstr(p->hostname, host)))
|
||||
++match;
|
||||
}
|
||||
fclose(fp);
|
||||
return match;
|
||||
}
|
||||
|
||||
int
|
||||
quit(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue