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 /"
borisuu/laravel-telnet 适用场景与选型建议
borisuu/laravel-telnet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.78k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2020 年 10 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 borisuu/laravel-telnet 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 borisuu/laravel-telnet 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.78k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 13
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-only
- 更新时间: 2020-10-08