Esempio n. 1
0
        void ReleaseDesignerOutlets()
        {
            if (IpConfirm != null)
            {
                IpConfirm.Dispose();
                IpConfirm = null;
            }

            if (IPEntry != null)
            {
                IPEntry.Dispose();
                IPEntry = null;
            }

            if (StatusProgress != null)
            {
                StatusProgress.Dispose();
                StatusProgress = null;
            }

            if (StatusText != null)
            {
                StatusText.Dispose();
                StatusText = null;
            }
        }
Esempio n. 2
0
        private void ApplyButton_Click(object sender, EventArgs e)
        {
            if (InterfaceListView.SelectedIndices.Count == 1)
            {
                int selectedIdx        = InterfaceListView.SelectedIndices[0];
                NetworkInterface netIf = mIfList[selectedIdx];

                if (DhcpCheckBox.Checked)
                {
                    netIf.EnableDHCP();
                }
                else
                {
                    List <IPEntry> ipList = new List <IPEntry>();
                    foreach (DataRow row in IPTable.Rows)
                    {
                        IPEntry ip = new IPEntry(row["IP"].ToString(), row["Mask"].ToString());
                        ipList.Add(ip);
                        Console.WriteLine("IPList : " + ip.ToString());
                    }
                    string gateway = GatewayTextBox.Text;
                    netIf.SetIPEntries(ipList);
                    netIf.SetGateway(gateway);
                }
                RefreshInterfaces();
            }
        }
Esempio n. 3
0
    public override void Update(Server server, float dt)
    {
        if (!loaded)
        {
            loaded = true;
            LoadBanlist(server);
        }

        if (server.banlist.ClearTimeBans() > 0)
        {
            SaveBanlist(server);
        }

        foreach (KeyValuePair <int, ClientOnServer> k in server.clients)
        {
            int            clientId = k.Key;
            ClientOnServer c        = k.Value;
            IPEndPointCi   iep1     = c.socket.RemoteEndPoint();

            if (server.banlist.IsIPBanned(iep1.AddressToString()))
            {
                IPEntry entry  = server.banlist.GetIPEntry(iep1.AddressToString());
                string  reason = entry.Reason;
                if (string.IsNullOrEmpty(reason))
                {
                    reason = "";
                }
                server.SendPacket(clientId, ServerPackets.DisconnectPlayer(string.Format(server.language.ServerIPBanned(), reason)));
                Console.WriteLine(string.Format("Banned IP {0} tries to connect.", iep1.AddressToString()));
                server.ServerEventLog(string.Format("Banned IP {0} tries to connect.", iep1.AddressToString()));
                server.KillPlayer(clientId);
                continue;
            }

            string username = c.playername;
            if (server.banlist.IsUserBanned(username))
            {
                UserEntry entry  = server.banlist.GetUserEntry(username);
                string    reason = entry.Reason;
                if (string.IsNullOrEmpty(reason))
                {
                    reason = "";
                }
                server.SendPacket(clientId, ServerPackets.DisconnectPlayer(string.Format(server.language.ServerUsernameBanned(), reason)));
                Console.WriteLine(string.Format("{0} fails to join (banned username: {1}).", (c.socket.RemoteEndPoint()).AddressToString(), username));
                server.ServerEventLog(string.Format("{0} fails to join (banned username: {1}).", (c.socket.RemoteEndPoint()).AddressToString(), username));
                server.KillPlayer(clientId);
                continue;
            }
        }
    }
Esempio n. 4
0
    public bool UnbanIP(string ip)
    {
        bool exists = false;

        for (int i = BannedIPs.Count - 1; i >= 0; i--)
        {
            IPEntry bannedip = BannedIPs[i];
            if (bannedip.IPAdress.Equals(ip, StringComparison.InvariantCultureIgnoreCase))
            {
                exists = true;
                BannedIPs.RemoveAt(i);
                break;
            }
        }
        return(exists);
    }
Esempio n. 5
0
    public bool TimeBanIP(string ipadress, string bannedby, string reason, int intervalMinutes)
    {
        if (IsIPBanned(ipadress))
        {
            return(false);
        }
        IPEntry newBan = new IPEntry();

        newBan.IPAdress = ipadress;
        newBan.BannedBy = bannedby;
        if (intervalMinutes > 0)
        {
            newBan.BannedUntil = DateTime.UtcNow + TimeSpan.FromMinutes(intervalMinutes);
        }
        if (!string.IsNullOrEmpty(reason))
        {
            newBan.Reason = reason;
        }
        BannedIPs.Add(newBan);
        return(true);
    }
Esempio n. 6
0
        public async Task <bool> Get([FromQuery] string name,
                                     [FromQuery] int?price,
                                     [FromQuery] Rarity?rarity,
                                     [FromQuery] ItemCategory?category,
                                     [FromQuery(Name = "ext")] bool?extraordinary)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(false);
            }
            if (price == null)
            {
                return(false);
            }
            if (rarity == null)
            {
                return(false);
            }
            if (category == null)
            {
                return(false);
            }
            if (extraordinary == null)
            {
                return(false);
            }

            var ipEntry = await _marketContext.IPs.SingleOrDefaultAsync(k => k.IP == HttpContext.Connection.RemoteIpAddress.ToString());

            if (ipEntry == null)
            {
                ipEntry = new IPEntry()
                {
                    IP = HttpContext.Connection.RemoteIpAddress.ToString()
                };
            }
            if (ipEntry.Blocked)
            {
                return(false);
            }

            var item = await _marketContext.Items.SingleOrDefaultAsync(i => i.Name == name && i.Rarity == rarity);

            if (item == null)
            {
                item = new Item()
                {
                    Name = name, Rarity = rarity, ItemCategory = category, IsExtraordinary = extraordinary
                };
            }
            else
            {
                var mostRecentPrice = await _marketContext.MostRecentPrices.SingleAsync(mrp => mrp.ItemID == item.ID);

                if (mostRecentPrice.Marks == price && mostRecentPrice.Time.AddHours(3) > DateTime.UtcNow)
                {
                    //Ignore duplicated prices if they happen over a small time window
                    return(false);
                }
            }

            var newPrice = new HistoricalPrice()
            {
                Item = item, Marks = price.Value, Time = DateTime.UtcNow, IP = ipEntry
            };

            _marketContext.Prices.Add(newPrice);

            await _marketContext.SaveChangesAsync();

            return(true);
        }
Esempio n. 7
0
 public bool TimeBanIP(string ipadress, string bannedby, string reason, int intervalMinutes)
 {
     if (IsIPBanned(ipadress))
     {
         return false;
     }
     IPEntry newBan = new IPEntry();
     newBan.IPAdress = ipadress;
     newBan.BannedBy = bannedby;
     if (intervalMinutes > 0)
     {
         newBan.BannedUntil = DateTime.UtcNow + TimeSpan.FromMinutes(intervalMinutes);
     }
     if (!string.IsNullOrEmpty(reason))
     {
         newBan.Reason = reason;
     }
     BannedIPs.Add(newBan);
     return true;
 }