add protocolValidation field to server and client options (#964)

* add protocolValidation field to server and client options

* add doc

* change option name
This commit is contained in:
Richard Dorian 2022-03-08 15:40:57 +01:00 committed by GitHub
parent ef7d0332d9
commit f7ef27dd70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View file

@ -26,7 +26,8 @@ automatically logged in and validated against mojang's auth.
* errorHandler : A way to override the default error handler for client errors. A function that takes a Client and an error.
The default kicks the client.
* hideErrors : do not display errors, default to false
* agent : a http agent that can be used to set proxy settings for yggdrasil authentication confirmation (see proxy-agent on npm)
* agent : a http agent that can be used to set proxy settings for yggdrasil authentication confirmation (see proxy-agent on npm)
* validateChannelProtocol (optional) : whether or not to enable protocol validation for custom protocols using plugin channels for the connected clients. Defaults to true
## mc.Server(version,[customPackets])
@ -116,6 +117,7 @@ Returns a `Client` instance and perform login.
* onMsaCode(data) : (optional) callback called when signing in with a microsoft account
with device code auth. `data` is an object documented [here](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code#device-authorization-response)
* id : a numeric client id used for referring to multiple clients in a server
* validateChannelProtocol (optional) : whether or not to enable protocol validation for custom protocols using plugin channels. Defaults to true
## mc.Client(isServer,version,[customPackets])

View file

@ -5,7 +5,7 @@ const debug = require('debug')('minecraft-protocol')
module.exports = function (client, options) {
const mcdata = require('minecraft-data')(options.version || require('../version').defaultVersion)
const channels = []
const proto = new ProtoDef()
const proto = new ProtoDef(options.validateChannelProtocol ?? true)
proto.addTypes(mcdata.protocol.types)
proto.addTypes(minecraft)
proto.addType('registerarr', [readDumbArr, writeDumbArr, sizeOfDumbArr])

2
src/index.d.ts vendored
View file

@ -104,6 +104,7 @@ declare module 'minecraft-protocol' {
onMsaCode?: (data: MicrosoftDeviceAuthorizationResponse) => void
id?: number
session?: SessionOption
validateChannelProtocol?: boolean
}
export class Server extends EventEmitter {
@ -147,6 +148,7 @@ declare module 'minecraft-protocol' {
errorHandler?: (client: Client, error: Error) => void
hideErrors?: boolean
agent?: Agent
validateChannelProtocol: boolean
}
export interface SerializerOptions {