Browse Source

up ws connect in https #12

lejianwen 1 year ago
parent
commit
5291270e6a
3 changed files with 18 additions and 10 deletions
  1. 1 1
      resources/web2/index.html
  2. 16 8
      resources/web2/js/dist/index.js
  3. 1 1
      resources/web2/js/dist/ljw.js

+ 1 - 1
resources/web2/index.html

@@ -32,7 +32,7 @@
32 32
     <title>RustDesk</title>
33 33
     <script src="/webclient-config/index.js"></script>
34 34
     <link rel="manifest" href="manifest.json" />
35
-    <script type="module" crossorigin src="js/dist/index.js?v=3"></script>
35
+    <script type="module" crossorigin src="js/dist/index.js?v=4"></script>
36 36
     <link rel="modulepreload" href="js/dist/vendor.js?v=0b990c6e" />
37 37
     <style>
38 38
       html,

+ 16 - 8
resources/web2/js/dist/index.js

@@ -1,4 +1,4 @@
1
-import {getServerConf} from "./ljw.js?v=3"
1
+import {getServerConf} from "./ljw.js?v=4"
2 2
 import {F as $t, J as Yt, L as Re, l as P4, m as r, P as ua, s as Xt, z as H4} from "./vendor.js?v=0b990c6e";
3 3
 
4 4
 var Zt = Object.defineProperty;
@@ -38987,22 +38987,30 @@ function S4(u = !1) {
38987 38987
 }
38988 38988
 
38989 38989
 function z4(u, e = !1, i = 0) {
38990
-    if (vn()) return "wss://" + kn(u) + "/ws/" + (e ? "relay" : "id");
38991
-    if (u.indexOf(":") > 0) {
38992
-        const o = u.split(":"), a = parseInt(o[1]);
38993
-        u = o[0] + ":" + (a + (e ? i || 3 : 2))
38990
+    const p = vn() ? "wss://" : "ws://"
38991
+    const domain = uriDomain(u)
38992
+    const uriport = uriPort(u)
38993
+    if (vn() && (!uriport || uriport == '443')){
38994
+        return p + domain + "/ws/" + (e ? "relay" : "id");
38995
+    }
38996
+
38997
+    if (uriport) {
38998
+        const a = parseInt(uriport);
38999
+        u = domain + ":" + (a + (e ? i || 3 : 2))
38994 39000
     } else u += ":" + (Pt + (e ? 3 : 2));
38995
-    return "ws://" + u
39001
+    return p + u
38996 39002
 }
38997 39003
 
38998 39004
 function vn() {
38999 39005
     return window.location.protocol === "https:"
39000 39006
 }
39001 39007
 
39002
-function kn(u) {
39008
+function uriDomain(u) {
39003 39009
     return u.indexOf(":") > 0 ? u.split(":")[0] : u
39004 39010
 }
39005
-
39011
+function uriPort(u){
39012
+    return u.indexOf(":") > 0 ? u.split(":")[1] : ''
39013
+}
39006 39014
 const $i = (u, e, i) => e && u.type == "SharedAb" ? Z(Gu([u.value, i.salt])) === Z(e) : !1,
39007 39015
     ut = (u, e) => e && u.type == "PersonalAb" ? Z(u.value) === Z(e) : !1;
39008 39016
 

+ 1 - 1
resources/web2/js/dist/ljw.js

@@ -1,6 +1,6 @@
1 1
 window._gwen = {}
2 2
 window._gwen.kv = {}
3
-const apiserver = localStorage.getItem('api-server')
3
+const apiserver = localStorage.getItem('wc-api-server')
4 4
 
5 5
 function stringToUint8Array(str) {
6 6
     var arr = [];