Browse Source

Removed gzip from media server and demo mode flag

Toby Chui 1 năm trước cách đây
mục cha
commit
81078f8ff9
4 tập tin đã thay đổi với 3 bổ sung37 xóa
  1. 0 6
      file_system.go
  2. 0 1
      main.flags.go
  3. 1 20
      main.go
  4. 2 10
      mediaServer.go

+ 0 - 6
file_system.go

@@ -753,12 +753,6 @@ func system_fs_handleUpload(w http.ResponseWriter, r *http.Request) {
 		r.Body = http.MaxBytesReader(w, r.Body, max_upload_size)
 	}
 
-	//Check if this is running under demo mode. If yes, reject upload
-	if *demo_mode {
-		utils.SendErrorResponse(w, "You cannot upload in demo mode")
-		return
-	}
-
 	err = r.ParseMultipartForm(int64(*upload_buf) << 20)
 	if err != nil {
 		//Filesize too big

+ 0 - 1
main.flags.go

@@ -99,7 +99,6 @@ var enable_logging = flag.Bool("logging", true, "Enable logging to file for debu
 // Flags related to running on Cloud Environment or public domain
 var allow_public_registry = flag.Bool("public_reg", false, "Enable public register interface for account creation")
 var allow_autologin = flag.Bool("allow_autologin", true, "Allow RESTFUL login redirection that allow machines like billboards to login to the system on boot")
-var demo_mode = flag.Bool("demo_mode", false, "Run the system in demo mode. All directories and database are read only.")
 var allow_package_autoInstall = flag.Bool("allow_pkg_install", true, "Allow the system to install package using Advanced Package Tool (aka apt or apt-get)")
 var allow_homepage = flag.Bool("homepage", true, "Enable user homepage. Accessible via /www/{username}/")
 

+ 1 - 20
main.go

@@ -26,7 +26,7 @@ import (
 	P.S. Try to keep this file < 300 lines
 */
 
-//Close handler, close db and clearn up everything before exit
+// Close handler, close db and clearn up everything before exit
 func SetupCloseHandler() {
 	c := make(chan os.Signal, 2)
 	signal.Notify(c, os.Interrupt, syscall.SIGTERM)
@@ -82,10 +82,6 @@ func main() {
 
 	//Handle flag assignments
 	max_upload_size = int64(*max_upload) << 20 //Parse the max upload size
-	if *demo_mode {                            //Disable hardware man under demo mode
-		enablehw := false
-		allow_hardware_management = &enablehw
-	}
 
 	//Clean up previous tmp files
 	final_tmp_directory := filepath.Clean(*tmp_directory) + "/tmp/"
@@ -109,24 +105,9 @@ func main() {
 
 	//Initiate all the static files transfer
 	fs := http.FileServer(http.Dir("./web"))
-	/*
-		if *enable_gzip {
-			//Gzip enabled. Always serve with gzip if header exists
-			//http.Handle("/", gzipmiddleware.Compress(mrouter(fs)))
-			http.Handle("/", mrouter(fs))
-		} else {
-			//Normal file server without gzip
-			http.Handle("/", mrouter(fs))
-		}
-	*/
 	//Updates 2022-09-06: Gzip handler moved inside the master router
 	http.Handle("/", mrouter(fs))
 
-	//Set database read write to ReadOnly after startup if demo mode
-	if *demo_mode {
-		sysdb.UpdateReadWriteMode(true)
-	}
-
 	//Setup handler for Ctrl +C
 	SetupCloseHandler()
 

+ 2 - 10
mediaServer.go

@@ -16,7 +16,6 @@ import (
 	"imuslab.com/arozos/mod/compatibility"
 	"imuslab.com/arozos/mod/filesystem"
 	fs "imuslab.com/arozos/mod/filesystem"
-	"imuslab.com/arozos/mod/network/gzipmiddleware"
 	"imuslab.com/arozos/mod/utils"
 )
 
@@ -34,15 +33,8 @@ PLEASE ALWAYS USE URLENCODE IN THE LINK PASSED INTO THE /media ENDPOINT
 */
 
 func mediaServer_init() {
-	if *enable_gzip {
-		http.HandleFunc("/media/", gzipmiddleware.CompressFunc(serverMedia))
-		http.HandleFunc("/media/getMime/", gzipmiddleware.CompressFunc(serveMediaMime))
-	} else {
-		http.HandleFunc("/media/", serverMedia)
-		http.HandleFunc("/media/getMime/", serveMediaMime)
-	}
-
-	//Download API always bypass gzip no matter if gzip mode is enabled
+	http.HandleFunc("/media/", serverMedia)
+	http.HandleFunc("/media/getMime/", serveMediaMime)
 	http.HandleFunc("/media/download/", serverMedia)
 }