added writeip back, writes all bans and filters to listip.cfg

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2307 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-05-29 16:12:21 +00:00
parent 4942e86843
commit c91b804c1e
2 changed files with 53 additions and 39 deletions

View file

@ -847,13 +847,14 @@ void SV_Unban_f (void)
while (nb)
{
nbnext = nb->next;
if (all || NET_CompareAdrMasked(nb->adr, unbanadr, unbanmask))
if (all || (NET_CompareAdr(nb->adr, unbanadr) && NET_CompareAdr(nb->adrmask, unbanmask)))
{
if (!all)
Con_Printf("unbanned %s\n", NET_AdrToStringMasked(nb->adr, nb->adrmask));
if (svs.bannedips == nb)
svs.bannedips = nbnext;
Z_Free(nb);
break;
}
nb = nbnext;
@ -885,19 +886,68 @@ void SV_Unfilter_f (void)
while (nb)
{
nbnext = nb->next;
if (all || NET_CompareAdrMasked(nb->adr, unbanadr, unbanmask))
if (all || (NET_CompareAdr(nb->adr, unbanadr) && NET_CompareAdr(nb->adrmask, unbanmask)))
{
if (!all)
Con_Printf("unfiltered %s\n", NET_AdrToStringMasked(nb->adr, nb->adrmask));
if (svs.filteredips == nb)
svs.filteredips = nbnext;
Z_Free(nb);
break;
}
nb = nbnext;
}
}
void SV_WriteIP_f (void)
{
vfsfile_t *f;
char name[MAX_OSPATH];
bannedips_t *bi;
filteredips_t *fi;
char *s;
strcpy (name, "listip.cfg");
Con_Printf ("Writing %s.\n", name);
f = FS_OpenVFS(name, "wb", FS_GAME);
if (!f)
{
Con_Printf ("Couldn't open %s\n", name);
return;
}
s = "// banned ip addresses\n";
VFS_WRITE(f, s, strlen(s));
bi = svs.bannedips;
while (bi)
{
if (bi->reason[0])
s = va("banip %s \"%s\"\n", NET_AdrToStringMasked(bi->adr, bi->adrmask), bi->reason);
else
s = va("banip %s\n", NET_AdrToStringMasked(bi->adr, bi->adrmask));
VFS_WRITE(f, s, strlen(s));
bi = bi->next;
}
s = "\n// filtered ip addresses\n";
VFS_WRITE(f, s, strlen(s));
fi = svs.filteredips;
while (fi)
{
s = va("addip %s\n", NET_AdrToStringMasked(fi->adr, fi->adrmask));
VFS_WRITE(f, s, strlen(s));
fi = fi->next;
}
VFS_CLOSE (f);
}
void SV_ForceName_f (void)
{
client_t *cl;
@ -1870,6 +1920,7 @@ void SV_InitOperatorCommands (void)
Cmd_AddCommand ("addip", SV_FilterIP_f);
Cmd_AddCommand ("removeip", SV_Unfilter_f);
Cmd_AddCommand ("listip", SV_FilterList_f);
Cmd_AddCommand ("writeip", SV_WriteIP_f);
// Cmd_AddCommand ("filterip", SV_FilterIP_f);
// Cmd_AddCommand ("unfilter", SV_Unfilter_f);

View file

@ -2371,43 +2371,6 @@ If 0, then only addresses matching the list will be allowed. This lets you easi
cvar_t filterban = SCVAR("filterban", "1");
/*
=================
SV_WriteIP_f
=================
*/
void SV_WriteIP_f (void)
{
// TODO: function needs to be rewritten to handle new banning and filtering logic
/*
vfsfile_t *f;
char name[MAX_OSPATH];
qbyte b[4];
int i;
char *s;
strcpy (name, "listip.cfg");
Con_Printf ("Writing %s.\n", name);
f = FS_OpenVFS(name, "wb", FS_GAME);
if (!f)
{
Con_Printf ("Couldn't open %s\n", name);
return;
}
for (i=0 ; i<numipfilters ; i++)
{
*(unsigned *)b = ipfilters[i].compare;
s = va("addip %i.%i.%i.%i\n", b[0], b[1], b[2], b[3]);
VFS_WRITE(f, s, strlen(s));
}
VFS_CLOSE (f);
*/
}
/*
=================
SV_FilterPacket