定制 meklis/console-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

meklis/console-client

最新稳定版本:0.0.3

Composer 安装命令:

composer require meklis/console-client

包简介

SSH/Telnet client

README 文档

README

PHP library for login/password connections to devices over Telnet and SSH.

Install

composer require meklis/console-client

Example

SSH connection to ZTE devices

require __DIR__ . '/vendor/autoload.php';

$ssh = new \Meklis\Network\Console\SSH();
$ssh->setDeviceHelper(new \Meklis\Network\Console\Helpers\ZTE());
$ssh->connect("10.0.0.2", 2222); //Ip and custom port 
$ssh->login("login", "password"); 
echo $ssh->exec("show card");

Telnet connection to Dlink device

require __DIR__ . '/vendor/autoload.php';

$ssh = new \Meklis\Network\Console\Telnet();
$ssh->setDeviceHelper(new \Meklis\Network\Console\Helpers\Dlink());
$ssh->connect("10.0.0.1");
$ssh->login("login", "password");
echo $ssh->exec("show switch");

Supported vendors

  • Alcatel
  • Alaxala
  • Bdcom
  • Cdata
  • Dlink
  • Dell
  • Edgecore
  • Foxgate
  • Gcom
  • Huawei
  • Tp-link
  • Ios
  • ZTE
  • Junos
  • Linux
  • Vsolution
  • Xos

For adding own vendors you can create Helper extended from DefaultHelper and implement HelperInterface.

Example of helper

namespace Meklis\Network\Console\Helpers;

class Cdata extends DefaultHelper
{
    protected $prompt = 'OLT(.*?)[>#]';
    protected $userPrompt = 'ame:';
    protected $passwordPrompt = 'ord:';
    protected $afterLoginCommands = [];
    protected $beforeLogoutCommands = [];
    protected $windowSize = null;

    public function isDoubleLoginPrompt(): bool
    {
        if ($this->connectionType === 'ssh') {
            return true;
        }
        return $this->doubleLoginPrompt;
    }
}

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-25