【发布时间】:2017-05-12 04:11:56
【问题描述】:
我正在通过 telnet 连接到 Cisco 编解码器 SX20。
我的套接字连接然后得到:��\u0018�� ��#��\' 连接后。我期待类似于Password: 或login: 的东西。我使用节点的 net.socket 连接的其他设备工作正常。这是我得到的唯一块;它总是看起来一样。
我已经尝试过大量节点编码实现(本机和 iconv) - 没有任何可读性。其他客户端工作正常,例如 putty(utf8 编码)或 telnet 命令(自动发现?)。
部分结果:https://gist.github.com/below9k/4dbae508031d586ed7719958b425552c
-- 解决方案/编辑: 我最终使用https://github.com/blinkdog/telnet-stream 解决了这个问题 显然,这个单位想要在合作之前进行一些小的 telnet 协商。
const telnetInput = new TelnetInput()
const telnetOutput = new TelnetOutput()
telnetInput.on('do', function (option) {
telnetOutput.writeWont(option)
})
telnetInput.on('will', function (option) {
telnetOutput.writeDont(option)
})
telnetInput.on('data', Meteor.bindEnvironment((data) => {
console.log(data.toString('utf8'))
}))
socket.pipe(telnetInput)
telnetOutput.pipe(socket)
console.log 返回 login: - 耶
我的理解是,我向该单元发送了一些标准化的信息(更多信息在上面的 repo 中)并且使它工作。
【问题讨论】:
标签: node.js sockets terminal character-encoding telnet