Coder Social home page Coder Social logo

corercon's Introduction

New Maintainer

CoreRCON has been moved to Challengermode/CoreRcon per #17! Please direct any issues and pull requests there.


CoreRCON

CoreRCON is an implementation of the RCON protocol on .NET Core. It currently supports connecting to a server, sending commands and receiving their output, and receiving logs from logaddress.

Supports:

Installation

CoreRCON is available on NuGet, and can be installed with:

Install-Package CoreRCON

Quick Start

Connect to an RCON server and send a command

The IP address supplied here is the server you wish to connect to.

using CoreRCON;
using CoreRCON.Parsers.Standard;
// ...

// Connect to a server
var rcon = new RCON(IPAddress.Parse("10.0.0.1"), 27015, "secret-password");

// Send "status"
Status status = await rcon.SendCommandAsync<Status>("status");

Console.WriteLine($"Connected to: {status.Hostname}");

Listen for chat messages on the server

This assumes you have been added to the server's logaddress list. You do not need to make an rcon connection to receive logs from a server.

The port specified must be open (check your router settings) and unused. Pass a value of 0 to use the first-available port. Access log.ResolvedPort to see which port it chose.

Finally, pass an array (or list of params) of IPEndPoints to express which servers you would like to receive logs from. This is because any server can send your server logs if they know which port you are listening on, as it's just UDP.

using CoreRCON;
using CoreRCON.Parsers.Standard;
// ...

// Listen on port 50000 for log packets coming from 10.0.0.1:27015
var log = new LogReceiver(50000, new IPEndPoint(IPAddress.Parse("10.0.0.1"), 27015));
log.Listen<ChatMessage>(chat =>
{
	Console.WriteLine($"Chat message: {chat.Player.Name} said {chat.Message} on channel {chat.Channel}");
});

Troubleshooting

Can't install via NuGet

"Could not install package 'CoreRCON X.X.X'. You are trying to install this package into a project that targets '.NETFramework,Version=vy.y.y', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."

If you are seeing an error similar to this, try changing your project's targeted .NET Framework version [#11]. If you are using Visual Studio 2015, the minimum resolvable framework version is 4.7. Visual Studio 2017 has improved support for .NET Core packages, allowing CoreRCON to resolve for versions as low as 4.6.1.

Changelog

Version 3.0.0

corercon's People

Contributors

codingcontraption avatar scottkaye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

corercon's Issues

Cant install nuget

Hi when i try and install Nuget i get an error below
CoreRCON 2.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.2', but the package
does not contain any assembly references or content files that are compatible with that framework.

I have tried changing the target framework to what i think is every option but still cannot get it to install. Can you please advise what framework It is targeted to in case i missed one?

License?

I'm interested in using this library. Can you add a license to the project?

Intrested in contribution/maintaining

I forked and improved this library at work.
Challengermode/CoreRcon

I could help maintain and improve the project.
We use it in production at work so it seems stable.

Do you think we should merge or split it into a new repo since a changed how a connection is handled?

Can't RCON a server when it isn't empty.

Successful connection only work on a empty server.
When connect to a server which filling in people(not local connnection), it would alert a error.

Error messages:

24/01/2018 22:17:35 - Error reading RCON packet from server: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex

Connection from same machine

I have same problem as described in issue #10 from @tgardner851

I can connect from remote machine and all work's good, but when I deploy to server where game is running connection never finish, it does'n throw exception but stalls.
I have B3Bot running on the same machine as the game and it is working, B3Bot uses rcon as well to communicate with the game.

Game is COD4, and I say again everything works when game is accessed from another machine.

Could not install package 'CoreRCON 2.0.0'.

Could not install package 'CoreRCON 2.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Visual Studio 2015
Nuget VS 2015 VSIX - latest (v3.5.0)

CoreRcon seems to get no response from server

using your git repository, i get no info from the server, also followin the quickstart guide in my own project, i dont get any logs. even when i manually set the ip:port, and the port is properly exposed directly to the internet.

Using a fresh console application it instantly exists when i follow the logreciever quickguide. if i try to put the log.Listen inside a while(true) loop, i get a memoryleak. (which makes sense)

C# - CoreRCON

Hello,
I quickly tried to load the nuget to a "C#" project.
At first, I got 0 conflicts to download and install the package on the C# project.
I've got a conflict when I tried to call the class: new RCON(IPAddress.Parse.....)

It was like a conflict with the IPAddress from System.Net.Primitives. So I updated my .NET Core to see what I could achieve. Now it won't even install the package because the package doesn't have any information for what framework it is...Because it's .NET Core.

My question is, how could I get your awesome library to work on C# ?

Thank you

Connection from same server

Got what looks to be a strange situation - I'm running the code for CoreRCON and my Ark server (works with CoreRCON, by the way!), all from the same box. For whatever reason, I cannot get a connection working this way. The same code works from another server, or a local client, but never from the same server that hosts the RCON server and the Ark server.

I tried using local addresses (192.168.1.xxx, 127.0.0.1, localhost, and the public IP address). None work. All of these (with exception to 127.0.0.1 and localhost, for obvious reasons) will work from another device on the network.

Could this be related to CoreRCON and how it handles local requests?

I receive server info but can't receive log

Hello,
I'm testing this library with your example (Program.cs) and i receive the number of players and info server but he never receive log from server like messages.
I can't get status responde to say hostname.

Am I doing something wrong?
Regards.

Error reading RCON packet from server: Index was out of range.

When i send command trough RCON to my minecraft server it's successfully executed, but answer from server generate error: "Error reading RCON packet from server: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'startIndex')"

Sent command is an plugin's command. And error generated only with any plugin's commands.
With a command of the kernel of minecraft such an error isn't generated.

I know such program as "mcrcon". In this program all plugin's commands successfully return answer.

Perhaps I doing something wrong. Or CoreRcon can't get answer from such commands.

Suggestions

This is alot more stable than some of the other rcon libs i have used but is there any reason why there is no DisconnectAsync() function or an action for onConnected.

System.InvalidOperationException

Unhandled Exception: System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed. at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at CoreRCON.RCON.TCPPacketReceived(Object sender, SocketAsyncEventArgs e) at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e) at System.Net.Sockets.SocketAsyncEventArgs.ExecutionCallback(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags) at System.Net.Sockets.SocketAsyncEventArgs.CompletionCallback(Int32 bytesTransferred, SocketError socketError) at System.Net.Sockets.SocketAsyncEventArgs.TransferCompletionCallbackCore(Int32 bytesTransferred, Byte[] socketAddress, Int32 socketAddressSize, SocketFlags receivedFlags, SocketError socketError) at System.Net.Sockets.SocketAsyncContext.SendReceiveOperation.InvokeCallback() at System.Net.Sockets.SocketAsyncContext.AsyncOperation.<>c.<QueueCompletionCallback>b__11_0(Object o) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.QueueUserWorkItemCallbackDefaultContext.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch()

After sending RCON commands, my program crashes (after a small while) even with a couple of try catch statements. I have no idea why though.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.