@@ -401,4 +401,53 @@ async function connect (options) {
401
401
} , 2500 )
402
402
} )
403
403
}
404
- main ( )
404
+
405
+ /**
406
+ * @param {URLSearchParams } params
407
+ */
408
+ async function fromTheOutside ( params , addr ) {
409
+ const opts = { }
410
+ const dfltConfig = await ( await window . fetch ( 'config.json' ) ) . json ( )
411
+
412
+ let server , port , proxy , proxyPort
413
+
414
+ if ( address . includes ( ':' ) ) {
415
+ const s = address . split ( ':' )
416
+ server = s [ 0 ]
417
+ port = Number ( s [ 1 ] ) || 25565
418
+ } else {
419
+ server = address
420
+ port = Number ( params . get ( 'port' ) ) || 25565
421
+ }
422
+
423
+ const proxyAddr = params . get ( 'proxy' )
424
+ if ( proxyAddr ) {
425
+ const s = proxyAddr . split ( ':' )
426
+ proxy = s [ 0 ]
427
+ proxyPort = Number ( s [ 1 ] ?? 'NaN' ) || 22
428
+ } else {
429
+ proxy = dfltConfig . defaultProxy
430
+ proxyPort = ! dfltConfig . defaultProxy && ! dfltConfig . defaultProxyPort ? '' : dfltConfig . defaultProxyPort ?? 443
431
+ }
432
+
433
+ opts . server = `${ server } :${ port } `
434
+ opts . proxy = `${ proxy } :${ proxyPort } `
435
+ opts . username = params . get ( 'username' ) ?? `pviewer${ Math . floor ( Math . random ( ) * 1000 ) } `
436
+ opts . password = params . get ( 'password' ) ?? ''
437
+ opts . botVersion = params . get ( 'version' ) ?? false
438
+
439
+ console . log ( opts )
440
+
441
+ showEl ( 'loading-screen' )
442
+ removePanorama ( )
443
+ connect ( opts )
444
+ }
445
+
446
+ const params = new URLSearchParams ( window . location . search )
447
+ let address
448
+ if ( ( address = params . get ( 'address' ) ) ) {
449
+ fromTheOutside ( params , address )
450
+ } else {
451
+ showEl ( 'title-screen' )
452
+ main ( )
453
+ }
0 commit comments