diff --git a/html/mainPage/js/main.js b/html/mainPage/js/main.js index 10a5304..cb1b07c 100644 --- a/html/mainPage/js/main.js +++ b/html/mainPage/js/main.js @@ -368,7 +368,8 @@ function loginDialog(callback) { callback({ cancelled: false, email: document.getElementById('login-email').value, - password: document.getElementById('login-password').value + password: document.getElementById('login-password').value, + method: document.getElementById('msa').checked ? 'microsoft' : 'mojang' }) closeDialog() } @@ -377,6 +378,7 @@ function loginDialog(callback) { document.getElementById('dialog').className='dialog dialog-medium' document.getElementById('dialog').innerHTML = `
+

This server is in online mode

Please log in to your Minecraft account then reconnect.

@@ -385,6 +387,12 @@ function loginDialog(callback) {

+

+ +
diff --git a/html/mainPage/style.css b/html/mainPage/style.css index eb45ae0..41b40c6 100644 --- a/html/mainPage/style.css +++ b/html/mainPage/style.css @@ -149,9 +149,9 @@ div.dialog-small { } div.dialog-medium { - top: calc(50% - 160px); + top: calc(50% - 180px); left: calc(50% - 250px); - height: 320px; + height: 360px; width: 500px; } diff --git a/html/startPage/index.html b/html/startPage/index.html index b15e2f7..81f57a4 100644 --- a/html/startPage/index.html +++ b/html/startPage/index.html @@ -75,14 +75,14 @@

pakkit



- - Asks for login credentials in a dialog box on join instead of automatically detecting them + + Asks for login credentials in a dialog box on join instead of automatically detecting them. Also forces online mode.


diff --git a/html/startPage/script.js b/html/startPage/script.js index 4134492..931d549 100644 --- a/html/startPage/script.js +++ b/html/startPage/script.js @@ -32,6 +32,7 @@ function loadSettings (newPlatform) { 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 + 'LastManualAuth', 'manualAuth', 'manual-auth', platform === 'java' ? '25566' : '19142') } function saveSettings (thePlatform) { @@ -40,6 +41,7 @@ function saveSettings (thePlatform) { store.set(thePlatform + 'LastConnectAddress', connectAddress) store.set(thePlatform + 'LastConnectPort', connectPort) store.set(thePlatform + 'LastListenPort', listenPort) + store.set(thePlatform + 'LastManualAuth', manualAuth) } function loadSetting (name, varname, elementID, defaultValue) { @@ -54,6 +56,7 @@ function loadSetting (name, varname, elementID, defaultValue) { function updateVars () { connectAddress = document.getElementById('connect-address').value connectPort = document.getElementById('connect-port').value + manualAuth = document.getElementById('manual-auth').value listenPort = document.getElementById('listen-port').value platform = document.getElementById('platform').value version = document.getElementById('version').value @@ -101,8 +104,9 @@ window.startProxy = function (event) { consent: store.get('authConsentGiven'), connectAddress: connectAddress, connectPort: connectPort, + manualAuth: manualAuth, listenPort: listenPort, platform: platform, - version: version + version: version, })) } diff --git a/src/index.js b/src/index.js index 30216ed..ff9b386 100644 --- a/src/index.js +++ b/src/index.js @@ -163,6 +163,7 @@ function createWindow() { consent: false, connectAddress: options.connect, connectPort: options.connectPort, + manualAuth: options.manualAuth, listenPort: options.listenPort, platform: options.platform, version: options.version @@ -209,7 +210,7 @@ function requestManualAuth () { ipcMain.on('setManualAuth', (event, arg) => { const ipcMessage = JSON.parse(arg) - proxy.setManualAuth(true, ipcMessage.email, ipcMessage.password) + proxy.setManualAuth(true, ipcMessage.email, ipcMessage.password, ipcMessage.method) }) function startProxy (args) { @@ -225,7 +226,7 @@ function startProxy (args) { proxy.startProxy(args.connectAddress, args.connectPort, args.listenPort, args.version, args.consent, packetHandler.packetHandler, packetHandler.messageHandler , dataFolder, () => { win.send('updateFiltering', '') - }, requestManualAuth) + }, requestManualAuth, args.manualAuth) win.loadFile('html/mainPage/index.html') diff --git a/src/proxy/bedrock/proxy.js b/src/proxy/bedrock/proxy.js index cdf6bd8..5a8691a 100644 --- a/src/proxy/bedrock/proxy.js +++ b/src/proxy/bedrock/proxy.js @@ -186,7 +186,7 @@ function handleError (chunk) { } exports.startProxy = function (passedHost, passedPort, passedListenPort, version, authConsent, passedPacketCallback, - passedMessageCallback, passedDataFolder, passedUpdateFilteringCallback, manualAuthCallback) { + passedMessageCallback, passedDataFolder, passedUpdateFilteringCallback, manualAuthCallback, manualAuth) { host = passedHost port = passedPort listenPort = passedListenPort diff --git a/src/proxy/java/proxy.js b/src/proxy/java/proxy.js index d891474..863c807 100644 --- a/src/proxy/java/proxy.js +++ b/src/proxy/java/proxy.js @@ -43,17 +43,22 @@ exports.capabilities = { let manualAuthEnabled = false let manualAuthEmail = undefined let manualAuthPassword = undefined +let manualAuthMethod = undefined -exports.setManualAuth = function (enabled, email, password) { +let authWindowOpen = false + +exports.setManualAuth = function (enabled, email, password, method) { + authWindowOpen = false manualAuthEnabled = enabled if (enabled) { manualAuthEmail = email manualAuthPassword = password + manualAuthMethod = method } } exports.startProxy = function (host, port, listenPort, version, authConsent, callback, messageCallback, dataFolder, - updateFilteringCallback, manualAuthCallback) { + updateFilteringCallback, manualAuthCallback, manualAuth) { storedCallback = callback // . cannot be in a JSON property name with electron-store @@ -122,6 +127,10 @@ exports.startProxy = function (host, port, listenPort, version, authConsent, cal } else { console.warn('Consent not given to use launcher_profiles.json - automatic online mode will not work') } + if (manualAuth && !manualAuthEmail) { + authWindowOpen = true + manualAuthCallback() + } const clientOptions = { host: host, port: port, @@ -129,13 +138,15 @@ exports.startProxy = function (host, port, listenPort, version, authConsent, cal password: manualAuthEnabled ? manualAuthPassword : undefined, keepAlive: false, version: version, - profilesFolder: (authConsent && !manualAuthEnabled) ? minecraftFolder : dataFolder + profilesFolder: (authConsent && !manualAuthEnabled) ? minecraftFolder : dataFolder, + auth: manualAuthMethod } let targetClient = mc.createClient(clientOptions) realServer = targetClient targetClient.on('noAuth', () => { // Request manual authentication console.log('Automatic auth failed - manual auth needed') + authWindowOpen = true manualAuthCallback() }) @@ -254,6 +265,7 @@ exports.startProxy = function (host, port, listenPort, version, authConsent, cal endedTargetClient = true console.log('Connection error by server', '(' + host + ':' + port + ') ', err) console.log(err.stack) + if (authWindowOpen) return let header = 'Unable to connect to server' let message = err.message if (err.message.includes('ECONNREFUSED')) {