rollylni/rcon-protocol 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rollylni/rcon-protocol

Composer 安装命令:

composer require rollylni/rcon-protocol

包简介

the library is written based on the Source RCON Protocol

README 文档

README

PHPVersion

RCON Protocol is a TCP / IP, communication-based protocol that allows console commands t mo be issued to a server via a "remote console", or RCON. Most often, RCON is used to allow server owners toanage their game servers without direct access to the machine the server is running on. For commands to be accepted, the connection must first be authenticated using the server's RCON password

Source RCON Protocol

Installation

composer require rollylni/rcon-protocol

Example Server

require "vendor/autoload.php";
use RconProtocol\RconServer;
use RconProtocol\ServerClient;
use RconProtocol\Packet;

$port = 27015;
$host = "0.0.0.0";

$server = new RconServer($port, $host);

# set ur password
$server->setPassword("Your Password");
# or generate
$len = 8;
$server->generatePassword($len);

$server->setMaxClients(10);
# client login timeout
$server->setTimeout(10);

# Events
$handler = $server->getHandler();
$handler->add("onTimeout", function(ServerClient $c) {
   echo $c->getPeerName() . ": timeout!\n";
});

$handler->add("onConnection", function(ServerClient $c) {
   echo $c->getPeerName() . ": connection...\n";
});

$handler->add("onDisconnection", function(ServerClient $c) {
   echo $c->getPeerName() . ": disconnection...\n";
});

$handler->add("onReceive", function(ServerClient $c, Packet $p) {
   echo $c->getPeerName() . ": ". $p->getBody() ."\n";
});

$handler->add("onAuthorized", function(ServerClient $c) {
   echo $c->getPeerName() . ": authorized!\n";
});

$handler->add("onFailed", function(ServerClient $c, string $input) {
   echo $c->getPeerName() . ": '$input' wrong password!\n";
});

$handler->add("onCommand", function(ServerClient $c, string $cmd) {
   //exec command
   echo $c->getPeerName() . ": $cmd\n";
});

// Starting RCON server
$server->start();
// Stopping
$server->stop();

Example Client

use RconProtocol\RconClient;

$serverHost = "0.0.0.0";
$serverPort = 27015;
$serverPassword = "";
$execCommand = "cmd";
$timeout = 10;

$client = new RconClient($serverHost, $serverPort, $timeout);
$client->connect();
if ($client->authorize($serverPassword)) {
   echo "Response: " . $client->sendCommand($execCommand);
} else {
   $client->disconnect();
}

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固