borisuu/laravel-telnet 问题修复 & 功能扩展

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

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

borisuu/laravel-telnet

Composer 安装命令:

composer require borisuu/laravel-telnet

包简介

A client for writing/reading commands to a host over telnet.

README 文档

README

Update 08.10.2020 - borisuu: I've made this a composer package for easier install into other projects. No code changes made.

Telnet client implementation in PHP.

This code is based on https://github.com/ngharo/Random-PHP-Classes/blob/master/Telnet.class.php but was completely rewritten. I tried to keep interface compatibility as much as possible.

Things that I know not to work the same anymore:

  • Using the constructor with more than 2 arguments, the meaning and order of subsequent parameters have changed
  • Line endings should always be returned to the caller as "\n" but this guarantee is based on the assumption of a correct server implementation (one that encodes line endings as <CR> <LF> in the default (text) state)
  • buffer and global_buffer as well as their associated methods are gone
  • The constructor no longer does a connect() call
  • The subclassing interface is probably broken (I couldn't keep the getBuffer() method without skipping the state machine)

Many things are still wrong (though it was like that in upstream versions too):

  • we DONT/WONT Suppress Go Ahead, Echo and Linemode but expect them to work, etc.

Usage example:

use Borisuu\Telnet\TelnetClient;

//Uncomment this to get debug logging
//TelnetClient::setDebug(true);

$telnet = new TelnetClient('127.0.0.1', 23);
$telnet->connect();
$telnet->setPrompt('$'); //setRegexPrompt() to use a regex
//$telnet->setPruneCtrlSeq(true); //Enable this to filter out ANSI control/escape sequences
$telnet->login('telnetuser', 'weak');

$cmdResult = $telnet->exec('ls /');

$telnet->disconnect();

print("The contents of / is: \"{$cmdResult}\"\n");

Alternatively, have a look at testTelnet.php:

$ ./testTelnet.php -h
$ ./testTelnet.php -u telnetuser -p weak -H 127.0.0.1 -P 23 -c "ls /"

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 0
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-only
  • 更新时间: 2020-10-08