minecraft-protocol
Advanced tools
Comparing version 1.10.0 to 1.11.0
@@ -24,6 +24,4 @@ # Documentation | ||
The default kicks the client. | ||
* stream : a stream to use as connection | ||
* connect : a function taking the client as parameter and that should client.setSocket(socket) | ||
and client.emit('connect') when appropriate (see the proxy examples for an example of use) | ||
* 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) | ||
@@ -89,2 +87,6 @@ ## mc.Server(version,[customPackets]) | ||
* skipValidation : do not try to validate given session, defaults to false | ||
* stream : a stream to use as connection | ||
* connect : a function taking the client as parameter and that should client.setSocket(socket) | ||
and client.emit('connect') when appropriate (see the proxy examples for an example of use) | ||
* agent : a http agent that can be used to set proxy settings for yggdrasil authentication (see proxy-agent on npm) | ||
@@ -91,0 +93,0 @@ ## mc.Client(isServer,version,[customPackets]) |
const mc = require('minecraft-protocol') | ||
const Http = require('http') | ||
const ProxyAgent = require('proxy-agent') | ||
@@ -22,3 +23,3 @@ if (process.argv.length < 6 || process.argv.length > 8) { | ||
req.on('connect', function (res, stream) { | ||
req.on('connect', (res, stream) => { | ||
client.setSocket(stream) | ||
@@ -28,2 +29,3 @@ client.emit('connect') | ||
}, | ||
agent: new ProxyAgent({ protocol: 'http', host: proxyHost, port: proxyPort }), | ||
username: process.argv[6] ? process.argv[6] : 'echo', | ||
@@ -30,0 +32,0 @@ password: process.argv[7] |
@@ -5,4 +5,6 @@ { | ||
"private": true, | ||
"dependencies": {}, | ||
"dependencies": { | ||
"proxy-agent": "^3.1.1" | ||
}, | ||
"description": "A node-minecraft-protocol example" | ||
} |
const mc = require('minecraft-protocol') | ||
const socks = require('socks') | ||
const socks = require('socks').SocksClient | ||
const ProxyAgent = require('proxy-agent') | ||
@@ -16,11 +17,12 @@ if (process.argv.length < 6 || process.argv.length > 8) { | ||
proxy: { | ||
ipaddress: proxyHost, | ||
host: proxyHost, | ||
port: proxyPort, | ||
type: 5 | ||
}, | ||
target: { | ||
command: 'connect', | ||
destination: { | ||
host: process.argv[2], | ||
port: parseInt(process.argv[3]) | ||
} | ||
}, function (err, socket) { | ||
}, (err, info) => { | ||
if (err) { | ||
@@ -31,6 +33,7 @@ console.log(err) | ||
client.setSocket(socket) | ||
client.setSocket(info.socket) | ||
client.emit('connect') | ||
}) | ||
}, | ||
agent: new ProxyAgent({ protocol: 'socks5', host: proxyHost, port: proxyPort }), | ||
username: process.argv[6] ? process.argv[6] : 'echo', | ||
@@ -37,0 +40,0 @@ password: process.argv[7] |
@@ -6,5 +6,6 @@ { | ||
"dependencies": { | ||
"socks": "^1.1.10" | ||
"proxy-agent": "^3.1.1", | ||
"socks": "^2.3.3" | ||
}, | ||
"description": "A node-minecraft-protocol example" | ||
} |
# History | ||
## 1.11.0 | ||
* proxy support in auth (thanks @IdanHo) | ||
## 1.10.0 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "minecraft-protocol", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "Parse and serialize minecraft packets, plus authentication and encryption.", | ||
@@ -39,3 +39,3 @@ "main": "src/index.js", | ||
"minecraft-wrap": "^1.2.3", | ||
"mocha": "^6.0.0", | ||
"mocha": "^7.0.1", | ||
"power-assert": "^1.0.0", | ||
@@ -46,2 +46,3 @@ "require-self": "^0.2.1", | ||
"dependencies": { | ||
"yggdrasil": "^1.3.0", | ||
"buffer-equal": "^1.0.0", | ||
@@ -57,5 +58,4 @@ "debug": "^4.1.0", | ||
"readable-stream": "^3.0.6", | ||
"uuid-1345": "^0.99.6", | ||
"yggdrasil": "^1.1.1" | ||
"uuid-1345": "^0.99.6" | ||
} | ||
} |
@@ -1,5 +0,6 @@ | ||
const yggdrasil = require('yggdrasil')({}) | ||
const UUID = require('uuid-1345') | ||
const yggdrasil = require('yggdrasil') | ||
module.exports = function (client, options) { | ||
const yggdrasilClient = yggdrasil({ agent: options.agent }) | ||
const clientToken = options.clientToken || (options.session && options.session.clientToken) || UUID.v4().toString() | ||
@@ -26,9 +27,9 @@ const skipValidation = false || options.skipValidation | ||
if (!skipValidation) { | ||
yggdrasil.validate(options.session.accessToken, function (err) { | ||
yggdrasilClient.validate(options.session.accessToken, function (err) { | ||
if (!err) { cb(null, options.session) } else { | ||
yggdrasil.refresh(options.session.accessToken, options.session.clientToken, function (err, accessToken, data) { | ||
yggdrasilClient.refresh(options.session.accessToken, options.session.clientToken, function (err, accessToken, data) { | ||
if (!err) { | ||
cb(null, data) | ||
} else if (options.username && options.password) { | ||
yggdrasil.auth({ | ||
yggdrasilClient.auth({ | ||
user: options.username, | ||
@@ -49,3 +50,3 @@ pass: options.password, | ||
} else { | ||
yggdrasil.auth({ | ||
yggdrasilClient.auth({ | ||
user: options.username, | ||
@@ -52,0 +53,0 @@ pass: options.password, |
'use strict' | ||
const crypto = require('crypto') | ||
const yggserver = require('yggdrasil').server({}) | ||
const debug = require('debug')('minecraft-protocol') | ||
const yggdrasil = require('yggdrasil') | ||
module.exports = function (client, options) { | ||
const yggdrasilServer = yggdrasil.server({ agent: options.agent }) | ||
client.once('encryption_begin', onEncryptionKeyRequest) | ||
@@ -39,3 +40,3 @@ | ||
function joinServerRequest (cb) { | ||
yggserver.join(options.accessToken, client.session.selectedProfile.id, | ||
yggdrasilServer.join(options.accessToken, client.session.selectedProfile.id, | ||
packet.serverId, sharedSecret, packet.publicKey, cb) | ||
@@ -42,0 +43,0 @@ } |
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
import * as Stream from 'stream' | ||
import { on } from 'cluster'; | ||
import { Agent } from 'http' | ||
@@ -34,2 +34,3 @@ declare module 'minecraft-protocol' { | ||
on(event: 'end', handler: (reason: string) => void): this | ||
on(event: string, handler: (data: any, packetMeta: PacketMeta)=> unknown): this | ||
} | ||
@@ -50,2 +51,5 @@ | ||
skipValidation?: boolean | ||
stream?: Stream | ||
connect?: (client: Client) => void | ||
agent?: Agent | ||
} | ||
@@ -78,7 +82,6 @@ | ||
port?: number | ||
stream?: Stream | ||
version?: string | ||
beforePing?: (response: any, client: Client, callback?: (result: any) => any) => any | ||
connect?: (client: Client) => void | ||
errorHandler?: (client: Client, error: Error) => void | ||
agent?: Agent | ||
} | ||
@@ -144,3 +147,3 @@ | ||
export const state: States | ||
export const states: typeof States | ||
export const supportedVersions: ['1.7', '1.8', '1.9', '1.10', '1.11.2', '1.12.2', '1.13.1'] | ||
@@ -147,0 +150,0 @@ |
@@ -1,2 +0,1 @@ | ||
const yggserver = require('yggdrasil').server({}) | ||
const UUID = require('uuid-1345') | ||
@@ -7,4 +6,6 @@ const bufferEqual = require('buffer-equal') | ||
const states = require('../states') | ||
const yggdrasil = require('yggdrasil') | ||
module.exports = function (client, server, options) { | ||
const yggdrasilServer = yggdrasil.server({ agent: options.agent }) | ||
const { | ||
@@ -78,3 +79,3 @@ 'online-mode': onlineMode = true, | ||
function verifyUsername () { | ||
yggserver.hasJoined(client.username, serverId, sharedSecret, client.publicKey, function (err, profile) { | ||
yggdrasilServer.hasJoined(client.username, serverId, sharedSecret, client.publicKey, function (err, profile) { | ||
if (err) { | ||
@@ -81,0 +82,0 @@ client.end('Failed to verify username!') |
139223
3133
Updatedyggdrasil@^1.3.0