Esempio n. 1
0
        public void addClient(TcpClient client)
        {
            if (this._banned == null)
            {
                this._banned = NetworkBlock.getInstance();
            }
            string ip = client.Client.RemoteEndPoint.ToString().Split(new char[1]
            {
                ':'
            })[0];

            if (!this._banned.allowed(ip))
            {
                client.Close();
                CLogger.getInstance().error("NetworkBlock: connection attemp failed. " + ip + " banned.");
            }
            else
            {
                GameClient gameClient = new GameClient(client);
                if (this._loggedClients.Contains(gameClient))
                {
                    CLogger.getInstance().info("Client is Have");
                }
                else
                {
                    this._loggedClients.Add(gameClient);
                }
            }
        }
Esempio n. 2
0
        public void addClient(TcpClient client)
        {
            bool flag = this._banned == null;

            if (flag)
            {
                this._banned = NetworkBlock.getInstance();
            }
            string text = client.Client.RemoteEndPoint.ToString().Split(new char[]
            {
                ':'
            })[0];
            bool flag2 = !this._banned.allowed(text);

            if (flag2)
            {
                client.Close();
                CLogger.getInstance().error("NetworkBlock: connection attemp failed. " + text + " banned.");
            }
            else
            {
                GameClient item  = new GameClient(client);
                bool       flag3 = this._loggedClients.Contains(item);
                if (flag3)
                {
                    CLogger.getInstance().info("Client is Have");
                }
                else
                {
                    this._loggedClients.Add(item);
                }
            }
        }
Esempio n. 3
0
        public NetworkBlock ToNetworkBlock()
        {
            NetworkBlock netBlock = new NetworkBlock();

            netBlock.type = type;
            return(netBlock);
        }
Esempio n. 4
0
    public IEnumerator Block_Network_Create_new_block()
    {
        GameObject NetworkManager = GameObject.Find("NetworkManager");//new GameObject("NetworkManager");
        // NetworkManager.AddComponent<NetworkLayerClient>();
        NetworkLayerClient networkLayer = NetworkManager.GetComponent <NetworkLayerClient>();
        Home home = new Home();

        home.city                = 1;
        home.idtable             = 255;
        networkLayer.citynetwork = new NetworkCity();
        // networkLayer.HomeListAdd(new Vector3());
        Vector3 position = new Vector3();

        if (networkLayer.isDublicateHome(position) != null)
        {
            yield return(null);
        }

        Home newhome = new Home();

        newhome.position = position;
        networkLayer.homes.Add(newhome);

        networkLayer.citynetwork.id = 1;
        Assert.AreEqual(5701, networkLayer.port); /// Проверка подшрузился ли NetworkManager
        Assert.AreEqual(1, networkLayer.homes);   // Проверка на добавление дома



        ItemStore itemStore = networkLayer.isDublicateBlock(home.idtable, position);

        if (itemStore == null)
        {
            itemStore        = new ItemStore();
            itemStore.coordX = position.x;
            itemStore.coordY = position.y;
            itemStore.coordZ = position.z;

            //homes[homeid].itemList.Add(itemStore);
            // networkLayer.homes.Find(x => x.idtable == home.idtable).itemList.Add(itemStore); //Причина дублирования юлоков

            NetworkBlock networkBlock = new NetworkBlock();
            networkBlock.position = position;
        }
        else
        {
            Debug.Log("Этот блок уже сушесьвует " + itemStore.ItemID);
        }


        yield return(null);
    }
Esempio n. 5
0
        public void addClient(TcpClient client)
        {
            if (banned == null)
            {
                banned = NetworkBlock.getInstance();
            }

            string ip = client.Client.RemoteEndPoint.ToString().Split(':')[0];

            Console.WriteLine("connected " + ip);
            if (flood.ContainsKey(ip))
            {
                if (flood[ip].CompareTo(DateTime.Now) == 1)
                {
                    CLogger.warning("active flooder " + ip);
                    client.Close();
                    return;
                }
                else
                {
                    lock (flood)
                    {
                        flood.Remove(ip);
                    }
                }
            }

            flood.Add(ip, DateTime.Now.AddMilliseconds(3000));

            if (!banned.Allowed(ip))
            {
                client.Close();
                CLogger.error("NetworkBlock: connection attemp failed. " + ip + " banned.");
                return;
            }

            LoginClient lc = new LoginClient(client);

            if (_loggedClients.Contains(lc))
            {
                return;
            }

            _loggedClients.Add(lc);
        }
Esempio n. 6
0
        public void AddClient(TcpClient client)
        {
            if (Banned == null)
            {
                Banned = NetworkBlock.Instance;
            }

            string ip = client.Client.RemoteEndPoint.ToString().Split(':')[0];

            lock (Flood)
            {
                if (Flood.ContainsKey(ip))
                {
                    if (Flood[ip].CompareTo(DateTime.Now) == 1)
                    {
                        log.Warn($"Active flooder: {ip}");
                        client.Close();
                        return;
                    }

                    lock (Flood)
                        Flood.Remove(ip);
                }
            }

            Flood.Add(ip, DateTime.Now.AddMilliseconds(3000));

            if (!Banned.Allowed(ip))
            {
                client.Close();
                log.Error($"Connection attempt failed. {ip} banned.");
                return;
            }

            GameClient gc = new GameClient(_playerService, this, client, _gamePacketHandler);

            lock (Clients)
                Clients.Add(gc.Address.ToString(), gc);
            log.Info($"{Clients.Count} active connections");
        }
Esempio n. 7
0
    private void CheckNeighbours()
    {
        NetworkBlock neighbour = FindObjectOfType <LevelGrid>()?.GetBlock(transform.position + transform.up)?.GetComponent <NetworkBlock>();

        if (neighbour != null && neighbour != this)
        {
            if (neighbour.IsOn)
            {
                TurnOn(neighbour);
            }
        }

        neighbour = FindObjectOfType <LevelGrid>()?.GetBlock(transform.position - transform.up)?.GetComponent <NetworkBlock>();
        if (neighbour != null && neighbour != this)
        {
            if (neighbour.IsOn)
            {
                TurnOn(neighbour);
            }
        }

        neighbour = FindObjectOfType <LevelGrid>()?.GetBlock(transform.position + transform.right)?.GetComponent <NetworkBlock>();
        if (neighbour != null && neighbour != this)
        {
            if (neighbour.IsOn)
            {
                TurnOn(neighbour);
            }
        }

        neighbour = FindObjectOfType <LevelGrid>()?.GetBlock(transform.position - transform.right)?.GetComponent <NetworkBlock>();
        if (neighbour != null && neighbour != this)
        {
            if (neighbour.IsOn)
            {
                TurnOn(neighbour);
            }
        }
    }
Esempio n. 8
0
        public void addClient(TcpClient client)
        {
            if (_banned == null)
            {
                _banned = NetworkBlock.getInstance();
            }

            string ip = client.Client.RemoteEndPoint.ToString().Split(':')[0];

            if (_flood.ContainsKey(ip))
            {
                if (_flood[ip].CompareTo(DateTime.Now) == 1)
                {
                    CLogger.warning("active flooder " + ip);
                    client.Close();
                    return;
                }
                else
                {
                    lock (_flood)
                        _flood.Remove(ip);
                }
            }

            _flood.Add(ip, DateTime.Now.AddMilliseconds(3000));

            if (!_banned.allowed(ip))
            {
                client.Close();
                CLogger.error("NetworkBlock: connection attemp failed. " + ip + " banned.");
                return;
            }

            GameClient gc = new GameClient(client);

            clients.Add(gc._address.ToString(), gc);
            CLogger.extra_info("NetController: " + clients.Count + " active connections");
        }
Esempio n. 9
0
        public void Start()
        {
            Console.Title = "L2dotNET Gameserver";

            CLogger.form();
            Cfg.init("all");

            CharTemplateTable.Instance.Initialize();

            NetworkBlock.getInstance();
            GameTime.getInstance();

            IdFactory.Instance.Initialize();

            L2World.Instance.Initialize();

            // MapRegionTable.getInstance();
            ZoneTable.getInstance();

            NpcTable.getInstance();
            NpcData.getInstance();
            //  SpawnTable.getInstance();
            StaticObjTable.getInstance().read();
            StructureTable.getInstance().read();
            //  TSkillTable.getInstance();
            ItemTable.getInstance();
            ItemHandler.getInstance();
            MultiSell.getInstance();
            Capsule.getInstance();
            RecipeTable.getInstance();

            MonsterRace.getInstance();

            AIManager.getInstance();


            BlowFishKeygen.genKey();
            CLogger.info("generated 20 blowfish keys");

            AdminAccess.Instance.Initialize();;

            QuestManager.getInstance();

            AnnouncementManager.Instance.Initialize();

            AllianceTable.getInstance();
            ClanTable.getInstance();

            CLogger.info("NpcServer: ");
            StaticObjTable.getInstance().Spawn();
            MonsterRace.getInstance().Spawn();
            //  SpawnTable.getInstance().Spawn();
            StructureTable.getInstance().init();

            HtmCache.getInstance();

            AuthThread.getInstance();

            //   GeoData.getInstance();

            CLogger.extra_info("listening game clients on port " + Cfg.SERVER_PORT);
            _listener = new TcpListener(Cfg.SERVER_PORT);
            _listener.Start();

            TcpClient clientSocket = default(TcpClient);

            while (true)
            {
                clientSocket = _listener.AcceptTcpClient();
                accept(clientSocket);
            }
        }