fix(important): fix connect to servers by domain
fix: finally display readable errors on proxy connect errors
This commit is contained in:
parent
7c4d34c9c2
commit
c7f3593611
5 changed files with 42 additions and 29 deletions
|
|
@ -55,7 +55,7 @@ it('Loads & renders singleplayer', () => {
|
|||
|
||||
it('Joins to server', () => {
|
||||
// visit('/?version=1.16.1')
|
||||
window.localStorage.version = '1.16.1'
|
||||
window.localStorage.version = ''
|
||||
visit()
|
||||
// todo replace with data-test
|
||||
cy.get('#title-screen').find('[data-test-id="connect-screen-button"]', { includeShadowDom: true, }).click()
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
"lit": "^2.8.0",
|
||||
"lodash": "^4.17.21",
|
||||
"minecraft-data": "^3.0.0",
|
||||
"net-browserify": "github:PrismarineJS/net-browserify",
|
||||
"net-browserify": "github:zardoy/prismarinejs-net-browserify",
|
||||
"peerjs": "^1.5.0",
|
||||
"pretty-bytes": "^6.1.1",
|
||||
"qrcode.react": "^3.1.0",
|
||||
|
|
|
|||
32
pnpm-lock.yaml
generated
32
pnpm-lock.yaml
generated
|
|
@ -79,8 +79,8 @@ importers:
|
|||
specifier: 3.45.0
|
||||
version: 3.45.0
|
||||
net-browserify:
|
||||
specifier: github:PrismarineJS/net-browserify
|
||||
version: github.com/PrismarineJS/net-browserify/0acebf76d5a14991e6b2586f83f707be5171579c
|
||||
specifier: github:zardoy/prismarinejs-net-browserify
|
||||
version: github.com/zardoy/prismarinejs-net-browserify/51262fe139a6a4856ffd4a6dc7b9145c3d6d8039
|
||||
peerjs:
|
||||
specifier: ^1.5.0
|
||||
version: 1.5.0
|
||||
|
|
@ -12157,20 +12157,6 @@ packages:
|
|||
- utf-8-validate
|
||||
dev: true
|
||||
|
||||
github.com/PrismarineJS/net-browserify/0acebf76d5a14991e6b2586f83f707be5171579c:
|
||||
resolution: {tarball: https://codeload.github.com/PrismarineJS/net-browserify/tar.gz/0acebf76d5a14991e6b2586f83f707be5171579c}
|
||||
name: net-browserify
|
||||
version: 0.2.4
|
||||
dependencies:
|
||||
body-parser: 1.20.2
|
||||
express: 4.18.2
|
||||
express-ws: 4.0.0(express@4.18.2)
|
||||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
- supports-color
|
||||
- utf-8-validate
|
||||
dev: false
|
||||
|
||||
github.com/PrismarineJS/node-process/380d0b4f4c86f1b65b216c311bf00431f314e88e:
|
||||
resolution: {tarball: https://codeload.github.com/PrismarineJS/node-process/tar.gz/380d0b4f4c86f1b65b216c311bf00431f314e88e}
|
||||
name: process
|
||||
|
|
@ -12288,6 +12274,20 @@ packages:
|
|||
dependencies:
|
||||
vec3: 0.1.8
|
||||
|
||||
github.com/zardoy/prismarinejs-net-browserify/51262fe139a6a4856ffd4a6dc7b9145c3d6d8039:
|
||||
resolution: {tarball: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/51262fe139a6a4856ffd4a6dc7b9145c3d6d8039}
|
||||
name: net-browserify
|
||||
version: 0.2.4
|
||||
dependencies:
|
||||
body-parser: 1.20.2
|
||||
express: 4.18.2
|
||||
express-ws: 4.0.0(express@4.18.2)
|
||||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
- supports-color
|
||||
- utf-8-validate
|
||||
dev: false
|
||||
|
||||
github.com/zardoy/space-squid/eec886b7a881eb40dd8efc6d48fa52e638e07693:
|
||||
resolution: {tarball: https://codeload.github.com/zardoy/space-squid/tar.gz/eec886b7a881eb40dd8efc6d48fa52e638e07693}
|
||||
name: flying-squid
|
||||
|
|
|
|||
33
src/index.ts
33
src/index.ts
|
|
@ -450,18 +450,31 @@ async function connect(connectOptions: {
|
|||
bot.emit('inject_allowed')
|
||||
bot._client.emit('connect')
|
||||
} else {
|
||||
bot._client.socket.on('connect', () => {
|
||||
console.log('TCP connection established')
|
||||
//@ts-expect-error
|
||||
bot._client.socket._ws.addEventListener('close', () => {
|
||||
console.log('TCP connection closed')
|
||||
setTimeout(() => {
|
||||
if (bot) {
|
||||
bot.emit('end', 'TCP connection closed with unknown reason')
|
||||
}
|
||||
const setupConnectHandlers = () => {
|
||||
bot._client.socket.on('connect', () => {
|
||||
console.log('TCP connection established')
|
||||
//@ts-expect-error
|
||||
bot._client.socket._ws.addEventListener('close', () => {
|
||||
console.log('TCP connection closed')
|
||||
setTimeout(() => {
|
||||
if (bot) {
|
||||
bot.emit('end', 'TCP connection closed with unknown reason')
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
// socket setup actually can be delayed because of dns lookup
|
||||
if (bot._client.socket) {
|
||||
setupConnectHandlers()
|
||||
} else {
|
||||
const originalSetSocket = bot._client.setSocket.bind(bot._client)
|
||||
bot._client.setSocket = (socket) => {
|
||||
originalSetSocket(socket)
|
||||
setupConnectHandlers()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (err) {
|
||||
handleError(err)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class LoadingErrorScreen extends LitElement {
|
|||
return html`
|
||||
<div class="dirt-bg"></div>
|
||||
|
||||
<div class="title">${this.status}${this.hasError || this.hideDots ? '' : this._loadingDots}
|
||||
<div class="title" data-test-id="loading-or-error-message">${this.status}${this.hasError || this.hideDots ? '' : this._loadingDots}
|
||||
<p class="potential-problem">${this.hasError ? guessProblem(this.status) : ''}</p>
|
||||
<p class="last-status">${this.lastStatus ? `Last status: ${this.lastStatus}` : this.lastStatus}</p></div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue