Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using System.Text;
- using System.Net.Sockets;
- using System.Threading;
- using System.Net;
- using System.IO;
- namespace Minerva.RCon
- {
- class RConServer
- {
- private Thread rconThread;
- private int rconPort;
- private string rconUser, rconPass;
- private TcpListener rconListener;
- private NetworkStream rconStream;
- private IPAddress rconIP;
- private TcpClient rconClient;
- private StreamWriter rconWrite;
- private StreamReader rconRead;
- public RConServer()
- {
- LoadConfiguration();
- rconListener = new TcpListener(rconIP, rconPort);
- rconThread = new Thread(new ThreadStart(ListenForRConClients));
- rconThread.Start();
- }
- private void ListenForRConClients()
- {
- Console.WriteLine("RConSvr listening for clients on {0}", rconListener.LocalEndpoint);
- while (true)
- {
- // blocks until a client has connected to the server
- TcpClient client = this.rconListener.AcceptTcpClient();
- Console.WriteLine("Client {0} connected to RConSvr", client.Client.RemoteEndPoint);
- // Create a thread to handle communication with connected client
- Thread clientThread = new Thread(new ParameterizedThreadStart(HandleRConComm));
- clientThread.Start(client);
- }
- }
- private void HandleRConComm(object client)
- {
- rconClient = (TcpClient)client;
- rconStream = rconClient.GetStream();
- int bytesRead;
- rconWrite.WriteLine("[Minerva RCon Server]");
- rconWrite.WriteLine("Authentication Required!");
- rconWrite.WriteLine("Please enter your username:");
- }
- void LoadConfiguration()
- {
- IniReader rconConf = new IniReader("conf/RConSvr.ini");
- rconIP = IPAddress.Parse(rconConf.ReadString("listen", "ip"));
- rconPort = rconConf.ReadInteger("listen", "port");
- rconUser = rconConf.ReadString("auth", "user");
- rconPass = rconConf.ReadString("auth", "password");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement