Skip to content

Commit fea2535

Browse files
committed
fix http proxy in production
1 parent 3377ec3 commit fea2535

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

assets/mineflayer.tar.xz

11.6 KB
Binary file not shown.

src/scripts/UrlParams.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ function UrlParams (game) {
88
game.server = new URL(document.location).searchParams.get('server')
99
game.serverPort = new URL(document.location).searchParams.get('port')
1010
game.premium = new URL(document.location).searchParams.get('premium')
11-
game.proxy = {
12-
hostname: new URL(document.location).searchParams.get('proxyHost'),
13-
port: new URL(document.location).searchParams.get('proxyPort')
14-
}
11+
game.proxy = new URL(document.location).searchParams.get('proxy')
1512
let reload = false
1613
if (game.nick === '' || game.nick === null) {
1714
reload = true
@@ -33,17 +30,20 @@ function UrlParams (game) {
3330
reload = true
3431
game.premium = 'false'
3532
}
36-
if (game.proxy.hostname === '' || game.proxy.hostname === null) {
37-
reload = true
38-
game.proxy.hostname = game.production ? 'web-minecraft-proxy.herokuapp.com' : 'local'
39-
}
40-
if (game.proxy.port === '' || game.proxy.port === null) {
33+
if (game.proxy === '' || game.proxy === null) {
4134
reload = true
42-
43-
game.proxy.port = game.production ? (document.location.protocol === 'https:' ? '443' : '80') : 'local'
35+
if (game.production) {
36+
if (document.location.protocol === 'https:') {
37+
game.proxy = 'wss:web-minecraft-proxy.herokuapp.com:443'
38+
} else {
39+
game.proxy = 'ws:web-minecraft-proxy.herokuapp.com:80'
40+
}
41+
} else {
42+
game.proxy = 'local'
43+
}
4444
}
4545
if (reload) {
46-
document.location.href = `?server=${game.server}&port=${game.serverPort}&nick=${game.nick}&premium=${game.premium}&proxyHost=${game.proxy.hostname}&proxyPort=${game.proxy.port}`
46+
document.location.href = `?server=${game.server}&port=${game.serverPort}&nick=${game.nick}&premium=${game.premium}&proxy=${game.proxy}`
4747
} else {
4848
if (game.premium === 'true') {
4949
swal({

src/scripts/proxy/Proxy.worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ addEventListener('message', function (e) {
2020
case 'init':
2121
data = data[0]
2222
console.log(data)
23-
bot = self.mineflayer(data.hostname, data.port, {
23+
bot = self.mineflayer(data.connection, data.hostname, data.port, {
2424
host: data.server,
2525
port: data.serverPort,
2626
username: data.nick

src/scripts/proxy/Socket.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,21 @@ class Socket {
55
this.game = game
66
this.worker = new Proxy()
77
this.handlers = new Map()
8-
const hostname = this.game.proxy.hostname === 'local' ? document.location.hostname : this.game.proxy.hostname
9-
const port = this.game.proxy.port === 'local' ? document.location.port : this.game.proxy.port
8+
let connection, hostname, port
9+
if (this.game.proxy === 'local') {
10+
connection = document.location.protocol === 'https:' ? 'wss' : 'ws'
11+
hostname = document.location.hostname
12+
port = document.location.port
13+
} else {
14+
const pars = this.game.proxy.split(':')
15+
connection = pars[0]
16+
hostname = pars[1]
17+
port = pars[2]
18+
}
1019
this.emit('init', {
11-
hostname: hostname,
12-
port: port,
20+
connection,
21+
hostname,
22+
port,
1323
nick: this.game.nick,
1424
server: this.game.server,
1525
serverPort: this.game.serverPort,

src/scripts/rendering/DistanceBasedFog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class DistanceBasedFog {
3737
'float dist = length(u_viewPos - vViewPosition);',
3838
'float fogFactor = smoothstep(u_farnear.x, u_farnear.y, dist);',
3939
'gl_FragColor = vec4(outgoingLight, diffuseColor.a );',
40-
'gl_FragColor = mix(gl_FragColor, u_fogColor, max(0.1, fogFactor));'
40+
'gl_FragColor = mix(gl_FragColor, u_fogColor, max(0.05, fogFactor));'
4141
].join('\n')
4242
)
4343
}

0 commit comments

Comments
 (0)