-
-
Notifications
You must be signed in to change notification settings - Fork 7
WIP: Online mode #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
WIP: Online mode #16
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,23 +13,46 @@ module.exports = { | |
| stopping: false, | ||
| proxyServer: null, | ||
| proxyClient: null, | ||
| settings: null, | ||
|
|
||
| setSettings(settings){ | ||
| this.settings = settings | ||
| }, | ||
|
Comment on lines
+18
to
+20
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unneeded |
||
|
|
||
| async start () { | ||
|
|
||
| async start (version, proxyPort = 25566, targetHost = 'localhost', targetPort = 25565) { | ||
| this.proxyServer = createServer({ | ||
| 'online-mode': false, | ||
| 'online-mode': this.settings.server.online_mode, | ||
| keepAlive: false, | ||
| version, | ||
| port: proxyPort | ||
| version: this.settings.version, | ||
| port: this.settings.server.proxyPort | ||
| }) | ||
|
|
||
| return new Promise((resolve, reject) => { | ||
| this.proxyServer.on('login', (client) => { | ||
| this.proxyClient = createClient({ | ||
| host: targetHost, | ||
| port: targetPort, | ||
| username: client.username, | ||
| keepAlive: false, | ||
| version | ||
| // console.log(client) | ||
| console.log('client is logging in!') | ||
| if (this.proxyClient == null) { | ||
| const playerInfo = { | ||
| host: this.settings.server.targetHost, | ||
| port: this.settings.server.targetPort, | ||
| keepAlive: false, | ||
| version: this.settings.version | ||
| } | ||
| if(this.settings.server.target_server_is_online){ | ||
| playerInfo.username = this.settings.client.username | ||
| playerInfo.password = this.settings.client.password | ||
| } | ||
|
Comment on lines
+42
to
+45
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newlines around this section |
||
| this.proxyClient = createClient(playerInfo) | ||
|
|
||
| } | ||
|
|
||
| console.log('creating a new client!') | ||
|
|
||
|
|
||
|
|
||
|
Comment on lines
+51
to
+53
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix multiple newlines |
||
| client.on('error', (error) => { | ||
| console.log(error) | ||
| }) | ||
|
|
||
| // === | ||
|
|
@@ -64,26 +87,32 @@ module.exports = { | |
| // End handlers | ||
| // === | ||
|
|
||
| this.proxyClient.on('end', () => { | ||
| this.proxyClientEnded = true | ||
| //This will call the proxyClient | ||
| client.on('end', () => { | ||
| this.clientEnded = true | ||
| console.log('ending client!') | ||
|
|
||
| if (!this.clientEnded) { | ||
| client.end() | ||
| if (!this.proxyClientEnded) { | ||
| this.proxyClient.end() | ||
| emitter.emit(this.stopping ? 'stop' : 'end') | ||
| this.stopping = false | ||
| } | ||
| }) | ||
|
|
||
| client.on('end', () => { | ||
| this.clientEnded = true | ||
|
|
||
| if (!this.proxyClientEnded) { | ||
| this.proxyClient.end() | ||
| this.proxyClient.on('end', () => { | ||
| this.proxyClientEnded = true | ||
| console.log('ending proxy client!') | ||
| if (!this.clientEnded) { | ||
| client.end() | ||
| emitter.emit(this.stopping ? 'stop' : 'end') | ||
| this.stopping = false | ||
| } | ||
| }) | ||
|
|
||
| this.proxyClient.on('session', (session) => { | ||
| // console.log(session) | ||
| }) | ||
|
Comment on lines
+112
to
+114
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this block necessary or is it just for debugging |
||
|
|
||
| // === | ||
| // Error handlers | ||
| // === | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,7 @@ fastify.post('/settings', async (request, reply) => { | |
| } | ||
|
|
||
| if (data.server.host !== config.server.host || data.server.proxyPort !== config.server.proxyPort) { | ||
| proxyInstance.setSettings(data) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| return proxyInstance.restart() | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,18 @@ | |
| <input v-model='settings.server.host' type="text" placeholder="localhost:25565" class="bg-white border-b-2 focus:border-teal-400 focus:outline-none rounded py-2 px-4 block w-full appearance-none leading-normal placeholder-gray-600 focus:shadow"> | ||
| <p class="mb-1 mt-3">Proxy port:</p> | ||
| <input v-model='settings.server.proxyPort' type="text" placeholder="25565" class="bg-white border-b-2 focus:border-teal-400 focus:outline-none rounded py-2 px-4 block w-full appearance-none leading-normal placeholder-gray-600 focus:shadow"> | ||
|
|
||
| <p class="text-xs text-gray-700 my-2">Client settings</p> | ||
| <div @click='settings.server.target_server_is_online = !settings.server.target_server_is_online' class="text-xs flex items-center pb-3 pt-4 border-b border-gray-300 group cursor-pointer select-none"> | ||
| <pre class="text-gray-900">Login with a real minecraft account? (necessary for online-mode servers): {{settings.server.target_server_is_online}}</pre> | ||
| <CheckSquareIcon class="ml-auto mr-4 text-teal-400" v-if="settings.server.target_server_is_online" size="1.5x"></CheckSquareIcon> | ||
| <SquareIcon class="ml-auto mr-4 text-gray-700 group-hover:text-teal-400" v-else size="1.5x"></SquareIcon> | ||
| </div> | ||
| <p class="mb-1 mt-3">Username (or email if you have a mojang account):</p> | ||
| <input v-model='settings.client.username' type="text" placeholder="Username" class="bg-white border-b-2 focus:border-teal-400 focus:outline-none rounded py-2 px-4 block w-full appearance-none leading-normal placeholder-gray-600 focus:shadow"> | ||
| <p class="mb-1 mt-3">Password: </p> | ||
| <input v-model='settings.client.password' type="text" placeholder="Pa$$w0rd123" class="bg-white border-b-2 focus:border-teal-400 focus:outline-none rounded py-2 px-4 block w-full appearance-none leading-normal placeholder-gray-600 focus:shadow"> | ||
|
Comment on lines
+29
to
+31
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those should be server side, clients be exposed to the web in some rare cases... |
||
|
|
||
| </div> | ||
| <div> | ||
| <div class="text-xl">Ignored packets (custom)</div> | ||
|
|
@@ -73,7 +85,7 @@ | |
| </div> | ||
| <div v-if="record.state !== 0" class="fixed top-0 left-0 h-screen w-screen z-10 flex items-center justify-center" style="background: rgba(255, 255, 255, .75)"> | ||
| <div class="absolute bottom-0 left-0 mb-5 ml-5 text-xs text-gray-700"> | ||
| Recording on {{ host }} at {{ version }} | ||
| Recording on {{ settings.server.targetHost }} at {{ settings.version }} | ||
| </div> | ||
| <div class="absolute top-0 right-0 mt-5 mr-5"> | ||
| <span v-if="record.state === -1" title="Open settings" class="cursor-pointer mr-5" @click='openSettings'> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there a way to avoid setting username/email in settings?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, its possible. But for that you need to have the
username,clientTokenandaccessToken. So that means that we would need to read thelauncher_profiles.jsonwhich is located in your.minecraftfolder.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading
.minecraftis as bad as hell. For example multimc keeps separate.minecraftper instance. I'll look into the client implementation to check if there's a way to skip the credentials. For now leave it be.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: using the username, clienttoken and accesstoken is the way when you want to skip the credentials. Underneath I used
credentialsbut it should have beenvalidationwhich makes it not important since you said that you wanted to skip the credentials and not the validation.--end edit
Not skipping the credentials is the whole point of adding an option to join online mode servers since thats how the server can validate or your account is real or not cracked?What if we make the path to the launcher_profile.json as config value so you can change it. And make the creation of a client more dynamic so you can set the config after you have started up the proxy.
Or maybe just start the webserver and start the proxy after setting the file path if you want to use online mode servers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
launcher_profile.json path as config is too much. I mean that this tool should be as simple as we can make it. Let's leave it be right now, I'll make an issue after merging it. It's not a must have to skip the credentials it's just that I don't really like an idea of putting my minecraft credentials to some tool I found on the internet. For a regular user it may (or may not) sound sketchy.
I'm totally aware that those credentials won't leak if you host it locally. But let's be honest there is a chance that someone would use it over the net/on exposed port. In theory, after enabling the
online-modesetting, inputting the credentials and saving, we could remove the username and password from the frontend entirely. Next time the settings will be opened, the password field will be filled with some random string, and username with (idk, maybe)[email protected], both inputs disabled and a text with an open padlock icon saying🔓 Change credentialsor something like that.Second option, the one I'm more convinced to is to make the credentials as a server side settings. No inputs in the frontend, just in the server config file.