Coder Social home page Coder Social logo

fpaezf / valve-rcon-protocol-in-vb.net Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 45 KB

A Valve RCON protocol implementation in Visual Basic .NET

Home Page: https://developer.valvesoftware.com/wiki/Source_RCON_Protocol

License: MIT License

Visual Basic .NET 100.00%
ark counter-strike counter-strike-2 counter-strike-global-offensive half-life rcon rcon-client rcon-console rcon-protocol rcon-server

valve-rcon-protocol-in-vb.net's Introduction

A Valve RCON protocol implementation in Visual Basic .NET

This is a simple implementation of the Valve RCON protocol in Visual Basic .NET 2019 Community Edition (Framework 4.7.2). Whith this library/class you can connect/authenticate/send commands/receive responses from your gameserver.

More info: https://developer.valvesoftware.com/wiki/Source_RCON_Protocol

TESTED WITH:

  • Counter-Strike 2
  • Counter-Strike: Global Offensive
  • Counter-Strike: Source
  • (Older versions are not guaranteed)

Installation

Usage

Dim serverIP As String = "82.223.49.142" 'String to declare server IP or host
Dim serverPort As Integer = 27015 'Integer to declare server port
Dim serverPassword As String = "your-password" 'String to declare RCON password

Dim RCON As New RconClient 'Create a new RconClient
RCON.Connect(serverIP, serverPort) 'Connect to the server IP/HOST:PORT
RCON.Authorize(serverPassword) 'Send password to authenticate
   If RCON.Authorized = True And RCON.Connected = True Then 'If no errors, you can now send commands
      Dim a As String = RCON.SendCommand("status") 'Store in a string the server response to command "status"
      RichTextBox1.AppendText(a) 'Append server response to RichTextBox.Text
   End If
RCON.Close() 'Close connection to the server

Data visualization

If you put the server output string in a TextBox control the lines will be concatenated because of the return carriage chars. To visualize data correctly please, use RichTextBox control.

Building RCON packets

Both requests and responses are sent as TCP packets. Their payload follows the following basic structure:

  • Size (Integer)
  • ID (Integer)
  • Type (Integer)
  • Body (null-terminated string encoded in ASCII)
  • Empty String (Empty null-terminated string encoded in ASCII)

This is how i build the packet to request authorization:

Dim Packet As Byte() = New Byte(CByte((4 + 4 + 4 + password.Length + 1))) {} 'Size + ID + Type + Command + Null
Packet(0) = password.Length + 9         'Packet Size (Integer)
Packet(4) = 99                          'Request Id (Integer between 1 and 99)
Packet(8) = 3                           'Request packet type: 3 = SERVERDATA_AUTH request
For X As Integer = 0 To password.Length - 1
     Packet(12 + X) = System.Text.Encoding.UTF8.GetBytes(password(X))(0) 'Command
Next

valve-rcon-protocol-in-vb.net's People

Contributors

fpaezf avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.