Add internal client/server test

This commit is contained in:
extremeheat 2021-03-25 02:33:56 -04:00
commit 43ef9c9430
4 changed files with 19 additions and 9 deletions

View file

@ -17,10 +17,10 @@ module.exports = (client, server, options) => {
let pubKey = mcPubKeyToPem(getX5U(chain[0])) // the first one is client signed, allow it
let finalKey = null
console.log(pubKey)
// console.log(pubKey)
for (const token of chain) {
const decoded = JWT.verify(token, pubKey, { algorithms: 'ES384' })
console.log('Decoded', decoded)
// console.log('Decoded', decoded)
// Check if signed by Mojang key
const x5u = getX5U(token)
@ -69,7 +69,6 @@ function getX5U (token) {
}
function mcPubKeyToPem (mcPubKeyBuffer) {
console.log(mcPubKeyBuffer)
if (mcPubKeyBuffer[0] === '-') return mcPubKeyBuffer
let pem = '-----BEGIN PUBLIC KEY-----\n'
let base64PubKey = mcPubKeyBuffer.toString('base64')

View file

@ -1,6 +1,7 @@
const { ClientStatus, Connection } = require('./connection')
const fs = require('fs')
const Options = require('./options')
const debug = require('debug')('minecraft-protocol')
const { Encrypt } = require('./auth/encryption')
const Login = require('./auth/login')
@ -21,8 +22,8 @@ class Player extends Connection {
this.startQueue()
this.status = ClientStatus.Authenticating
this.inLog = (...args) => console.info('S ->', ...args)
this.outLog = (...args) => console.info('S <-', ...args)
this.inLog = (...args) => debug('S ->', ...args)
this.outLog = (...args) => debug('S <-', ...args)
}
getData () {
@ -125,10 +126,9 @@ class Player extends Connection {
throw e
}
console.log('-> S', des)
switch (des.data.name) {
case 'login':
console.log(des)
// console.log(des)
this.onLogin(des)
return
case 'client_to_server_handshake':
@ -142,7 +142,7 @@ class Player extends Connection {
this.emit('spawn')
break
default:
console.log('ignoring, unhandled')
// console.log('ignoring, unhandled')
}
this.emit(des.data.name, des.data.params)
}

View file

@ -1,4 +1,4 @@
process.env.DEBUG = 'minecraft-protocol raknet'
// process.env.DEBUG = 'minecraft-protocol raknet'
const { Server, Client } = require('../')
const { dumpPackets, hasDumps } = require('../tools/genPacketDumps')
const DataProvider = require('../data/provider')

11
test/internal.test.js Normal file
View file

@ -0,0 +1,11 @@
/* eslint-env jest */
const { timedTest } = require('./internal')
describe('internal client/server test', function () {
this.timeout(120 * 1000)
it('connects', async () => {
await timedTest()
})
})