Exemplo n.º 1
0
        /**
         * StringToFilter.
         */
        private static bool StringToFilter(string s, ipfilter_t f)
        {
            byte[] b = { 0, 0, 0, 0 };
            byte[] m = { 0, 0, 0, 0 };

            try
            {
                var tk = s.Split(". ");

                for (var n = 0; n < 4; n++)
                {
                    b[n] = (byte)Lib.atoi(tk[n]);

                    if (b[n] != 0)
                    {
                        m[n] = 0xff;
                    }
                }

                f.mask    = new BinaryReader(new MemoryStream(m)).ReadInt32();
                f.compare = new BinaryReader(new MemoryStream(b)).ReadInt32();
            }
            catch (Exception)
            {
                GameBase.gi.cprintf(null, Defines.PRINT_HIGH, "Bad filter address: " + s + "\n");

                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        static void SVCmd_RemoveIP_f( )
        {
            GameSVCmds.ipfilter_t f = new ipfilter_t();
            Int32 i, j;

            if (GameBase.gi.Argc() < 3)
            {
                GameBase.gi.Cprintf(null, Defines.PRINT_HIGH, "Usage:  sv removeip <ip-mask>\\n");
                return;
            }

            if (!StringToFilter(GameBase.gi.Argv(2), f))
            {
                return;
            }
            for (i = 0; i < numipfilters; i++)
            {
                if (ipfilters[i].mask == f.mask && ipfilters[i].compare == f.compare)
                {
                    for (j = i + 1; j < numipfilters; j++)
                    {
                        ipfilters[j - 1] = ipfilters[j];
                    }
                    numipfilters--;
                    GameBase.gi.Cprintf(null, Defines.PRINT_HIGH, "Removed.\\n");
                    return;
                }
            }

            GameBase.gi.Cprintf(null, Defines.PRINT_HIGH, "Didn't find " + GameBase.gi.Argv(2) + ".\\n");
        }