Pārlūkot izejas kodu

Fixed weboscket nedpoint err on https default port

TC pushbot 5 4 gadi atpakaļ
vecāks
revīzija
fbb5f74a80

+ 1 - 1
file_system.go

@@ -1183,7 +1183,7 @@ func system_fs_handleWebSocketOpr(w http.ResponseWriter, r *http.Request) {
 
 	//Permission checking
 	if !userinfo.CanWrite(vdestFile) {
-		log.Println(vdestFile)
+		log.Println("Access denied for " + userinfo.Username + " try to access " + vdestFile)
 		w.WriteHeader(http.StatusForbidden)
 		w.Write([]byte("403 - Access Denied"))
 		return

+ 12 - 1
web/SystemAO/file_system/file_operation.html

@@ -579,7 +579,18 @@ mainloop:
                 if (location.protocol !== 'https:') {
                     protocol = "ws://";
                 }
-                wsControlEndpoint = (protocol + window.location.hostname + ":" + window.location.port + "/system/file_system/ws/fileOpr");
+
+                var port = window.location.port;
+                if (window.location.port == ""){
+                    if (location.protocol !== 'https:') {
+                        port = "80";
+                    }else{
+                        port = "443";
+                    }
+                    
+                }
+
+                wsControlEndpoint = (protocol + window.location.hostname + ":" + port + "/system/file_system/ws/fileOpr");
                 return wsControlEndpoint;
             }
 

+ 12 - 1
web/SystemAO/file_system/trashbin.html

@@ -209,7 +209,18 @@
                 if (location.protocol !== 'https:') {
                     protocol = "ws://";
                 }
-                wsControlEndpoint = (protocol + window.location.hostname + ":" + window.location.port);
+
+                var port = window.location.port;
+                if (window.location.port == ""){
+                    if (location.protocol !== 'https:') {
+                        port = "80";
+                    }else{
+                        port = "443";
+                    }
+                    
+                }
+
+                wsControlEndpoint = (protocol + window.location.hostname + ":" + port);
                 return wsControlEndpoint;
             }
             

+ 6 - 1
web/desktop.system

@@ -5500,7 +5500,12 @@
 
                 var port = window.location.port;
                 if (window.location.port == ""){
-                    port = "80";
+                    if (location.protocol !== 'https:') {
+                        port = "80";
+                    }else{
+                        port = "443";
+                    }
+                    
                 }
 
                 let uploadDir = "user:/Desktop";

+ 18 - 0
web/script/ao_module.js

@@ -883,6 +883,24 @@ class ao_module_utils{
         var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
         return time;
     }
+
+    static getWebSocketEndpoint(){
+        let protocol = "wss://";
+        if (location.protocol !== 'https:') {
+            protocol = "ws://";
+        }
+        var port = window.location.port;
+        if (window.location.port == ""){
+            if (location.protocol !== 'https:') {
+                port = "80";
+            }else{
+                port = "443";
+            }
+            
+        }
+        wsept = (protocol + window.location.hostname + ":" + port);
+        return wsept;
+    }
     
     static formatBytes(a,b=2){if(0===a)return"0 Bytes";const c=0>b?0:b,d=Math.floor(Math.log(a)/Math.log(1024));return parseFloat((a/Math.pow(1024,d)).toFixed(c))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][d]}
 }