From faf8bbaf5768c8fdac460fd08f5d7e11561e5763 Mon Sep 17 00:00:00 2001
From: Heath123
- - 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')) {