コード例 #1
0
        public static bool Initialize()
        {
            // Setting up ENet-Client ->
            if (g_Client == null)
            {
                AllocConsole();
                Console.WriteLine("[ACCOUNT-CHECKER] Account Checker Bot/Client (C) 2020 playingo (aka DEERUX), github.com/playingoDEERUX/growbrewproxy\n" +
                                  "DO NOT CLOSE THIS WINDOW, OTHERWISE THE ENTIRE PROXY WILL CLOSE (except do it when you wanna exit from it)! \n" +
                                  "Although, you can still click on stop checking accounts to gain performance for proxy-only again.");

                if (accountsToCheck == null)
                {
                    Console.WriteLine("[ACCOUNT-CHECKER] ERROR: Could not start Account Checking, accountsToCheck list was null.");
                    return(false);
                }

                if (accountsToCheck.Count() <= 0)
                {
                    Console.WriteLine("[ACCOUNT-CHECKER] ERROR: Could not start Account Checking, there were no accounts loaded.");
                    return(false);
                }

                leftToCheckIndex    = accountsToCheck.Count() - 1;
                g_Client            = new ENetHost(1, 2);
                g_Client.OnConnect += Client_OnConnect;
                g_Client.ChecksumWithCRC32();
                g_Client.CompressWithRangeCoder();
                g_Client.StartServiceThread();
                Console.WriteLine("[ACCOUNT-CHECKER] Initialized Global Client Host and started service thread!\n" +
                                  "\nClick 'Connect and check all accounts' to start checking!");
            }
            return(true);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: zKevz/CSharp-GT-Server
        public static async Task Main()
        {
            try
            {
                Console.WriteLine("Gt server testing");
                ManagedENet.Startup();
                await UpdateItemsDat();

                IPEndPoint address = new IPEndPoint(IPAddress.Any, 17091);
                Server = new ENetHost(address, 1024, 10);
                Server.ChecksumWithCRC32();
                Server.CompressWithRangeCoder();

                await SetItemsDataDB();
                await SetItemsDB();

                await DbContext.OpenConnection();

                Console.WriteLine("Success at opening MySql connection!");
                Server.OnConnect += Server_OnConnect;
                Server.StartServiceThread();
                Thread.Sleep(-1);
            }
            catch (Exception e)
            {
                Console.WriteLine("Critical error occured ! Message : " + e.Message);
            }
        }
コード例 #3
0
        public static void LaunchProxy()
        {
            if (!globalUserData.srvRunning)
            {
                globalUserData.srvRunning    = true;
                globalUserData.clientRunning = true;

                // Setting up ENet-Server ->

                m_Host = new ENetHost(new IPEndPoint(IPAddress.Any, 2), 32, 10, 0, 0);
                m_Host.ChecksumWithCRC32();
                m_Host.CompressWithRangeCoder();
                m_Host.EnableNewProtocol(2);

                // Setting up ENet-Client ->
                client = new ENetHost(null, 64, 10); // for multibotting, coming soon.
                client.ChecksumWithCRC32();
                client.CompressWithRangeCoder();
                client.EnableNewProtocol(1);

                // realPeer = client.Connect(new IPEndPoint(IPAddress.Parse(globalUserData.Growtopia_Master_IP), globalUserData.Growtopia_Master_Port), 2, 0);
                //realPeer = client.Connect(new IPEndPoint(IPAddress.Parse(globalUserData.Growtopia_Master_IP), globalUserData.Growtopia_Master_Port), 2, 0);
                doProxy();

                // Setting up controls
                Console.WriteLine("RUnning!");
            }
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: RealGoblins/growbrewproxy
        void LaunchProxy()
        {
            if (!srvRunning)
            {
                srvRunning    = true;
                clientRunning = true;

                // Setting up ENet-Server ->
                m_Host            = new ENetHost(new IPEndPoint(IPAddress.Any, 2), 16, 2); // allow only 1 peer to be connected at the same time
                m_Host.OnConnect += Host_OnConnect;
                m_Host.ChecksumWithCRC32();
                m_Host.CompressWithRangeCoder();
                m_Host.StartServiceThread();

                // Setting up ENet-Client ->
                client            = new ENetHost(16, 2);
                client.OnConnect += Client_OnConnect;
                client.ChecksumWithCRC32();
                client.CompressWithRangeCoder();
                client.StartServiceThread();


                // Setting up controls
                runproxy.Enabled             = false; // too lazy to make it so u can disable it via button
                labelsrvrunning.Text         = "Server is running!";
                labelsrvrunning.ForeColor    = Color.Green;
                labelclientrunning.Text      = "Client is running!";
                labelclientrunning.ForeColor = Color.Green;
            }
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: thequantes/Growtopia-Checker
 private void animaButton2_Click(object sender, EventArgs e)
 {
     eNet            = new ENetHost(1, 2);
     eNet.OnConnect += Client_OnConnect;
     eNet.CompressWithRangeCoder();
     eNet.ChecksumWithCRC32();
     eNet.StartServiceThread();
     eNetP = eNet.Connect(new System.Net.IPEndPoint(IPAddress.Parse(Growtopia_Master_IP), Growtopia_Master_Port), 2, 0);
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: moien007/ENet.Managed
        static void Main(string[] args)
        {
            // You should call this at start of your application or before any usage of ENet
            Console.WriteLine("Starting ENet...");
            ManagedENet.Startup();

            // The IP endpoint which we are going to listen on
            var listenEndPoint = new IPEndPoint(IPAddress.Loopback, 27015);

            // By creating ENetHost we bind the endpoint
            Console.WriteLine("Creating host...");
            var host = new ENetHost(listenEndPoint, MaximumPeers, MaximumChannels);

            Console.WriteLine($"Servicing on {listenEndPoint}");

            while (true)
            {
                var Event = host.Service(TimeSpan.FromSeconds(60));

                switch (Event.Type)
                {
                case ENetEventType.None:
                    continue;

                case ENetEventType.Connect:
                    Console.WriteLine($"Peer connected from {Event.Peer.GetRemoteEndPoint()}");
                    continue;

                case ENetEventType.Disconnect:
                    Console.WriteLine($"Peer disconnected from {Event.Peer.GetRemoteEndPoint()}");
                    continue;

                case ENetEventType.Receive:
                    // Decode packet data bytes to ASCII string
                    var dataString = Encoding.ASCII.GetString(Event.Packet.Data);

                    // Here we prefix the dataString with peer's remote endpoint
                    dataString = $"{Event.Peer.GetRemoteEndPoint()}: {dataString}";

                    Console.WriteLine($"Peer {Event.Peer.GetRemoteEndPoint()}: {dataString}");

                    // this will broadcast the packet to all connected peers
                    // including the peer that sent this packet
                    host.Broadcast(Event.ChannelId, Event.Packet.Data, ENetPacketFlags.Reliable);

                    // We are done with the packet that the peer sent so we destroy it
                    // if you miss this you will end up with memory leaks
                    Event.Packet.Destroy();
                    continue;

                default:
                    throw new NotImplementedException();
                }
            }
        }
コード例 #7
0
        public static void Build()
        {
            ManagedENet.Startup();
            Port    = 17091;
            Address = new IPEndPoint(IPAddress.Any, Port);
            Host    = new ENetHost(Address, 1024, 1);
            Host.ChecksumWithCRC32();
            Host.CompressWithRangeCoder();

            Console.WriteLine("Server core has been built.\n" +
                              $"    [-] Port : {Port}\n");
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: OverallGod/GrowingServer
        private static void Main(string[] args)
        {
            ManagedENet.Startup();

            Console.WriteLine("Setting up Local Server");
            LocalServer = new ENetHost(new IPEndPoint(IPAddress.Any, 17091), 1024, 10, 0, 0);
            LocalServer.ChecksumWithCRC32();
            LocalServer.CompressWithRangeCoder();

            LocalServer.OnConnect += (sender, eventArgs) =>
            {
                LogClient("Connected!");

                RemotePeer = RemoteServer.Connect(RemoteEndpoint, 1, 0);

                RemotePeer.OnReceive += (o, packet) =>
                {
                    SendToClient(packet);
                };

                eventArgs.Peer.OnReceive += (o, packet) =>
                {
                    SendToRemote(packet);
                };

                eventArgs.Peer.OnDisconnect += (o, u) =>
                {
                    RemotePeer.DisconnectNow(0);
                    LogClient("Disconnected!");
                };
            };

            LocalServer.StartServiceThread();

            Console.WriteLine("Setting up Remote Server");

            RemoteServer = new ENetHost(1, 10);
            RemoteServer.ChecksumWithCRC32();
            RemoteServer.CompressWithRangeCoder();

            RemoteServer.OnConnect += (sender, eventArgs) => LogServer("Connected!");

            RemoteServer.StartServiceThread();

            while (true)
            {
                Thread.Sleep(5);
            }
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: thequantes/Growtopia-Checker
 private void animaButton5_Click(object sender, EventArgs e)
 {
     animaTextBox4.Enabled = false;
     animaTextBox3.Enabled = false;
     animaButton6.Enabled  = false;
     animaButton5.Enabled  = false;
     ManagedENet.Startup();
     eNet            = new ENetHost(1, 2);
     eNet.OnConnect += Client_OnConnect;
     eNet.CompressWithRangeCoder();
     eNet.ChecksumWithCRC32();
     eNet.StartServiceThread();
     eNetP = eNet.Connect(new System.Net.IPEndPoint(IPAddress.Parse(Growtopia_Master_IP), Growtopia_Master_Port), 2, 0);
     updatestatus("Connected!", 2);
 }
コード例 #10
0
        public ENetServer(string hostname, ushort port = 17091)
        {
            ManagedENet.Startup();

            var address = new IPEndPoint(IPAddress.Any, port);

            if (hostname != "0.0.0.0")
            {
                var addresses = Dns.GetHostAddresses(hostname);
                if (addresses.Length == 0)
                {
                    throw new ArgumentException("Unable to retrieve address from specified host name.", nameof(hostname));
                }

                address = new IPEndPoint(addresses[0], port);
            }

            _host = new ENetHost(address, 1024, 10);
            _host.ChecksumWithCRC32();
            _host.CompressWithRangeCoder();

            InstanceId = Guid.NewGuid();

            OnConnect += (sender, args) =>
            {
                Console.WriteLine("A new Peer tries to connect!");
                lock (Peers)
                    Peers.Add(args.Peer);

                var player = new Player(args.Peer);
                player.OnConnect();

                args.Peer.OnDisconnect += (o, u) =>
                {
                    lock (Peers)
                        Peers.Remove(o as ENetPeer);

                    player.OnDisconnect();
                };
            };

            _host.OnConnect += OnConnect;
        }
コード例 #11
0
        public ChatForm(IPEndPoint endPoint, bool connect) : this()
        {
            ManagedENet.Startup();

            IsClient     = connect;
            nameBox.Text = string.Format("Test{0}", new Random().Next(1, 10));
            if (IsClient)
            {
                chatBox.Enabled = false;
            }

            m_Host            = IsClient ? new ENetHost(1, 1) : new ENetHost(endPoint, ENetHost.MaximumPeers, 1);
            m_Host.OnConnect += Host_OnConnect;
            if (IsClient)
            {
                m_Host.Connect(endPoint, 1, 0);
            }
            m_Host.StartServiceThread();
        }
コード例 #12
0
        public static async Task Main()
        {
            try
            {
                SendDateTime();
                Console.WriteLine("GT SERVER IN C#");
                ManagedENet.Startup();
                await UpdateItemsDat();

                // To check the log. recommend not to lol
                //UseLog = true;

                IPEndPoint address = new IPEndPoint(IPAddress.Any, 17091);
                Server = new ENetHost(address, 1024, 10);
                Server.ChecksumWithCRC32();
                Server.CompressWithRangeCoder();

                await SetItemsDataDB();
                await SetItemsDB();

                await DbContext.OpenConnection();

                SendDateTime();
                Console.WriteLine("Success at opening MySql connection!");
                SendDateTime();
                Console.WriteLine("Server created.");
                Server.OnConnect += Server_OnConnect;
                Server.StartServiceThread();
                Thread.Sleep(-1);
            }
            catch (Exception e)
            {
                SendDateTime();
                Console.WriteLine("Critical error occured ! Message : " + e.Message);
            }
        }
コード例 #13
0
ファイル: Native.cs プロジェクト: NitroXenon/Ignite
 public static extern int enet_host_check_events(ENetHost* host, out ENetEvent @event);
コード例 #14
0
 public override void host_channel_limit(ENetHost* host, IntPtr channelLimit)
 {
     native_host_channel_limit(host, channelLimit);
 }
コード例 #15
0
 public override int host_service(ENetHost* host, out ENetEvent @event, uint timeout)
 {
     return native_host_service(host, out @event, timeout);
 }
コード例 #16
0
 public override void host_destroy(ENetHost* host)
 {
     native_host_destroy(host);
 }
コード例 #17
0
 static extern void native_host_broadcast(ENetHost* host, byte channelID, ENetPacket* packet);
コード例 #18
0
ファイル: Native.cs プロジェクト: NitroXenon/Ignite
 public static extern ENetPeer* enet_host_connect(ENetHost* host, ref ENetAddress address, IntPtr channelCount);
コード例 #19
0
ファイル: Native.cs プロジェクト: NitroXenon/Ignite
 public static extern void enet_host_flush(ENetHost* host);
コード例 #20
0
 static extern void native_host_destroy(ENetHost* host);
コード例 #21
0
 static extern void native_host_flush(ENetHost* host);
コード例 #22
0
 static extern int native_host_compress_with_range_encoder(ENetHost* host);
コード例 #23
0
 static extern ENetPeer* native_host_connect(ENetHost* host, ref ENetAddress address, IntPtr channelCount, uint data);
コード例 #24
0
 static extern void native_host_compress(ENetHost* host, ENetCompressor* compressor);
コード例 #25
0
 static extern int native_host_check_events(ENetHost* host, out ENetEvent @event);
コード例 #26
0
 static extern void native_host_channel_limit(ENetHost* host, IntPtr channelLimit);
コード例 #27
0
ファイル: Native.cs プロジェクト: NitroXenon/Ignite
 public static extern void enet_host_compress(ENetHost* host, ENetCompressor* compressor);
コード例 #28
0
 static extern int native_host_service(ENetHost* host, out ENetEvent @event, uint timeout);
コード例 #29
0
ファイル: Native.cs プロジェクト: NitroXenon/Ignite
 public static extern int enet_host_compress_with_range_coder(ENetHost* host);
コード例 #30
0
        static void Main(string[] args)
        {
            // You should call this at start of your application or before any usage of ENet library
            Console.WriteLine("Starting ENet...");
            ManagedENet.Startup();

            // By passing null as endpoint the system will pick up a random open endpoint to listen on
            // since we are the client we choose a random endpoint
            IPEndPoint listenEndPoint = null;
            var        host           = new ENetHost(listenEndPoint, MaximumPeers, MaximumChannels);

            // This is the endpoint that the server is listening on
            // IPAddress.Loopback equals to 127.0.0.1 on most systems
            IPEndPoint connectEndPoint = new IPEndPoint(IPAddress.Loopback, 27015);

            // Here we connect to the server by creating a peer and sending the connect packet
            // Connect Data is a number which we can supply with our packet
            // this number can be ignored by server
            uint connectData = 0;

            // Send connect request
            Console.WriteLine("Requesting connection...");
            var peer = host.Connect(connectEndPoint, MaximumChannels, connectData);

            while (true)
            {
                var Event = host.Service(TimeSpan.FromMilliseconds(250));

                switch (Event.Type)
                {
                case ENetEventType.None:
                    // Check if user is about to write something to input
                    if (Console.KeyAvailable)
                    {
                        // Read user input
                        var line = Console.ReadLine();

                        // If user wanted to disconnect
                        if (line == "/disconnect")
                        {
                            // Request disconnect
                            peer.Disconnect(data: 0);

                            // Go for next event
                            continue;
                        }

                        // Encode the input into ASCII bytes
                        var data = Encoding.ASCII.GetBytes(line);

                        // Send packet through channel 0 with the reliable packet flag set
                        peer.Send(channelId: 0, data, ENetPacketFlags.Reliable);
                    }

                    continue;

                case ENetEventType.Connect:
                    Console.WriteLine("Connected, write /disconnect to disconnect from server");
                    continue;

                case ENetEventType.Disconnect:
                    Console.WriteLine("Disconnected");
                    goto shutdown;

                case ENetEventType.Receive:
                    // Decode packet data into ASCII string
                    var dataString = Encoding.ASCII.GetString(Event.Packet.Data);

                    // We are done with this packet so we destroy it
                    Event.Packet.Destroy();

                    Console.WriteLine(dataString);
                    continue;

                default:
                    throw new NotImplementedException();
                }
            }

shutdown:
            host.Dispose();

            Console.WriteLine("Shutdown ENet...");
            ManagedENet.Shutdown();

            Console.WriteLine("Client stopped, press any key to close the app");
            Console.ReadKey();
        }
コード例 #31
0
ファイル: Native.cs プロジェクト: NitroXenon/Ignite
 public static extern void enet_host_destroy(ENetHost* host);
コード例 #32
0
 public override int host_compress_with_range_encoder(ENetHost* host)
 {
     return native_host_compress_with_range_encoder(host);
 }
コード例 #33
0
ファイル: Native.cs プロジェクト: NitroXenon/Ignite
 public static extern int enet_host_service(ENetHost* host, out ENetEvent @event, uint timeout);
コード例 #34
0
 public override void host_compress(ENetHost* host, ENetCompressor* compressor)
 {
     native_host_compress(host, compressor);
 }
コード例 #35
0
 public override ENetPeer* host_connect(ENetHost* host, ref ENetAddress address, IntPtr channelCount, uint data)
 {
     return native_host_connect(host, ref address, channelCount, data);
 }
コード例 #36
0
 static extern void native_host_bandwidth_limit(ENetHost* host, uint incomingBandwidth, uint outgoingBandwidth);
コード例 #37
0
ファイル: Native.cs プロジェクト: NitroXenon/Ignite
 public static extern void enet_host_bandwidth_limit(ENetHost* host, uint incomingBandwidth, uint outgoingBandwidth);
コード例 #38
0
ファイル: Native.cs プロジェクト: NitroXenon/Ignite
 public static extern void enet_host_broadcast(ENetHost* host, byte channelID, ENetPacket* packet);
コード例 #39
0
 public override int host_check_events(ENetHost* host, out ENetEvent @event)
 {
     return native_host_check_events(host, out @event);
 }
コード例 #40
0
ファイル: Native.cs プロジェクト: NitroXenon/Ignite
 public static extern void enet_host_channel_limit(ENetHost* host, IntPtr channelLimit);
コード例 #41
0
 public override void host_broadcast(ENetHost* host, byte channelID, ENetPacket* packet)
 {
     native_host_broadcast(host, channelID, packet);
 }
コード例 #42
0
 public override void host_flush(ENetHost* host)
 {
     native_host_flush(host);
 }
コード例 #43
0
 public override void host_bandwidth_limit(ENetHost* host, uint incomingBandwidth, uint outgoingBandwidth)
 {
     native_host_bandwidth_limit(host, incomingBandwidth, outgoingBandwidth);
 }
コード例 #44
0
 public ENetServer()
 {
     _running  = false;
     _logger   = LogProvider.Logger(GetType());
     _eNetHost = new ENetHost(new IPEndPoint(IPAddress.Loopback, 12345), 32, 2, 0, 0);
 }