mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-14 19:04:59 -05:00
allow false as beforePing callback result to ignore pings and terminate the connection (#986)
This commit is contained in:
parent
7a1d857602
commit
83f1e85480
2 changed files with 6 additions and 1 deletions
|
@ -15,6 +15,7 @@ automatically logged in and validated against mojang's auth.
|
|||
* beforePing : allow customisation of the answer to ping the server does.
|
||||
It takes a function with argument response and client, response is the default json response, and client is client who sent a ping.
|
||||
It can take as third argument a callback. If the callback is passed, the function should pass its result to the callback, if not it should return.
|
||||
If the result is `false` instead of a response object then the connection is terminated and no ping is returned to the client.
|
||||
* beforeLogin : allow customisation of client before the `success` packet is sent.
|
||||
It takes a function with argument client and should be synchronous for the server to wait for completion before continuing execution.
|
||||
* motd : default to "A Minecraft server"
|
||||
|
|
|
@ -41,7 +41,11 @@ module.exports = function (client, server, { beforePing = null, version, fallbac
|
|||
|
||||
function answerToPing (err, response) {
|
||||
if (err) return
|
||||
client.write('server_info', { response: JSON.stringify(response) })
|
||||
if (response === false) {
|
||||
client.socket.destroy()
|
||||
} else {
|
||||
client.write('server_info', { response: JSON.stringify(response) })
|
||||
}
|
||||
}
|
||||
|
||||
if (beforePing) {
|
||||
|
|
Loading…
Reference in a new issue