mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-18 09:35:50 +00:00
feat(protocols/sdtd): add telnet support for players (#692)
* feat(protocols/sdtd): add telnet support * docs: update CHANGELOG.md
This commit is contained in:
parent
4db8a473ff
commit
71ce074866
9 changed files with 159 additions and 5 deletions
|
|
@ -7,6 +7,7 @@ import Logger from '../lib/Logger.js'
|
|||
import DnsResolver from '../lib/DnsResolver.js'
|
||||
import { Results } from '../lib/Results.js'
|
||||
import Promises from '../lib/Promises.js'
|
||||
import { Telnet } from 'telnet-client'
|
||||
|
||||
let uid = 0
|
||||
|
||||
|
|
@ -27,6 +28,8 @@ export default class Core extends EventEmitter {
|
|||
this.udpSocket = null
|
||||
this.shortestRTT = 0
|
||||
this.usedTcp = false
|
||||
|
||||
this.telnetClient = new Telnet()
|
||||
}
|
||||
|
||||
// Runs a single attempt with a timeout and cleans up afterward
|
||||
|
|
@ -336,4 +339,23 @@ export default class Core extends EventEmitter {
|
|||
requestPromise?.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
async telnetConnect (params) {
|
||||
await this.telnetClient.connect({
|
||||
timeout: 2000,
|
||||
execTimeout: 2000,
|
||||
host: this.options.host,
|
||||
debug: this.debugEnabled,
|
||||
...params
|
||||
})
|
||||
}
|
||||
|
||||
async telnetExecute (command) {
|
||||
return await this.telnetClient.exec(command)
|
||||
}
|
||||
|
||||
async telnetClose () {
|
||||
await this.telnetClient.end()
|
||||
await this.telnetClient.destroy()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue