diff --git a/html/startPage/index.html b/html/startPage/index.html index 77431f3..272cf62 100644 --- a/html/startPage/index.html +++ b/html/startPage/index.html @@ -1,120 +1,122 @@ -
+pakkit is an advanced packet monitor proxy for Minecraft: Java Edition and Minecraft: Bedrock Edition based on + node-minecraft-protocol and ProxyPass.
+ + + diff --git a/html/startPage/script.js b/html/startPage/script.js index 5973721..cb7be9b 100644 --- a/html/startPage/script.js +++ b/html/startPage/script.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const {ipcRenderer} = require('electron') const Store = require('electron-store') const store = new Store() @@ -10,56 +10,67 @@ new customTitlebar.Titlebar({ }); */ if (!store.get('authConsentGiven')) { - document.getElementById('consent-box').style.display = 'contents' + document.getElementById('consent-row').style.display = 'flex' } let isLoading = false let connectAddress let connectPort - - let listenPort let platform let version +let onlineMode loadSetting('lastPlatform', 'platform', 'platform', 'java') let lastPlatform = platform platformChange() loadSettings(platform) -function loadSettings (newPlatform) { - loadSetting(newPlatform + 'LastVersion', 'version', 'version', '1.16.4') +function loadSettings(newPlatform) +{ + loadSetting(newPlatform + 'LastVersion', 'version', 'version', '1.18.2') loadSetting(newPlatform + 'LastConnectAddress', 'connectAddress', 'connect-address', '127.0.0.1') loadSetting(newPlatform + 'LastConnectPort', 'connectPort', 'connect-port', platform === 'java' ? '25565' : '19132') loadSetting(newPlatform + 'LastListenPort', 'listenPort', 'listen-port', platform === 'java' ? '25566' : '19142') + loadSetting(newPlatform + 'LastOnlineMode', 'onlineMode', 'auth-online', true) } -function saveSettings (thePlatform) { +function saveSettings(thePlatform) +{ store.set('lastPlatform', platform) store.set(thePlatform + 'LastVersion', version) store.set(thePlatform + 'LastConnectAddress', connectAddress) store.set(thePlatform + 'LastConnectPort', connectPort) store.set(thePlatform + 'LastListenPort', listenPort) + store.set(thePlatform + 'LastOnlineMode', onlineMode) } -function loadSetting (name, varname, elementID, defaultValue) { - if (!store.get(name)) { +function loadSetting(name, varname, elementID, defaultValue) +{ + if (!store.has(name)) { store.set(name, defaultValue) } window[varname] = store.get(name) - document.getElementById(elementID).value = window[varname] + if (varname == 'onlineMode') { + document.getElementById(elementID).checked = window[varname] + } else { + document.getElementById(elementID).value = window[varname] + } } -function updateVars () { +function updateVars() +{ connectAddress = document.getElementById('connect-address').value connectPort = document.getElementById('connect-port').value listenPort = document.getElementById('listen-port').value platform = document.getElementById('platform').value version = document.getElementById('version').value + onlineMode = document.getElementById('auth-online').checked } -function platformChange () { +function platformChange() +{ platform = document.getElementById('platform').value if (lastPlatform !== platform) { updateVars() @@ -68,15 +79,18 @@ function platformChange () { if (platform === 'bedrock') { document.getElementById('version-bedrock').style.display = 'block' document.getElementById('version').style.display = 'none' + document.getElementById('auth-row').style.display = 'none' } else { document.getElementById('version').style.display = 'block' document.getElementById('version-bedrock').style.display = 'none' + document.getElementById('auth-row').style.display = 'flex' } loadSettings(platform) lastPlatform = platform } -window.startProxy = function (event) { +window.startProxy = function (event) +{ if (isLoading) { return } @@ -104,5 +118,6 @@ window.startProxy = function (event) { listenPort: listenPort, platform: platform, version: version, + onlineMode: onlineMode, })) } diff --git a/html/startPage/style.css b/html/startPage/style.css index d28ff2e..00b0675 100644 --- a/html/startPage/style.css +++ b/html/startPage/style.css @@ -1,15 +1,44 @@ +body { + margin: 0.25em 1em; +} + h1.title { - font-family: "Lucida Console", Monaco, monospace; + font-family: "Lucida Console", Monaco, monospace; } -form { display: table; } +.form-wrapper { + list-style-type: none; + padding: 0; +} -form p { display: table-row; } +.form-row { + display: flex; + justify-content: flex-start; + padding: .25em 0; +} -form p label { display: table-cell; padding-left: 16px; padding-right: 16px; text-align: center; } +.form-row.topspacer { + padding-top: 1em; +} -form p input { display: table-cell; } +.form-row > label { + padding: .5em 1em .5em 0; + flex: 1; +} -input#start { - padding: 10px 78.5px; +.form-row > input, .form-row > select, .form-row > p, .form-row > span { + flex: 2; } + +.form-row > span { + padding: .5em 0; +} + +.form-row > span.start { + flex: auto; +} + +input#start { + max-width: 200px; + width: 100%; +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 98c818b..28156f3 100644 --- a/src/index.js +++ b/src/index.js @@ -28,8 +28,8 @@ const store = new Store() let proxy // Defined later when an option is chosen const resourcesPath = fs.existsSync(process.resourcesPath.concat('/app/')) - ? process.resourcesPath.concat('/app/') // Packaged with electron-forge - : './' // npm start + ? process.resourcesPath.concat('/app/') // Packaged with electron-forge + : './' // npm start const javaProxy = require('./proxy/java/proxy.js') @@ -84,40 +84,40 @@ function makeMenu(direction, text, id, invalid, noData) { if (!noData) { menuData.splice(2, 0, - { - label: proxy.capabilities.jsonData ? 'Copy JSON data' : 'Copy data', - click: () => { - BrowserWindow.getAllWindows()[0].send('copyPacketData', JSON.stringify({ - id: id - })) - } - } + { + label: proxy.capabilities.jsonData ? 'Copy JSON data' : 'Copy data', + click: () => { + BrowserWindow.getAllWindows()[0].send('copyPacketData', JSON.stringify({ + id: id + })) + } + } ) } if (!noData && text.split(' ')[1] === 'position' && direction === 'clientbound') { menuData.splice(3, 0, - { - label: 'Copy teleport as command', - click: () => { - BrowserWindow.getAllWindows()[0].send('copyTeleportCommand', JSON.stringify({ - id: id - })) - } - } + { + label: 'Copy teleport as command', + click: () => { + BrowserWindow.getAllWindows()[0].send('copyTeleportCommand', JSON.stringify({ + id: id + })) + } + } ) } if (proxy.capabilities.rawData) { menuData.splice(3, 0, - { - label: 'Copy hex data', - click: () => { - BrowserWindow.getAllWindows()[0].send('copyHexData', JSON.stringify({ - id: id - })) - } - } + { + label: 'Copy hex data', + click: () => { + BrowserWindow.getAllWindows()[0].send('copyHexData', JSON.stringify({ + id: id + })) + } + } ) } @@ -131,8 +131,8 @@ function createWindow() { // Create the browser window. const win = new BrowserWindow({ - height: store.get('authConsentGiven') ? 540 : 670, - width: 500, + height: store.get('authConsentGiven') ? 550 : 650, + width: 480, // resizable: false, // frame: false, webPreferences: { @@ -169,8 +169,9 @@ function createWindow() { // and load the index.html of the app. if (options.autostart) { startProxy({ - // TODO + // TODO: make online-mode working in headless via command-line parameters consent: false, + onlineMode: false, connectAddress: options.connect, connectPort: options.connectPort, listenPort: options.listenPort, @@ -227,7 +228,7 @@ function startProxy (args) { const win = BrowserWindow.getAllWindows()[0] packetHandler.init(BrowserWindow.getAllWindows()[0], ipcMain, proxy) - proxy.startProxy(args.connectAddress, args.connectPort, args.listenPort, args.version, + proxy.startProxy(args.connectAddress, args.connectPort, args.listenPort, args.version, args.onlineMode, args.consent, packetHandler.packetHandler, packetHandler.messageHandler , dataFolder, () => { win.send('updateFiltering', '') }, showAuthCode) @@ -373,4 +374,4 @@ ipcMain.on('loadScript', async (event, arg) => { }) // In this file you can include the rest of your app's specific main process -// code. You can also put them in separate files and require them here. +// code. You can also put them in separate files and require them here. \ No newline at end of file diff --git a/src/proxy/bedrock/proxy.js b/src/proxy/bedrock/proxy.js index 6b2a5ea..13d48e1 100644 --- a/src/proxy/bedrock/proxy.js +++ b/src/proxy/bedrock/proxy.js @@ -185,8 +185,8 @@ function handleError (chunk) { } } -exports.startProxy = function (passedHost, passedPort, passedListenPort, version, authConsent, passedPacketCallback, - passedMessageCallback, passedDataFolder, passedUpdateFilteringCallback, authCodeCallback) { +exports.startProxy = function (passedHost, passedPort, passedListenPort, version, onlineMode, authConsent, passedPacketCallback, + passedMessageCallback, passedDataFolder, passedUpdateFilteringCallback, authCodeCallback) { host = passedHost port = passedPort listenPort = passedListenPort @@ -233,4 +233,4 @@ exports.writeToServer = function (meta, data) { /* imports.setScriptingEnabled = function (isEnabled) { scriptingEnabled = isEnabled proxyPlayerSession.setDontSendPacketsPromise(scriptingEnabled) -} */ +} */ \ No newline at end of file diff --git a/src/proxy/java/proxy.js b/src/proxy/java/proxy.js index e931b7b..a1a513d 100644 --- a/src/proxy/java/proxy.js +++ b/src/proxy/java/proxy.js @@ -42,8 +42,8 @@ exports.capabilities = { let authWindowOpen = false -exports.startProxy = function (host, port, listenPort, version, authConsent, callback, messageCallback, dataFolder, - updateFilteringCallback, authCodeCallback) { +exports.startProxy = function (host, port, listenPort, version, onlineMode, authConsent, callback, messageCallback, dataFolder, + updateFilteringCallback, authCodeCallback) { storedCallback = callback // . cannot be in a JSON property name with electron-store @@ -119,7 +119,7 @@ exports.startProxy = function (host, port, listenPort, version, authConsent, cal keepAlive: false, version: version, profilesFolder: authConsent ? minecraftFolder : dataFolder, - // auth: 'microsoft', + auth: onlineMode ? 'microsoft' : 'offline', onMsaCode: function (data) { console.log('MSA code:', data.user_code) authWindowOpen = true @@ -133,7 +133,7 @@ exports.startProxy = function (host, port, listenPort, version, authConsent, cal authWindowOpen = false authCodeCallback('close') }) - + realServer = targetClient function getId (meta, mappings) { @@ -193,7 +193,7 @@ exports.startProxy = function (host, port, listenPort, version, authConsent, cal const bufferEqual = require('buffer-equal') targetClient.on('packet', function (data, meta, buffer, fullBuffer) { if (client.state !== states.PLAY || meta.state !== states.PLAY) { return } - + let packetValid = false try { const packetBuff = client.serializer.createPacketBuffer({ name: meta.name, params: data }) @@ -293,4 +293,4 @@ exports.writeToServer = function (meta, data, noCallback) { exports.setScriptingEnabled = function (isEnabled) { scriptingEnabled = isEnabled -} +} \ No newline at end of file