diff --git a/html/startPage/index.html b/html/startPage/index.html index 7ffbb78..eff7717 100644 --- a/html/startPage/index.html +++ b/html/startPage/index.html @@ -85,6 +85,13 @@
diff --git a/html/startPage/script.js b/html/startPage/script.js index d89da3a..59825de 100644 --- a/html/startPage/script.js +++ b/html/startPage/script.js @@ -8,6 +8,10 @@ new customTitlebar.Titlebar({ backgroundColor: customTitlebar.Color.fromHex('#FFF') }); */ +if (localStorage.getItem('authConsentGiven') !== 'true') { + document.getElementById('consent-box').style.display = 'contents' +} + var isLoading = false let connectAddress @@ -87,7 +91,11 @@ window.startProxy = function (event) { connectPort = (connectPort === '') ? '25565' : connectPort listenPort = (listenPort === '') ? '25566' : listenPort } + if (document.getElementById('consent').checked) { + localStorage.setItem('authConsentGiven', 'true') + } ipcRenderer.send('startProxy', JSON.stringify({ + consent: localStorage.getItem('authConsentGiven') === 'true', connectAddress: connectAddress, connectPort: connectPort, listenPort: listenPort, diff --git a/package-lock.json b/package-lock.json index bc48296..6e3f8e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3266,10 +3266,17 @@ "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-2.70.2.tgz", "integrity": "sha512-BM7I0/pbe4dyl9lgshGf/KtIhq6aHoED+7ByRb68dJgK988UHSmwAde4k3UCX3RMKM3dr+Tprs91wAxC2YuGwQ==" }, + "minecraft-folder-path": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/minecraft-folder-path/-/minecraft-folder-path-1.1.0.tgz", + "integrity": "sha512-Qee3g4DjXIPdioUtXPXrsrIBb2CqC+dS9LD9yoWVhHEJo+c0xbzndHE0k9KWVJDo+sK3Kb106V0Xvsov9vqQMw==", + "requires": { + "user-settings-dir": "0.0.3" + } + }, "minecraft-protocol": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/minecraft-protocol/-/minecraft-protocol-1.19.0.tgz", - "integrity": "sha512-jSOPBPAWu3OJuZxmmhQ45GvW2VaGnd97KjLGvnKlVQeEfqKjeSjyG0PN16m7Dz6dQtBik+SHUep/G5rQS9sieA==", + "version": "github:Heath123/node-minecraft-protocol#9e60d055c32c656d6159e9fc93cc279ed0a23b61", + "from": "github:Heath123/node-minecraft-protocol#ph0t0shop", "requires": { "aes-js": "^3.1.2", "buffer-equal": "^1.0.0", @@ -3277,13 +3284,13 @@ "endian-toggle": "^0.0.0", "lodash.get": "^4.1.2", "lodash.merge": "^4.3.0", - "minecraft-data": "^2.69.0", + "minecraft-data": "^2.70.0", "node-rsa": "^0.4.2", "prismarine-nbt": "^1.3.0", "protodef": "^1.8.0", "readable-stream": "^3.0.6", "uuid-1345": "^1.0.1", - "yggdrasil": "^1.3.0" + "yggdrasil": "github:ph0t0shop/node-yggdrasil#patch-1" }, "dependencies": { "readable-stream": { @@ -4744,6 +4751,11 @@ "prepend-http": "^2.0.0" } }, + "user-settings-dir": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/user-settings-dir/-/user-settings-dir-0.0.3.tgz", + "integrity": "sha1-mgLCvhLNbTQldHc5v4soTIHvqXc=" + }, "username": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/username/-/username-5.1.0.tgz", @@ -4768,7 +4780,8 @@ "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true }, "uuid-1345": { "version": "1.0.2", @@ -5143,12 +5156,18 @@ } }, "yggdrasil": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/yggdrasil/-/yggdrasil-1.3.0.tgz", - "integrity": "sha512-Soeun64VJfFlqUY99GwoHwePZEhJTAvcYPbcTaH/1pqCVqEfENuUhc8rNJlngNKrVkvZOPRIJ+T8FCKtcu6BXA==", + "version": "github:ph0t0shop/node-yggdrasil#425530eeaafc83f9065cff2a1b2cde2955f1e19f", + "from": "github:ph0t0shop/node-yggdrasil#patch-1", "requires": { "phin": "^3.4.1", - "uuid": "^3.4.0" + "uuid": "^8.2.0" + }, + "dependencies": { + "uuid": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz", + "integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==" + } } } } diff --git a/package.json b/package.json index 73acf5f..bc2a530 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,8 @@ "escape-html": "^1.0.3", "md5-file": "^5.0.0", "minecraft-data": "^2.70.2", - "minecraft-protocol": "^1.19.0", + "minecraft-folder-path": "^1.1.0", + "minecraft-protocol": "github:Heath123/node-minecraft-protocol#ph0t0shop", "node-eval": "^2.0.0", "source-map-support": "^0.5.19" } diff --git a/src/index.js b/src/index.js index 49760ba..e3764cd 100644 --- a/src/index.js +++ b/src/index.js @@ -128,7 +128,7 @@ ipcMain.on('startProxy', (event, arg) => { proxy = bedrockProxy } packetHandler.init(BrowserWindow.getAllWindows()[0], ipcMain, proxy) - proxy.startProxy(ipcMessage.connectAddress, ipcMessage.connectPort, ipcMessage.listenPort, ipcMessage.version, packetHandler.packetHandler, dataFolder) + proxy.startProxy(ipcMessage.connectAddress, ipcMessage.connectPort, ipcMessage.listenPort, ipcMessage.version, ipcMessage.consent, packetHandler.packetHandler, dataFolder) BrowserWindow.getAllWindows()[0].loadFile('html/mainPage/index.html') }) diff --git a/src/proxy/bedrock/proxy.js b/src/proxy/bedrock/proxy.js index 07c750a..050c161 100644 --- a/src/proxy/bedrock/proxy.js +++ b/src/proxy/bedrock/proxy.js @@ -58,7 +58,7 @@ exports.capabilities = { jsonData: false } -exports.startProxy = function (host, port, listenPort, version, callback, dataFolder) { +exports.startProxy = function (host, port, listenPort, version, authConsent, callback, dataFolder) { storedCallback = callback fs.writeFileSync(dataFolder + '/proxypass/config.yml', ` proxy: diff --git a/src/proxy/java/proxy.js b/src/proxy/java/proxy.js index f95802a..f339818 100644 --- a/src/proxy/java/proxy.js +++ b/src/proxy/java/proxy.js @@ -1,6 +1,7 @@ // Modified from https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/examples/proxy/proxy.js const mc = require('minecraft-protocol') +const minecraftFolder = require('minecraft-folder-path') const states = mc.states @@ -17,7 +18,7 @@ exports.capabilities = { serverboundPackets: [] } -exports.startProxy = function (host, port, listenPort, version, callback, dataFolder) { +exports.startProxy = function (host, port, listenPort, version, authConsent, callback, dataFolder) { storedCallback = callback const mcdata = require('minecraft-data')(version) // Used to get packets, may remove if I find a better way toClientMappings = mcdata.protocol.play.toClient.types.packet[1][0].type[1].mappings @@ -55,12 +56,18 @@ exports.startProxy = function (host, port, listenPort, version, callback, dataFo console.log(err.stack) if (!endedTargetClient) { targetClient.end('Error') } }) + if (authConsent) { + console.log('Will attempt to use launcher_profiles.json for online mode login data') + } else { + console.warn('Consent not given to use launcher_profiles.json - online mode will not work') + } const targetClient = mc.createClient({ host: host, port: port, username: client.username, keepAlive: false, - version: version + version: version, + profilesFolder: authConsent ? minecraftFolder : undefined }) realServer = targetClient client.on('packet', function (data, meta) {