Bläddra i källkod

Deprecated all ioutils

TC pushbot 5 2 år sedan
förälder
incheckning
d6fe8282a9
64 ändrade filer med 491 tillägg och 541 borttagningar
  1. 1 1
      agi-doc.md
  2. 0 2
      desktop.go
  3. 8 28
      documents/common.go
  4. 5 5
      error.go
  5. 5 3
      go.mod
  6. 9 9
      go.sum
  7. 2 3
      legacy/_hybridBackup/fastwalk.go
  8. 7 7
      legacy/_hybridBackup/linker.go
  9. 2 2
      mod/agi/agi.appdata.go
  10. 21 24
      mod/agi/agi.go
  11. 4 4
      mod/agi/agi.http.go
  12. 2 2
      mod/agi/agi.serverless.go
  13. 9 11
      mod/agi/error.go
  14. 3 3
      mod/agi/handler.go
  15. 3 3
      mod/agi/systemFunc.go
  16. 6 6
      mod/agi/userFunc.go
  17. 5 5
      mod/auth/autologin.go
  18. 2 2
      mod/auth/oauth2/github.go
  19. 2 2
      mod/auth/oauth2/gitlab.go
  20. 2 2
      mod/auth/oauth2/google.go
  21. 2 2
      mod/auth/oauth2/microsoft.go
  22. 14 14
      mod/auth/register/register.go
  23. 3 4
      mod/database/database_openwrt.go
  24. 2 3
      mod/filesystem/abstractions/ftpfs/ftpfs.go
  25. 2 0
      mod/filesystem/abstractions/localfs/localfs.go
  26. 1 2
      mod/filesystem/abstractions/sftpfs/sftpfs.go
  27. 5 5
      mod/iot/hds/utils.go
  28. 12 12
      mod/iot/hdsv2/hdsv2.go
  29. 2 2
      mod/iot/hdsv2/utils.go
  30. 2 2
      mod/iot/sonoff_s2x/utils.go
  31. 6 7
      mod/modules/installer.go
  32. 3 4
      mod/network/gzipmiddleware/gzipmiddleware.go
  33. 4 4
      mod/network/netstat/netstat.go
  34. 4 4
      mod/network/network.go
  35. 4 4
      mod/network/ssdp/ssdp.go
  36. 2 3
      mod/network/webdav/file_test.go
  37. 1 2
      mod/network/webdav/webdav_test.go
  38. 14 15
      mod/network/wifi/wifi_linux.go
  39. 5 5
      mod/notification/agents/smtpn/smtpn.go
  40. 23 25
      mod/share/share.go
  41. 8 9
      mod/storage/bridge/bridge.go
  42. 5 6
      mod/storage/ftp/aofs.go
  43. 4 4
      mod/storage/sftpserver/sftpserver.go
  44. 10 11
      mod/storage/webdav/common.go
  45. 73 75
      mod/subservice/common.go
  46. 2 3
      mod/subservice/subservice.go
  47. 1 1
      mod/time/scheduler/handlers.go
  48. 5 5
      mod/time/scheduler/helper.go
  49. 3 3
      mod/time/scheduler/scheduler.go
  50. 4 4
      mod/time/timezone/timezone.go
  51. 4 4
      mod/updates/handler.go
  52. 5 5
      mod/updates/updates.go
  53. 2 2
      mod/utils/template.go
  54. 8 8
      mod/utils/utils.go
  55. 4 6
      mod/wsshell/wsshell.go
  56. 3 3
      mod/www/www.go
  57. 1 2
      storage.go
  58. 18 19
      storage.pool.go
  59. 94 96
      subservice/WsTTY/common.go
  60. 1 2
      subservice/WsTTY/main.go
  61. 10 11
      subservice/WsTTY/mod/wsshell/common.go
  62. 4 6
      subservice/WsTTY/mod/wsshell/wsshell.go
  63. 4 4
      subservice/demo/main.go
  64. 9 9
      system.go

+ 1 - 1
agi-doc.md

@@ -188,7 +188,7 @@ func agiGatewayTest(w http.ResponseWriter, r *http.Request){
         log.Println(err)
     }else{
         //Try to read the resp body
-        bodyBytes, err := ioutil.ReadAll(resp.Body)
+        bodyBytes, err := os.ReadAll(resp.Body)
         if err != nil{
             log.Println(err)
             w.Write([]byte(err.Error()))

+ 0 - 2
desktop.go

@@ -3,7 +3,6 @@ package main
 import (
 	"encoding/json"
 	"errors"
-	"fmt"
 	"log"
 	"net/http"
 	"os"
@@ -213,7 +212,6 @@ func desktop_listFiles(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
-	fmt.Println("GLOBING PATH", userDesktopRealpath)
 	files, err := fshAbs.Glob(userDesktopRealpath + "/*")
 	if err != nil {
 		utils.SendErrorResponse(w, "Desktop file load failed")

+ 8 - 28
documents/common.go

@@ -1,10 +1,7 @@
 package main
 
 import (
-	"bufio"
-	"encoding/base64"
 	"errors"
-	"io/ioutil"
 	"log"
 	"net/http"
 	"os"
@@ -30,7 +27,7 @@ func sendTextResponse(w http.ResponseWriter, msg string) {
 	w.Write([]byte(msg))
 }
 
-//Send JSON response, with an extra json header
+// Send JSON response, with an extra json header
 func sendJSONResponse(w http.ResponseWriter, json string) {
 	w.Header().Set("Content-Type", "application/json")
 	w.Write([]byte(json))
@@ -47,16 +44,15 @@ func sendOK(w http.ResponseWriter) {
 }
 
 /*
-	The paramter move function (mv)
+The paramter move function (mv)
 
-	You can find similar things in the PHP version of ArOZ Online Beta. You need to pass in
-	r (HTTP Request Object)
-	getParamter (string, aka $_GET['This string])
-
-	Will return
-	Paramter string (if any)
-	Error (if error)
+You can find similar things in the PHP version of ArOZ Online Beta. You need to pass in
+r (HTTP Request Object)
+getParamter (string, aka $_GET['This string])
 
+Will return
+Paramter string (if any)
+Error (if error)
 */
 func mv(r *http.Request, getParamter string, postMode bool) (string, error) {
 	if postMode == false {
@@ -140,22 +136,6 @@ func stringToInt64(number string) (int64, error) {
 	return i, nil
 }
 
-func int64ToString(number int64) string {
-	convedNumber := strconv.FormatInt(number, 10)
-	return convedNumber
-}
-
-func loadImageAsBase64(filepath string) (string, error) {
-	if !fileExists(filepath) {
-		return "", errors.New("File not exists")
-	}
-	f, _ := os.Open(filepath)
-	reader := bufio.NewReader(f)
-	content, _ := ioutil.ReadAll(reader)
-	encoded := base64.StdEncoding.EncodeToString(content)
-	return string(encoded), nil
-}
-
 func pushToSliceIfNotExist(slice []string, newItem string) []string {
 	itemExists := false
 	for _, item := range slice {

+ 5 - 5
error.go

@@ -6,8 +6,8 @@ package main
 */
 
 import (
-	"io/ioutil"
 	"net/http"
+	"os"
 	"strings"
 
 	fs "imuslab.com/arozos/mod/filesystem"
@@ -17,7 +17,7 @@ func errorHandleNotFound(w http.ResponseWriter, r *http.Request) {
 	notFoundPage := "./web/SystemAO/notfound.html"
 	if fs.FileExists(notFoundPage) {
 
-		notFoundTemplateBytes, err := ioutil.ReadFile(notFoundPage)
+		notFoundTemplateBytes, err := os.ReadFile(notFoundPage)
 		notFoundTemplate := string(notFoundTemplateBytes)
 		if err != nil {
 			http.NotFound(w, r)
@@ -39,7 +39,7 @@ func errorHandleInternalServerError(w http.ResponseWriter, r *http.Request) {
 	internalServerErrPage := "./web/SystemAO/internalServerError.html"
 	if fs.FileExists(internalServerErrPage) {
 
-		templateBytes, err := ioutil.ReadFile(internalServerErrPage)
+		templateBytes, err := os.ReadFile(internalServerErrPage)
 		template := string(templateBytes)
 		if err != nil {
 			http.NotFound(w, r)
@@ -61,7 +61,7 @@ func errorHandleInternalServerError(w http.ResponseWriter, r *http.Request) {
 func errorHandlePermissionDenied(w http.ResponseWriter, r *http.Request) {
 	unauthorizedPage := "./web/SystemAO/unauthorized.html"
 	if fs.FileExists(unauthorizedPage) {
-		notFoundTemplateBytes, err := ioutil.ReadFile(unauthorizedPage)
+		notFoundTemplateBytes, err := os.ReadFile(unauthorizedPage)
 		notFoundTemplate := string(notFoundTemplateBytes)
 		if err != nil {
 			http.NotFound(w, r)
@@ -78,7 +78,7 @@ func errorHandlePermissionDenied(w http.ResponseWriter, r *http.Request) {
 	}
 }
 
-//Get escape root path, example /asd/asd => ../../
+// Get escape root path, example /asd/asd => ../../
 func getRootEscapeFromCurrentPath(requestURL string) string {
 	rel := ""
 	if !strings.Contains(requestURL, "/") {

+ 5 - 3
go.mod

@@ -12,6 +12,7 @@ require (
 	github.com/go-git/go-git/v5 v5.4.2
 	github.com/go-ldap/ldap v3.0.3+incompatible
 	github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
+	github.com/google/uuid v1.3.0
 	github.com/gorilla/sessions v1.2.1
 	github.com/gorilla/websocket v1.5.0
 	github.com/grandcat/zeroconf v1.0.0
@@ -22,13 +23,16 @@ require (
 	github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
 	github.com/oliamb/cutter v0.2.2
 	github.com/oov/psd v0.0.0-20220121172623-5db5eafcecbb
+	github.com/pkg/sftp v1.13.5
 	github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f
 	github.com/satori/go.uuid v1.2.0
+	github.com/smartystreets/cproxy v1.0.3
 	github.com/spf13/afero v1.9.2
 	github.com/studio-b12/gowebdav v0.0.0-20220128162035-c7b1ff8a5e62
 	github.com/tidwall/pretty v1.2.0
 	github.com/valyala/fasttemplate v1.2.1
 	gitlab.com/NebulousLabs/go-upnp v0.0.0-20211002182029-11da932010b6
+	golang.org/x/crypto v0.3.0
 	golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094
 	golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde
 )
@@ -50,7 +54,6 @@ require (
 	github.com/go-git/go-billy/v5 v5.3.1 // indirect
 	github.com/golang/protobuf v1.5.2 // indirect
 	github.com/golang/snappy v0.0.4 // indirect
-	github.com/google/uuid v1.3.0 // indirect
 	github.com/gopherjs/gopherjs v1.17.2 // indirect
 	github.com/gorilla/securecookie v1.1.1 // indirect
 	github.com/hashicorp/errwrap v1.1.0 // indirect
@@ -65,14 +68,13 @@ require (
 	github.com/mitchellh/go-homedir v1.1.0 // indirect
 	github.com/nwaples/rardecode v1.1.3 // indirect
 	github.com/pierrec/lz4/v4 v4.1.15 // indirect
-	github.com/pkg/sftp v1.13.5 // indirect
 	github.com/sergi/go-diff v1.2.0 // indirect
+	github.com/smartystreets/logging v1.1.1 // indirect
 	github.com/ulikunitz/xz v0.5.10 // indirect
 	github.com/valyala/bytebufferpool v1.0.0 // indirect
 	github.com/xanzy/ssh-agent v0.3.2 // indirect
 	github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
 	gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40 // indirect
-	golang.org/x/crypto v0.3.0 // indirect
 	golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 // indirect
 	golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
 	golang.org/x/net v0.2.0 // indirect

+ 9 - 9
go.sum

@@ -431,7 +431,15 @@ github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic
 github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
 github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/assertions v1.1.1 h1:T/YLemO5Yp7KPzS+lVtu+WsHn8yoSwTfItdAd1r3cck=
+github.com/smartystreets/assertions v1.1.1/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
+github.com/smartystreets/cproxy v1.0.3 h1:iL5mGkAdyT37BP6G8vmrZNyNvo1ZF58Rt009Vyf5G+g=
+github.com/smartystreets/cproxy v1.0.3/go.mod h1:yQ6NuHihvM3JR157HcIZIivG3MF3UkDPtI6nrJ2730A=
 github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
+github.com/smartystreets/gunit v1.3.4 h1:iHc8Rfhb/uCOc9a3KGuD3ut22L+hLIVaqR1o5fS6zC4=
+github.com/smartystreets/gunit v1.3.4/go.mod h1:ZjM1ozSIMJlAz/ay4SG8PeKF00ckUp+zMHZXV9/bvak=
+github.com/smartystreets/logging v1.1.1 h1:4UlnyYWB7LDd216NTuP3zTVvMQZREtPrDnJbsz0zftI=
+github.com/smartystreets/logging v1.1.1/go.mod h1:NwFCEPbtiTIug+UCtTbDVjgcJNfandE3brDx0x7QEY8=
 github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
 github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
 github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw=
@@ -517,8 +525,6 @@ golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0
 golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
 golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
 golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
-golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=
-golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
 golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A=
 golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
 golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -613,8 +619,6 @@ golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su
 golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
 golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
 golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
-golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY=
-golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
 golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
 golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@@ -734,16 +738,13 @@ golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220818161305-2296e01440c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY=
-golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
 golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM=
+golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -752,7 +753,6 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
 golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
 golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
 golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=

+ 2 - 3
legacy/_hybridBackup/fastwalk.go

@@ -1,20 +1,19 @@
 package hybridBackup
 
 import (
-	"io/ioutil"
 	"os"
 	"path/filepath"
 )
 
 /*
-	High speed file walk function with no file stats
+High speed file walk function with no file stats
 */
 func fastWalk(root string, walkFunc func(string) error) error {
 	return walkDir(root, walkFunc)
 }
 
 func walkDir(dir string, walkFunc func(string) error) error {
-	files, err := ioutil.ReadDir(dir)
+	files, err := os.ReadDir(dir)
 	if err != nil {
 		return err
 	}

+ 7 - 7
legacy/_hybridBackup/linker.go

@@ -3,7 +3,7 @@ package hybridBackup
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
+	"os"
 	"path/filepath"
 	"strings"
 )
@@ -20,17 +20,17 @@ type LinkFileMap struct {
 	DeletedFiles  map[string]string
 }
 
-//Generate and write link file to disk
+// Generate and write link file to disk
 func generateLinkFile(snapshotFolder string, lf LinkFileMap) error {
 	js, err := json.MarshalIndent(lf, "", "\t")
 	if err != nil {
 		return err
 	}
 
-	return ioutil.WriteFile(filepath.Join(snapshotFolder, "snapshot.datalink"), js, 0755)
+	return os.WriteFile(filepath.Join(snapshotFolder, "snapshot.datalink"), js, 0755)
 }
 
-//Read link file and parse it into link file map
+// Read link file and parse it into link file map
 func readLinkFile(snapshotFolder string) (*LinkFileMap, error) {
 	result := LinkFileMap{
 		UnchangedFile: map[string]string{},
@@ -41,7 +41,7 @@ func readLinkFile(snapshotFolder string) (*LinkFileMap, error) {
 	expectedLinkFilePath := filepath.Join(snapshotFolder, "snapshot.datalink")
 	if fileExists(expectedLinkFilePath) {
 		//Read the content of the link file
-		content, err := ioutil.ReadFile(expectedLinkFilePath)
+		content, err := os.ReadFile(expectedLinkFilePath)
 		if err == nil {
 			//No error. Read and parse the content
 			lfContent := LinkFileMap{}
@@ -57,7 +57,7 @@ func readLinkFile(snapshotFolder string) (*LinkFileMap, error) {
 	return &result, nil
 }
 
-//Update the linker by given a snapshot name to a new one
+// Update the linker by given a snapshot name to a new one
 func updateLinkerPointer(snapshotFolder string, oldSnapshotLink string, newSnapshotLink string) error {
 	oldSnapshotLink = strings.TrimSpace(oldSnapshotLink)
 	newSnapshotLink = strings.TrimSpace(newSnapshotLink)
@@ -89,7 +89,7 @@ func updateLinkerPointer(snapshotFolder string, oldSnapshotLink string, newSnaps
 	return generateLinkFile(snapshotFolder, newLinkMap)
 }
 
-//Check if a file exists in a linkFileMap. return boolean and its linked to snapshot name
+// Check if a file exists in a linkFileMap. return boolean and its linked to snapshot name
 func (lfm *LinkFileMap) fileExists(fileRelPath string) (bool, string) {
 	val, ok := lfm.UnchangedFile[filepath.ToSlash(fileRelPath)]
 	if !ok {

+ 2 - 2
mod/agi/agi.appdata.go

@@ -3,8 +3,8 @@ package agi
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"log"
+	"os"
 	"path/filepath"
 
 	"github.com/robertkrimen/otto"
@@ -55,7 +55,7 @@ func (g *Gateway) injectAppdataLibFunctions(vm *otto.Otto, u *user.User, scriptF
 		//Check if file exists
 		targetFile := filepath.Join(webRoot, relpath)
 		if utils.FileExists(targetFile) && !filesystem.IsDir(targetFile) {
-			content, err := ioutil.ReadFile(targetFile)
+			content, err := os.ReadFile(targetFile)
 			if err != nil {
 				g.raiseError(err)
 				return otto.FalseValue()

+ 21 - 24
mod/agi/agi.go

@@ -4,7 +4,6 @@ import (
 	"encoding/json"
 	"errors"
 	"io"
-	"io/ioutil"
 	"log"
 	"net/http"
 	"os"
@@ -41,7 +40,7 @@ var (
 	errTimeout  = errors.New("errTimeout")
 )
 
-//Lib interface, require vm, user, target system file handler and the vpath of the running script
+// Lib interface, require vm, user, target system file handler and the vpath of the running script
 type AgiLibIntergface func(*otto.Otto, *user.User, *filesystem.FileSystemHandler, string) //Define the lib loader interface for AGI Libraries
 type AgiPackage struct {
 	InitRoot string //The initialization of the root for the module that request this package
@@ -131,7 +130,7 @@ func (g *Gateway) RegisterNightlyOperations() {
 func (g *Gateway) InitiateAllWebAppModules() {
 	startupScripts, _ := filepath.Glob(filepath.ToSlash(filepath.Clean(g.Option.StartupRoot)) + "/*/init.agi")
 	for _, script := range startupScripts {
-		scriptContentByte, _ := ioutil.ReadFile(script)
+		scriptContentByte, _ := os.ReadFile(script)
 		scriptContent := string(scriptContentByte)
 		log.Println("[AGI] Gateway script loaded (" + script + ")")
 		//Create a new vm for this request
@@ -182,7 +181,7 @@ func (g *Gateway) raiseError(err error) {
 	//To be implemented
 }
 
-//Check if this table is restricted table. Return true if the access is valid
+// Check if this table is restricted table. Return true if the access is valid
 func (g *Gateway) filterDBTable(tablename string, existsCheck bool) bool {
 	//Check if table is restricted
 	if utils.StringInArray(g.ReservedTables, tablename) {
@@ -199,7 +198,7 @@ func (g *Gateway) filterDBTable(tablename string, existsCheck bool) bool {
 	return true
 }
 
-//Handle request from RESTFUL API
+// Handle request from RESTFUL API
 func (g *Gateway) APIHandler(w http.ResponseWriter, r *http.Request, thisuser *user.User) {
 	scriptContent, err := utils.PostPara(r, "script")
 	if err != nil {
@@ -210,7 +209,7 @@ func (g *Gateway) APIHandler(w http.ResponseWriter, r *http.Request, thisuser *u
 	g.ExecuteAGIScript(scriptContent, nil, "", "", w, r, thisuser)
 }
 
-//Handle user requests
+// Handle user requests
 func (g *Gateway) InterfaceHandler(w http.ResponseWriter, r *http.Request, thisuser *user.User) {
 	//Get user object from the request
 	startupRoot := g.Option.StartupRoot
@@ -268,20 +267,19 @@ func (g *Gateway) InterfaceHandler(w http.ResponseWriter, r *http.Request, thisu
 	}
 
 	//Get the content of the script
-	scriptContentByte, _ := ioutil.ReadFile(scriptFile)
+	scriptContentByte, _ := os.ReadFile(scriptFile)
 	scriptContent := string(scriptContentByte)
 
 	g.ExecuteAGIScript(scriptContent, nil, scriptFile, scriptScope, w, r, thisuser)
 }
 
 /*
-	Executing the given AGI Script contents. Requires:
-	scriptContent: The AGI command sequence
-	scriptFile: The filepath of the script file
-	scriptScope: The scope of the script file, aka the module base path
-	w / r : Web request and response writer
-	thisuser: userObject
-
+Executing the given AGI Script contents. Requires:
+scriptContent: The AGI command sequence
+scriptFile: The filepath of the script file
+scriptScope: The scope of the script file, aka the module base path
+w / r : Web request and response writer
+thisuser: userObject
 */
 func (g *Gateway) ExecuteAGIScript(scriptContent string, fsh *filesystem.FileSystemHandler, scriptFile string, scriptScope string, w http.ResponseWriter, r *http.Request, thisuser *user.User) {
 	//Create a new vm for this request
@@ -294,7 +292,7 @@ func (g *Gateway) ExecuteAGIScript(scriptContent string, fsh *filesystem.FileSys
 	contentType := r.Header.Get("Content-type")
 	if strings.Contains(contentType, "application/json") {
 		//For shitty people who use Angular
-		body, _ := ioutil.ReadAll(r.Body)
+		body, _ := io.ReadAll(r.Body)
 		fields := map[string]interface{}{}
 		json.Unmarshal(body, &fields)
 		for k, v := range fields {
@@ -340,9 +338,9 @@ func (g *Gateway) ExecuteAGIScript(scriptContent string, fsh *filesystem.FileSys
 }
 
 /*
-	Execute AGI script with given user information
-	scriptFile must be realpath resolved by fsa VirtualPathToRealPath function
-	Pass in http.Request pointer to enable serverless GET / POST request
+Execute AGI script with given user information
+scriptFile must be realpath resolved by fsa VirtualPathToRealPath function
+Pass in http.Request pointer to enable serverless GET / POST request
 */
 func (g *Gateway) ExecuteAGIScriptAsUser(fsh *filesystem.FileSystemHandler, scriptFile string, targetUser *user.User, r *http.Request) (string, error) {
 	//Create a new vm for this request
@@ -407,11 +405,10 @@ func (g *Gateway) ExecuteAGIScriptAsUser(fsh *filesystem.FileSystemHandler, scri
 }
 
 /*
-
-	Get user specific tmp filepath for buffering remote file. Return filepath and closer
-	tempFilepath, closerFunction := g.getUserSpecificTempFilePath(u, "myfile.txt")
-	//Do something with it, after done
-	closerFunction();
+Get user specific tmp filepath for buffering remote file. Return filepath and closer
+tempFilepath, closerFunction := g.getUserSpecificTempFilePath(u, "myfile.txt")
+//Do something with it, after done
+closerFunction();
 */
 func (g *Gateway) getUserSpecificTempFilePath(u *user.User, filename string) (string, func()) {
 	uuid := uuid.NewV4().String()
@@ -423,7 +420,7 @@ func (g *Gateway) getUserSpecificTempFilePath(u *user.User, filename string) (st
 }
 
 /*
-	Buffer remote reosurces to local by fsh and rpath. Return buffer filepath on local device and its closer function
+Buffer remote reosurces to local by fsh and rpath. Return buffer filepath on local device and its closer function
 */
 func (g *Gateway) bufferRemoteResourcesToLocal(fsh *filesystem.FileSystemHandler, u *user.User, rpath string) (string, func(), error) {
 	buffFile, closerFunc := g.getUserSpecificTempFilePath(u, rpath)

+ 4 - 4
mod/agi/agi.http.go

@@ -5,7 +5,7 @@ import (
 	"encoding/base64"
 	"encoding/json"
 	"errors"
-	"io/ioutil"
+	"io"
 	"log"
 	"net/http"
 	"net/url"
@@ -46,7 +46,7 @@ func (g *Gateway) injectHTTPFunctions(vm *otto.Otto, u *user.User, scriptFsh *fi
 			return otto.NullValue()
 		}
 
-		bodyContent, err := ioutil.ReadAll(res.Body)
+		bodyContent, err := io.ReadAll(res.Body)
 		if err != nil {
 			return otto.NullValue()
 		}
@@ -94,7 +94,7 @@ func (g *Gateway) injectHTTPFunctions(vm *otto.Otto, u *user.User, scriptFsh *fi
 		}
 		defer resp.Body.Close()
 
-		bodyContent, err := ioutil.ReadAll(resp.Body)
+		bodyContent, err := io.ReadAll(resp.Body)
 		if err != nil {
 			return otto.NullValue()
 		}
@@ -235,7 +235,7 @@ func (g *Gateway) injectHTTPFunctions(vm *otto.Otto, u *user.User, scriptFsh *fi
 			return otto.NullValue()
 		}
 
-		bodyContent, err := ioutil.ReadAll(res.Body)
+		bodyContent, err := io.ReadAll(res.Body)
 		if err != nil {
 			return otto.NullValue()
 		}

+ 2 - 2
mod/agi/agi.serverless.go

@@ -1,7 +1,7 @@
 package agi
 
 import (
-	"io/ioutil"
+	"io"
 	"net/http"
 
 	"github.com/robertkrimen/otto"
@@ -57,7 +57,7 @@ func (g *Gateway) injectServerlessFunctions(vm *otto.Otto, scriptFile string, sc
 			return otto.NullValue()
 		}
 
-		bodyContent, err := ioutil.ReadAll(r.Body)
+		bodyContent, err := io.ReadAll(r.Body)
 		if err != nil {
 			return otto.NullValue()
 		}

+ 9 - 11
mod/agi/error.go

@@ -2,7 +2,7 @@ package agi
 
 import (
 	"net/http"
-	"io/ioutil"
+	"os"
 	"strconv"
 	"time"
 
@@ -16,19 +16,17 @@ import (
 	For any runtime error, please see the console for more information.
 */
 
-
-func (g *Gateway)RenderErrorTemplate(w http.ResponseWriter, errmsg string, scriptpath string){
-	template, _ := ioutil.ReadFile("system/agi/error.html")
+func (g *Gateway) RenderErrorTemplate(w http.ResponseWriter, errmsg string, scriptpath string) {
+	template, _ := os.ReadFile("system/agi/error.html")
 	t := fasttemplate.New(string(template), "{{", "}}")
 	s := t.ExecuteString(map[string]interface{}{
-		"error_msg":  errmsg,
-		"script_filepath":  scriptpath,
-		"timestamp":  strconv.Itoa(int(time.Now().Unix())),
-		"major_version":  g.Option.BuildVersion,
-		"minor_version":  g.Option.InternalVersion,
-		"agi_version":  AgiVersion,
+		"error_msg":       errmsg,
+		"script_filepath": scriptpath,
+		"timestamp":       strconv.Itoa(int(time.Now().Unix())),
+		"major_version":   g.Option.BuildVersion,
+		"minor_version":   g.Option.InternalVersion,
+		"agi_version":     AgiVersion,
 	})
 	w.WriteHeader(http.StatusInternalServerError)
 	w.Write([]byte(s))
 }
-

+ 3 - 3
mod/agi/handler.go

@@ -1,14 +1,14 @@
 package agi
 
 import (
-	"io/ioutil"
 	"net/http"
+	"os"
 	"path/filepath"
 
 	"imuslab.com/arozos/mod/utils"
 )
 
-//Handle AGI Exectuion Request with token, design for letting other web scripting language like php to interface with AGI
+// Handle AGI Exectuion Request with token, design for letting other web scripting language like php to interface with AGI
 func (g *Gateway) HandleAgiExecutionRequestWithToken(w http.ResponseWriter, r *http.Request) {
 	token, err := utils.GetPara(r, "token")
 	if err != nil {
@@ -51,7 +51,7 @@ func (g *Gateway) HandleAgiExecutionRequestWithToken(w http.ResponseWriter, r *h
 	}
 
 	//Get the content of the script
-	scriptContentByte, err := ioutil.ReadFile(filepath.Join("./web/", script))
+	scriptContentByte, err := os.ReadFile(filepath.Join("./web/", script))
 	if err != nil {
 		w.WriteHeader(http.StatusNotFound)
 		w.Write([]byte("404 - Script Not Found"))

+ 3 - 3
mod/agi/systemFunc.go

@@ -4,8 +4,8 @@ import (
 	"encoding/csv"
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"log"
+	"os"
 	"os/exec"
 	"path/filepath"
 	"strings"
@@ -15,7 +15,7 @@ import (
 	"imuslab.com/arozos/mod/utils"
 )
 
-//Inject aroz online custom functions into the virtual machine
+// Inject aroz online custom functions into the virtual machine
 func (g *Gateway) injectStandardLibs(vm *otto.Otto, scriptFile string, scriptScope string) {
 	//Define system core modules and definations
 	sysdb := g.Option.UserHandler.GetDatabase()
@@ -369,7 +369,7 @@ func (g *Gateway) injectStandardLibs(vm *otto.Otto, scriptFile string, scriptSco
 			}
 
 			//Run the script
-			scriptContent, _ := ioutil.ReadFile(targetScriptPath)
+			scriptContent, _ := os.ReadFile(targetScriptPath)
 			_, err = vm.Run(string(scriptContent))
 			if err != nil {
 				//Script execution failed

+ 6 - 6
mod/agi/userFunc.go

@@ -3,9 +3,9 @@ package agi
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"log"
 	"net/http"
+	"os"
 	"path/filepath"
 
 	"github.com/robertkrimen/otto"
@@ -14,7 +14,7 @@ import (
 	user "imuslab.com/arozos/mod/user"
 )
 
-//Define path translation function
+// Define path translation function
 func virtualPathToRealPath(vpath string, u *user.User) (*filesystem.FileSystemHandler, string, error) {
 	fsh, err := u.GetFileSystemHandlerFromVirtualPath(vpath)
 	if err != nil {
@@ -31,9 +31,9 @@ func realpathToVirtualpath(fsh *filesystem.FileSystemHandler, path string, u *us
 	return fsh.FileSystemAbstraction.RealPathToVirtualPath(path, u.Username)
 }
 
-//Inject user based functions into the virtual machine
-//Note that the fsh might be nil and scriptPath must be real path of script being executed
-//**Use local file system check if fsh == nil**
+// Inject user based functions into the virtual machine
+// Note that the fsh might be nil and scriptPath must be real path of script being executed
+// **Use local file system check if fsh == nil**
 func (g *Gateway) injectUserFunctions(vm *otto.Otto, fsh *filesystem.FileSystemHandler, scriptPath string, scriptScope string, u *user.User, w http.ResponseWriter, r *http.Request) {
 	username := u.Username
 	vm.Set("USERNAME", username)
@@ -283,7 +283,7 @@ func (g *Gateway) injectUserFunctions(vm *otto.Otto, fsh *filesystem.FileSystemH
 		}
 
 		//Run the script
-		scriptContent, _ := ioutil.ReadFile(targetScriptPath)
+		scriptContent, _ := os.ReadFile(targetScriptPath)
 		go func() {
 			//Create a new VM to execute the script (also for isolation)
 			vm := otto.New()

+ 5 - 5
mod/auth/autologin.go

@@ -3,9 +3,9 @@ package auth
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"log"
 	"net/http"
+	"os"
 	"strconv"
 	"strings"
 	"time"
@@ -15,7 +15,7 @@ import (
 	"imuslab.com/arozos/mod/utils"
 )
 
-//Autologin token. This token will not expire until admin removal
+// Autologin token. This token will not expire until admin removal
 type AutoLoginToken struct {
 	Owner string
 	Token string
@@ -126,7 +126,7 @@ func (a *AuthAgent) HandleAutologinTokenLogin(w http.ResponseWriter, r *http.Req
 		//This token is not valid
 		w.WriteHeader(http.StatusUnauthorized)
 		//Try to get the autologin error page.
-		errtemplate, err := ioutil.ReadFile("./system/errors/invalidToken.html")
+		errtemplate, err := os.ReadFile("./system/errors/invalidToken.html")
 		if err != nil {
 			w.Write([]byte("401 - Unauthorized (Token not valid)"))
 		} else {
@@ -140,7 +140,7 @@ func (a *AuthAgent) HandleAutologinTokenLogin(w http.ResponseWriter, r *http.Req
 	if err == nil && currentlyLoggedUsername != username {
 		//The current client already logged in with another user account!
 		w.WriteHeader(http.StatusAccepted)
-		errtemplate, err := ioutil.ReadFile("./system/errors/alreadyLoggedin.html")
+		errtemplate, err := os.ReadFile("./system/errors/alreadyLoggedin.html")
 		if err != nil {
 			w.Write([]byte("202 - Accepted (Already logged in as another user)"))
 		} else {
@@ -175,7 +175,7 @@ func (a *AuthAgent) HandleAutologinTokenLogin(w http.ResponseWriter, r *http.Req
 
 }
 
-//Check if the given autologin token is valid. Autologin token is different from session token (aka token)
+// Check if the given autologin token is valid. Autologin token is different from session token (aka token)
 func (a *AuthAgent) ValidateAutoLoginToken(token string) (bool, string) {
 	//Try to get the username from token
 	username, err := a.GetUsernameFromToken(token)

+ 2 - 2
mod/auth/oauth2/github.go

@@ -2,7 +2,7 @@ package oauth2
 
 import (
 	"encoding/json"
-	"io/ioutil"
+	"io"
 	"net/http"
 	"time"
 
@@ -78,7 +78,7 @@ func githubUserInfo(accessToken string) (string, error) {
 		return "", err
 	}
 	defer response.Body.Close()
-	contents, err := ioutil.ReadAll(response.Body)
+	contents, err := io.ReadAll(response.Body)
 	var data GithubField
 	json.Unmarshal([]byte(contents), &data)
 

+ 2 - 2
mod/auth/oauth2/gitlab.go

@@ -2,7 +2,7 @@ package oauth2
 
 import (
 	"encoding/json"
-	"io/ioutil"
+	"io"
 	"net/http"
 	"net/url"
 	"time"
@@ -73,7 +73,7 @@ func gitlabUserInfo(accessToken string, server string) (string, error) {
 		return "", err
 	}
 	defer response.Body.Close()
-	contents, err := ioutil.ReadAll(response.Body)
+	contents, err := io.ReadAll(response.Body)
 	if err != nil {
 		return "", err
 	}

+ 2 - 2
mod/auth/oauth2/google.go

@@ -2,7 +2,7 @@ package oauth2
 
 import (
 	"encoding/json"
-	"io/ioutil"
+	"io"
 	"net/http"
 
 	"golang.org/x/oauth2"
@@ -35,7 +35,7 @@ func googleUserInfo(accessToken string) (string, error) {
 		return "", err
 	}
 	defer response.Body.Close()
-	contents, err := ioutil.ReadAll(response.Body)
+	contents, err := io.ReadAll(response.Body)
 	var data GoogleField
 	json.Unmarshal([]byte(contents), &data)
 

+ 2 - 2
mod/auth/oauth2/microsoft.go

@@ -2,7 +2,7 @@ package oauth2
 
 import (
 	"encoding/json"
-	"io/ioutil"
+	"io"
 	"net/http"
 
 	"golang.org/x/oauth2"
@@ -40,7 +40,7 @@ func microsoftUserInfo(accessToken string) (string, error) {
 		return "", err
 	}
 	defer response.Body.Close()
-	contents, err := ioutil.ReadAll(response.Body)
+	contents, err := io.ReadAll(response.Body)
 	var data MicrosoftField
 	json.Unmarshal([]byte(contents), &data)
 

+ 14 - 14
mod/auth/register/register.go

@@ -12,7 +12,7 @@ import (
 	"encoding/base64"
 	"encoding/json"
 	"errors"
-	"io/ioutil"
+	"io"
 	"log"
 	"net/http"
 	"net/mail"
@@ -77,7 +77,7 @@ func NewRegisterHandler(database *db.Database, authAgent *auth.AuthAgent, ph *pe
 	}
 }
 
-//Create the default usergroup used by new users
+// Create the default usergroup used by new users
 func createDefaultGroup(ph *permission.PermissionHandler) {
 	//Default storage space: 15GB
 	ph.NewPermissionGroup("default", false, 15<<30, []string{}, "Desktop")
@@ -91,11 +91,11 @@ func (h *RegisterHandler) HandleRegisterCheck(w http.ResponseWriter, r *http.Req
 	}
 }
 
-//Handle and serve the register itnerface
+// Handle and serve the register itnerface
 func (h *RegisterHandler) HandleRegisterInterface(w http.ResponseWriter, r *http.Request) {
 	//Serve the register interface
 	if h.AllowRegistry {
-		template, err := ioutil.ReadFile("system/auth/register.system")
+		template, err := os.ReadFile("system/auth/register.system")
 		if err != nil {
 			log.Println("Template not found: system/auth/register.system")
 			http.NotFound(w, r)
@@ -126,7 +126,7 @@ func readImageFileAsBase64(src string) (string, error) {
 	}
 
 	reader := bufio.NewReader(f)
-	content, err := ioutil.ReadAll(reader)
+	content, err := io.ReadAll(reader)
 	if err != nil {
 		return "", err
 	}
@@ -134,12 +134,12 @@ func readImageFileAsBase64(src string) (string, error) {
 	return encoded, nil
 }
 
-//Get the default usergroup for this register handler
+// Get the default usergroup for this register handler
 func (h *RegisterHandler) GetDefaultUserGroup() string {
 	return h.DefaultUserGroup
 }
 
-//Set the default usergroup for this register handler
+// Set the default usergroup for this register handler
 func (h *RegisterHandler) SetDefaultUserGroup(groupname string) error {
 	if !h.permissionHandler.GroupExists(groupname) {
 		return errors.New("Group not exists")
@@ -154,12 +154,12 @@ func (h *RegisterHandler) SetDefaultUserGroup(groupname string) error {
 	return nil
 }
 
-//Toggle registry on the fly
+// Toggle registry on the fly
 func (h *RegisterHandler) SetAllowRegistry(allow bool) {
 	h.AllowRegistry = allow
 }
 
-//Clearn Register information by removing all users info whose account is no longer registered
+// Clearn Register information by removing all users info whose account is no longer registered
 func (h *RegisterHandler) CleanRegisters() {
 	entries, _ := h.database.ListTable("register")
 	for _, keypairs := range entries {
@@ -176,7 +176,7 @@ func (h *RegisterHandler) CleanRegisters() {
 	}
 }
 
-//List all User Emails, return [username(string), email(string), stillResitered(bool)]
+// List all User Emails, return [username(string), email(string), stillResitered(bool)]
 func (h *RegisterHandler) ListAllUserEmails() [][]interface{} {
 	results := [][]interface{}{}
 	entries, _ := h.database.ListTable("register")
@@ -198,7 +198,7 @@ func (h *RegisterHandler) ListAllUserEmails() [][]interface{} {
 	return results
 }
 
-//Handle the request for creating a new user
+// Handle the request for creating a new user
 func (h *RegisterHandler) HandleRegisterRequest(w http.ResponseWriter, r *http.Request) {
 	if h.AllowRegistry == false {
 		utils.SendErrorResponse(w, "Public account registry is currently closed")
@@ -271,7 +271,7 @@ func (h *RegisterHandler) HandleRegisterRequest(w http.ResponseWriter, r *http.R
 
 }
 
-//Change Email for the registered user
+// Change Email for the registered user
 func (h *RegisterHandler) HandleEmailChange(w http.ResponseWriter, r *http.Request) {
 	//Get username from request
 	username, err := h.authAgent.GetUserName(w, r)
@@ -299,7 +299,7 @@ func (h *RegisterHandler) HandleEmailChange(w http.ResponseWriter, r *http.Reque
 	h.database.Write("register", "user/email/"+username, email)
 }
 
-//Get user email by name
+// Get user email by name
 func (h *RegisterHandler) GetUserEmail(username string) (string, error) {
 	userEmail := ""
 	err := h.database.Read("register", "user/email/"+username, &userEmail)
@@ -309,7 +309,7 @@ func (h *RegisterHandler) GetUserEmail(username string) (string, error) {
 	return userEmail, nil
 }
 
-//Helper functions
+// Helper functions
 func isValidEmail(email string) bool {
 	_, err := mail.ParseAddress(email)
 	return err == nil

+ 3 - 4
mod/database/database_openwrt.go

@@ -6,7 +6,6 @@ package database
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"log"
 	"os"
 	"path/filepath"
@@ -110,7 +109,7 @@ func (d *Database) write(tableName string, key string, value interface{}) error
 
 	key = strings.ReplaceAll(key, "/", "-SLASH_SIGN-")
 
-	return ioutil.WriteFile(filepath.Join(tablePath, key+".entry"), js, 0755)
+	return os.WriteFile(filepath.Join(tablePath, key+".entry"), js, 0755)
 }
 
 func (d *Database) read(tableName string, key string, assignee interface{}) error {
@@ -122,7 +121,7 @@ func (d *Database) read(tableName string, key string, assignee interface{}) erro
 
 	tablePath := filepath.Join(d.Db.(string), filepath.Base(tableName))
 	entryPath := filepath.Join(tablePath, key+".entry")
-	content, err := ioutil.ReadFile(entryPath)
+	content, err := os.ReadFile(entryPath)
 	if err != nil {
 		return err
 	}
@@ -172,7 +171,7 @@ func (d *Database) listTable(tableName string) ([][][]byte, error) {
 
 			bkey := []byte(key)
 			bval := []byte("")
-			c, err := ioutil.ReadFile(entry)
+			c, err := os.ReadFile(entry)
 			if err != nil {
 				break
 			}

+ 2 - 3
mod/filesystem/abstractions/ftpfs/ftpfs.go

@@ -4,7 +4,6 @@ import (
 	"bytes"
 	"io"
 	"io/fs"
-	"io/ioutil"
 	"log"
 	"math/rand"
 	"os"
@@ -278,7 +277,7 @@ func (l FTPFSAbstraction) ReadFile(filename string) ([]byte, error) {
 	}
 	defer r.Close()
 
-	return ioutil.ReadAll(r)
+	return io.ReadAll(r)
 }
 func (l FTPFSAbstraction) ReadDir(filename string) ([]fs.DirEntry, error) {
 	results := []fs.DirEntry{}
@@ -360,7 +359,7 @@ func (l FTPFSAbstraction) Heartbeat() error {
 	return nil
 }
 
-//Utilities
+// Utilities
 func filterFilepath(rawpath string) string {
 	rawpath = arozfs.ToSlash(filepath.Clean(strings.TrimSpace(rawpath)))
 	if strings.HasPrefix(rawpath, "./") {

+ 2 - 0
mod/filesystem/abstractions/localfs/localfs.go

@@ -88,6 +88,7 @@ func (l LocalFileSystemAbstraction) VirtualPathToRealPath(subpath string, userna
 		return "", err
 	}
 
+	//Append the local root path to the translated path to allow read write from os package
 	rpath = filepath.Join(l.Rootpath, rpath)
 
 	//fmt.Println("VIRTUAL TO REAL", l.Rootpath, subpath, rpath)
@@ -95,6 +96,7 @@ func (l LocalFileSystemAbstraction) VirtualPathToRealPath(subpath string, userna
 }
 
 func (l LocalFileSystemAbstraction) RealPathToVirtualPath(fullpath string, username string) (string, error) {
+	//Trim the absolute / relative path before passing into generic translator
 	fullpath = arozfs.ToSlash(fullpath)
 	if strings.HasPrefix(fullpath, arozfs.ToSlash(filepath.Clean(l.Rootpath))) {
 		fullpath = strings.TrimPrefix(fullpath, arozfs.ToSlash(filepath.Clean(l.Rootpath)))

+ 1 - 2
mod/filesystem/abstractions/sftpfs/sftpfs.go

@@ -5,7 +5,6 @@ import (
 	"fmt"
 	"io"
 	"io/fs"
-	"io/ioutil"
 	"log"
 	"net/url"
 	"os"
@@ -289,7 +288,7 @@ func (s SFTPFileSystemAbstraction) ReadFile(filename string) ([]byte, error) {
 		return []byte(""), err
 	}
 
-	return ioutil.ReadAll(f)
+	return io.ReadAll(f)
 }
 func (s SFTPFileSystemAbstraction) ReadDir(filename string) ([]fs.DirEntry, error) {
 	filename = arozfs.GenericPathFilter(filename)

+ 5 - 5
mod/iot/hds/utils.go

@@ -3,7 +3,7 @@ package hds
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
+	"io"
 	"log"
 	"net"
 	"net/http"
@@ -31,7 +31,7 @@ func tryGet(url string) (string, error) {
 		return "", errors.New("Server side return status code " + strconv.Itoa(resp.StatusCode))
 	}
 
-	content, err := ioutil.ReadAll(resp.Body)
+	content, err := io.ReadAll(resp.Body)
 	if err != nil {
 		return "", err
 	}
@@ -39,7 +39,7 @@ func tryGet(url string) (string, error) {
 	return string(content), nil
 }
 
-//Check if the given ip address is HDS device, return its UUID if true
+// Check if the given ip address is HDS device, return its UUID if true
 func tryGetHDSUUID(ip string) (string, error) {
 	uuid, err := tryGet("http://" + ip + "/uuid")
 	if err != nil {
@@ -50,7 +50,7 @@ func tryGetHDSUUID(ip string) (string, error) {
 	return uuid, nil
 }
 
-//Get the HDS device info, return Device Name, Class and error if any
+// Get the HDS device info, return Device Name, Class and error if any
 func tryGetHDSInfo(ip string) (string, string, error) {
 	infoStatus, err := tryGet("http://" + ip + "/info")
 	if err != nil {
@@ -65,7 +65,7 @@ func tryGetHDSInfo(ip string) (string, string, error) {
 	return infodata[0], infodata[1], nil
 }
 
-//Get the HDS device status. Only use this when you are sure the device is an HDS device
+// Get the HDS device status. Only use this when you are sure the device is an HDS device
 func getHDSStatus(ip string) (string, error) {
 	status, err := tryGet("http://" + ip + "/status")
 	if err != nil {

+ 12 - 12
mod/iot/hdsv2/hdsv2.go

@@ -3,7 +3,7 @@ package hdsv2
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
+	"io"
 	"log"
 	"net/http"
 	"net/url"
@@ -27,7 +27,7 @@ type Handler struct {
 	lastScanTime int64
 }
 
-//Create a new HDSv2 Protocol Handler
+// Create a new HDSv2 Protocol Handler
 func NewProtocolHandler(scanner *mdns.MDNSHost) *Handler {
 	//Create a new MDNS Host
 	return &Handler{
@@ -41,7 +41,7 @@ func (h *Handler) Start() error {
 	return nil
 }
 
-//Scan the devices within the LAN
+// Scan the devices within the LAN
 func (h *Handler) Scan() ([]*iot.Device, error) {
 	foundDevices := []*iot.Device{}
 	hosts := h.scanner.Scan(3, "hds.arozos.com")
@@ -95,22 +95,22 @@ func (h *Handler) Scan() ([]*iot.Device, error) {
 	return foundDevices, nil
 }
 
-//Home Dynamic system's devices no need to established conenction before executing anything
+// Home Dynamic system's devices no need to established conenction before executing anything
 func (h *Handler) Connect(device *iot.Device, authInfo *iot.AuthInfo) error {
 	return nil
 }
 
-//Same rules also apply to disconnect
+// Same rules also apply to disconnect
 func (h *Handler) Disconnect(device *iot.Device) error {
 	return nil
 }
 
-//Get the status of the device
+// Get the status of the device
 func (h *Handler) Status(device *iot.Device) (map[string]interface{}, error) {
 	return getStatusForDevice(device)
 }
 
-//Get the icon filename of the device
+// Get the icon filename of the device
 func (h *Handler) Icon(device *iot.Device) string {
 	devModel := device.Model
 	if devModel == "Switch" {
@@ -124,7 +124,7 @@ func (h *Handler) Icon(device *iot.Device) string {
 	}
 }
 
-//Get the status of the device
+// Get the status of the device
 func (h *Handler) Execute(device *iot.Device, endpoint *iot.Endpoint, payload interface{}) (interface{}, error) {
 	var result interface{}
 
@@ -160,7 +160,7 @@ func (h *Handler) Stats() iot.Stats {
 	}
 }
 
-//Get endpoint of the given device object
+// Get endpoint of the given device object
 func getEndpoints(device *iot.Device) ([]*iot.Endpoint, error) {
 	//Parse the URL of the endpoint apis location (eps)
 	requestURL := "http://" + device.IPAddr + ":" + strconv.Itoa(device.Port) + "/eps"
@@ -170,7 +170,7 @@ func getEndpoints(device *iot.Device) ([]*iot.Endpoint, error) {
 	}
 
 	//Get the body content
-	content, err := ioutil.ReadAll(resp.Body)
+	content, err := io.ReadAll(resp.Body)
 	if err != nil {
 		return nil, err
 	}
@@ -193,7 +193,7 @@ func getEndpoints(device *iot.Device) ([]*iot.Endpoint, error) {
 
 }
 
-//Get status given the device object.
+// Get status given the device object.
 func getStatusForDevice(device *iot.Device) (map[string]interface{}, error) {
 	//Parse the URL for its status api endpoint
 	requestURL := "http://" + device.IPAddr + ":" + strconv.Itoa(device.Port) + "/status"
@@ -203,7 +203,7 @@ func getStatusForDevice(device *iot.Device) (map[string]interface{}, error) {
 	}
 
 	//Get the body content
-	content, err := ioutil.ReadAll(resp.Body)
+	content, err := io.ReadAll(resp.Body)
 	if err != nil {
 		return map[string]interface{}{}, err
 	}

+ 2 - 2
mod/iot/hdsv2/utils.go

@@ -3,7 +3,7 @@ package hdsv2
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
+	"io"
 	"net/http"
 	"strconv"
 	"time"
@@ -28,7 +28,7 @@ func tryGet(url string) (string, error) {
 		return "", errors.New("Server side return status code " + strconv.Itoa(resp.StatusCode))
 	}
 
-	content, err := ioutil.ReadAll(resp.Body)
+	content, err := io.ReadAll(resp.Body)
 	if err != nil {
 		return "", err
 	}

+ 2 - 2
mod/iot/sonoff_s2x/utils.go

@@ -3,7 +3,7 @@ package sonoff_s2x
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
+	"io"
 	"net/http"
 	"strconv"
 	"time"
@@ -28,7 +28,7 @@ func tryGet(url string) (string, error) {
 		return "", errors.New("Server side return status code " + strconv.Itoa(resp.StatusCode))
 	}
 
-	content, err := ioutil.ReadAll(resp.Body)
+	content, err := io.ReadAll(resp.Body)
 	if err != nil {
 		return "", err
 	}

+ 6 - 7
mod/modules/installer.go

@@ -3,7 +3,6 @@ package modules
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"log"
 	"net/http"
 	"os"
@@ -26,7 +25,7 @@ import (
 
 */
 
-//Install a module via selecting a zip file
+// Install a module via selecting a zip file
 func (m *ModuleHandler) InstallViaZip(realpath string, gateway *agi.Gateway) error {
 	//Check if file exists
 	if !utils.FileExists(realpath) {
@@ -75,7 +74,7 @@ func (m *ModuleHandler) InstallViaZip(realpath string, gateway *agi.Gateway) err
 	return nil
 }
 
-//Reload all modules from agi file again
+// Reload all modules from agi file again
 func (m *ModuleHandler) ReloadAllModules(gateway *agi.Gateway) error {
 	//Clear the current registered module list
 	newModuleList := []*ModuleInfo{}
@@ -92,7 +91,7 @@ func (m *ModuleHandler) ReloadAllModules(gateway *agi.Gateway) error {
 	return nil
 }
 
-//Install a module via git clone
+// Install a module via git clone
 func (m *ModuleHandler) InstallModuleViaGit(gitURL string, gateway *agi.Gateway) error {
 	//Download the module from the gitURL
 	log.Println("Starting module installation by Git cloning ", gitURL)
@@ -154,7 +153,7 @@ func (m *ModuleHandler) ActivateModuleByRoot(moduleFolder string, gateway *agi.G
 	if utils.FileExists(thisModuleEstimataedRoot) {
 		if utils.FileExists(filepath.Join(thisModuleEstimataedRoot, "init.agi")) {
 			//Load this as an module
-			startDef, err := ioutil.ReadFile(filepath.Join(thisModuleEstimataedRoot, "init.agi"))
+			startDef, err := os.ReadFile(filepath.Join(thisModuleEstimataedRoot, "init.agi"))
 			if err != nil {
 				log.Println("*Module Activator* Failed to read init.agi from " + filepath.Base(moduleFolder))
 				return errors.New("Failed to read init.agi from " + filepath.Base(moduleFolder))
@@ -175,7 +174,7 @@ func (m *ModuleHandler) ActivateModuleByRoot(moduleFolder string, gateway *agi.G
 	return nil
 }
 
-//Handle and return the information of the current installed modules
+// Handle and return the information of the current installed modules
 func (m *ModuleHandler) HandleModuleInstallationListing(w http.ResponseWriter, r *http.Request) {
 	type ModuleInstallInfo struct {
 		Name          string //Name of the module
@@ -234,7 +233,7 @@ func (m *ModuleHandler) HandleModuleInstallationListing(w http.ResponseWriter, r
 	utils.SendJSONResponse(w, string(js))
 }
 
-//Uninstall the given module
+// Uninstall the given module
 func (m *ModuleHandler) UninstallModule(moduleName string) error {
 	//Check if this module is allowed to be removed
 	var targetModuleInfo *ModuleInfo = nil

+ 3 - 4
mod/network/gzipmiddleware/gzipmiddleware.go

@@ -3,7 +3,6 @@ package gzipmiddleware
 import (
 	"compress/gzip"
 	"io"
-	"io/ioutil"
 	"net/http"
 	"strings"
 	"sync"
@@ -17,7 +16,7 @@ import (
 
 var gzPool = sync.Pool{
 	New: func() interface{} {
-		w := gzip.NewWriter(ioutil.Discard)
+		w := gzip.NewWriter(io.Discard)
 		gzip.NewWriterLevel(w, gzip.BestCompression)
 		return w
 	},
@@ -38,7 +37,7 @@ func (w *gzipResponseWriter) Write(b []byte) (int, error) {
 }
 
 /*
-	Compresstion function for http.FileServer
+Compresstion function for http.FileServer
 */
 func Compress(h http.Handler) http.Handler {
 	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -91,7 +90,7 @@ func (w gzipFuncResponseWriter) Write(b []byte) (int, error) {
 }
 
 /*
-	Compress Function for http.HandleFunc
+Compress Function for http.HandleFunc
 */
 func CompressFunc(fn http.HandlerFunc) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {

+ 4 - 4
mod/network/netstat/netstat.go

@@ -3,8 +3,8 @@ package netstat
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"net/http"
+	"os"
 	"os/exec"
 	"path/filepath"
 	"runtime"
@@ -33,7 +33,7 @@ func HandleGetNetworkInterfaceStats(w http.ResponseWriter, r *http.Request) {
 	utils.SendJSONResponse(w, string(js))
 }
 
-//Get network interface stats, return accumulated rx bits, tx bits and error if any
+// Get network interface stats, return accumulated rx bits, tx bits and error if any
 func GetNetworkInterfaceStats() (int64, int64, error) {
 	if runtime.GOOS == "windows" {
 		cmd := exec.Command("wmic", "path", "Win32_PerfRawData_Tcpip_NetworkInterface", "Get", "BytesReceivedPersec,BytesSentPersec,BytesTotalPersec")
@@ -89,7 +89,7 @@ func GetNetworkInterfaceStats() (int64, int64, error) {
 		rxSum := int64(0)
 		txSum := int64(0)
 		for _, rxByteFile := range allIfaceRxByteFiles {
-			rxBytes, err := ioutil.ReadFile(rxByteFile)
+			rxBytes, err := os.ReadFile(rxByteFile)
 			if err == nil {
 				rxBytesInt, err := strconv.Atoi(strings.TrimSpace(string(rxBytes)))
 				if err == nil {
@@ -99,7 +99,7 @@ func GetNetworkInterfaceStats() (int64, int64, error) {
 
 			//Usually the tx_bytes file is nearby it. Read it as well
 			txByteFile := filepath.Join(filepath.Dir(rxByteFile), "tx_bytes")
-			txBytes, err := ioutil.ReadFile(txByteFile)
+			txBytes, err := os.ReadFile(txByteFile)
 			if err == nil {
 				txBytesInt, err := strconv.Atoi(strings.TrimSpace(string(txBytes)))
 				if err == nil {

+ 4 - 4
mod/network/network.go

@@ -3,7 +3,7 @@ package network
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
+	"io"
 	"log"
 	"net"
 	"net/http"
@@ -115,7 +115,7 @@ func GetNICInfo(w http.ResponseWriter, r *http.Request) {
 	utils.SendJSONResponse(w, string(jsonData))
 }
 
-//Get the IP address of the NIC that can conncet to the internet
+// Get the IP address of the NIC that can conncet to the internet
 func GetOutboundIP() (net.IP, error) {
 	conn, err := net.Dial("udp", "8.8.8.8:80")
 	if err != nil {
@@ -128,7 +128,7 @@ func GetOutboundIP() (net.IP, error) {
 	return localAddr.IP, nil
 }
 
-//Get External IP address, will require 3rd party services
+// Get External IP address, will require 3rd party services
 func GetExternalIPAddr() (string, error) {
 	u, err := upnp.Discover()
 	if err != nil {
@@ -150,7 +150,7 @@ func GetExternalIPAddrVia3rdPartyServices() (string, error) {
 	}
 
 	defer resp.Body.Close()
-	body, err := ioutil.ReadAll(resp.Body)
+	body, err := io.ReadAll(resp.Body)
 	if err != nil {
 		return "", err
 	}

+ 4 - 4
mod/network/ssdp/ssdp.go

@@ -2,10 +2,10 @@ package ssdp
 
 import (
 	"errors"
-	"io/ioutil"
 	"log"
 	"net"
 	"net/http"
+	"os"
 	"os/exec"
 	"runtime"
 	"strconv"
@@ -107,10 +107,10 @@ func (a *SSDPHost) Close() {
 
 }
 
-//Serve the xml file with the given properties
+// Serve the xml file with the given properties
 func (a *SSDPHost) handleSSDP(w http.ResponseWriter, r *http.Request) {
 	//Load the ssdp xml from file
-	template, err := ioutil.ReadFile(a.SSDPTemplateFile)
+	template, err := os.ReadFile(a.SSDPTemplateFile)
 	if err != nil {
 		w.Write([]byte("SSDP.XML NOT FOUND"))
 		return
@@ -131,7 +131,7 @@ func (a *SSDPHost) handleSSDP(w http.ResponseWriter, r *http.Request) {
 	w.Write([]byte(s))
 }
 
-//Helper functions
+// Helper functions
 func getFirstNetworkInterfaceName() (string, error) {
 	if runtime.GOOS == "linux" {
 		if pkg_exists("ip") {

+ 2 - 3
mod/network/webdav/file_test.go

@@ -9,7 +9,6 @@ import (
 	"encoding/xml"
 	"fmt"
 	"io"
-	"io/ioutil"
 	"os"
 	"path"
 	"path/filepath"
@@ -518,7 +517,7 @@ func TestDir(t *testing.T) {
 		t.Skip("see golang.org/issue/11453")
 	}
 
-	td, err := ioutil.TempDir("", "webdav-test")
+	td, err := os.MkdirTemp("", "webdav-test")
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -758,7 +757,7 @@ func TestMemFile(t *testing.T) {
 			if err != nil {
 				t.Fatalf("test case #%d %q: OpenFile: %v", i, tc, err)
 			}
-			gotBytes, err := ioutil.ReadAll(g)
+			gotBytes, err := io.ReadAll(g)
 			if err != nil {
 				t.Fatalf("test case #%d %q: ReadAll: %v", i, tc, err)
 			}

+ 1 - 2
mod/network/webdav/webdav_test.go

@@ -9,7 +9,6 @@ import (
 	"errors"
 	"fmt"
 	"io"
-	"io/ioutil"
 	"net/http"
 	"net/http/httptest"
 	"net/url"
@@ -256,7 +255,7 @@ func TestFilenameEscape(t *testing.T) {
 		}
 		defer res.Body.Close()
 
-		b, err := ioutil.ReadAll(res.Body)
+		b, err := io.ReadAll(res.Body)
 		if err != nil {
 			return "", "", err
 		}

+ 14 - 15
mod/network/wifi/wifi_linux.go

@@ -1,10 +1,10 @@
+//go:build linux
 // +build linux
 
 package wifi
 
 import (
 	"errors"
-	"io/ioutil"
 	"log"
 	"os"
 	"os/exec"
@@ -17,7 +17,7 @@ import (
 	"github.com/valyala/fasttemplate"
 )
 
-//Toggle WiFi On Off. Only allow on sudo mode
+// Toggle WiFi On Off. Only allow on sudo mode
 func (w *WiFiManager) SetInterfacePower(wlanInterface string, on bool) error {
 	status := "up"
 	if on == false {
@@ -67,7 +67,7 @@ func (w *WiFiManager) GetInterfacePowerStatuts(wlanInterface string) (bool, erro
 
 }
 
-//Scan Nearby WiFi
+// Scan Nearby WiFi
 func (w *WiFiManager) ScanNearbyWiFi(interfaceName string) ([]WiFiInfo, error) {
 	rcmd := `iwlist ` + interfaceName + ` scan`
 	if w.sudo_mode {
@@ -261,7 +261,7 @@ func (w *WiFiManager) ScanNearbyWiFi(interfaceName string) ([]WiFiInfo, error) {
 	return results, nil
 }
 
-//Hack the signal level out of the nmcli bars
+// Hack the signal level out of the nmcli bars
 func (w *WiFiManager) getSignalLevelEstimation(bar string) string {
 	bar = strings.TrimSpace(bar)
 	if bar == "▂▄▆█" {
@@ -277,7 +277,7 @@ func (w *WiFiManager) getSignalLevelEstimation(bar string) string {
 	}
 }
 
-//Get all the network interfaces
+// Get all the network interfaces
 func (w *WiFiManager) GetWirelessInterfaces() ([]string, error) {
 	rcmd := `iw dev | awk '$1=="Interface"{print $2}'`
 	cmd := exec.Command("bash", "-c", rcmd)
@@ -390,7 +390,7 @@ func (w *WiFiManager) ConnectWiFi(ssid string, password string, connType string,
 	if writeToConfig == true {
 		log.Println("*WiFi* WiFi Config Generated. Writing to file...")
 		//Write config file to disk
-		err := ioutil.WriteFile("./system/network/wifi/ap/"+ssid+".config", []byte(networkConfigFile), 0755)
+		err := os.WriteFile("./system/network/wifi/ap/"+ssid+".config", []byte(networkConfigFile), 0755)
 		if err != nil {
 			log.Println(err.Error())
 			return &WiFiConnectionResult{Success: false}, err
@@ -401,7 +401,7 @@ func (w *WiFiManager) ConnectWiFi(ssid string, password string, connType string,
 
 	//Start creating the new wpa_supplicant file
 	//Get header
-	configHeader, err := ioutil.ReadFile("./system/network/wifi/wpa_supplicant.conf_template.config")
+	configHeader, err := os.ReadFile("./system/network/wifi/wpa_supplicant.conf_template.config")
 	if err != nil {
 		//Template header not found. Use default one from Raspberry Pi
 		log.Println("*WiFi* Warning! wpa_supplicant template file not found. Using default template.")
@@ -422,7 +422,7 @@ func (w *WiFiManager) ConnectWiFi(ssid string, password string, connType string,
 	networks := []string{}
 
 	for _, configFile := range networksConfigs {
-		thisNetworkConfig, err := ioutil.ReadFile(configFile)
+		thisNetworkConfig, err := os.ReadFile(configFile)
 		if err != nil {
 			log.Println("*WiFi* Failed to read Network Config File: " + configFile)
 			continue
@@ -449,7 +449,7 @@ func (w *WiFiManager) ConnectWiFi(ssid string, password string, connType string,
 	})
 
 	//Try to write the new config to wpa_supplicant
-	err = ioutil.WriteFile(w.wpa_supplicant_path, []byte(newconfig), 0777)
+	err = os.WriteFile(w.wpa_supplicant_path, []byte(newconfig), 0777)
 	if err != nil {
 		log.Println("*WiFi* Failed to update wpa_supplicant config, are you sure you have access permission to that file?")
 		return &WiFiConnectionResult{Success: false}, err
@@ -462,8 +462,8 @@ func (w *WiFiManager) ConnectWiFi(ssid string, password string, connType string,
 	out, err := cmd.CombinedOutput()
 	if err != nil {
 		//Maybe the user forgot to set the flag. Try auto detect.
-		autoDetectedWIface, err := w.GetWirelessInterfaces();
-		if err != nil || len(autoDetectedWIface) == 0{
+		autoDetectedWIface, err := w.GetWirelessInterfaces()
+		if err != nil || len(autoDetectedWIface) == 0 {
 			log.Println("failed to restart network: " + string(out))
 			return &WiFiConnectionResult{Success: false}, err
 		}
@@ -477,7 +477,6 @@ func (w *WiFiManager) ConnectWiFi(ssid string, password string, connType string,
 			return &WiFiConnectionResult{Success: false}, err
 		}
 
-		
 	}
 
 	log.Println("*WiFi* Trying to connect new AP")
@@ -505,8 +504,8 @@ func (w *WiFiManager) ConnectWiFi(ssid string, password string, connType string,
 
 }
 
-//Get the current connected wifi, return ESSID, wifi interface name and error if any
-//Return ESSID, interface and error
+// Get the current connected wifi, return ESSID, wifi interface name and error if any
+// Return ESSID, interface and error
 func (w *WiFiManager) GetConnectedWiFi() (string, string, error) {
 	cmd := exec.Command("iwgetid")
 	out, err := cmd.CombinedOutput()
@@ -626,7 +625,7 @@ func (w *WiFiManager) RemoveWifi(ssid string) error {
 	return nil
 }
 
-//Helper functions
+// Helper functions
 func fileInDir(filesourcepath string, directory string) bool {
 	filepathAbs, err := filepath.Abs(filesourcepath)
 	if err != nil {

+ 5 - 5
mod/notification/agents/smtpn/smtpn.go

@@ -11,9 +11,9 @@ package smtpn
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"log"
 	"net/smtp"
+	"os"
 	"strconv"
 	"time"
 
@@ -32,7 +32,7 @@ type Agent struct {
 }
 
 func NewSMTPNotificationAgent(hostname string, configFile string, usernameToEmailFunction func(string) (string, error)) (*Agent, error) {
-	config, err := ioutil.ReadFile(configFile)
+	config, err := os.ReadFile(configFile)
 
 	if err != nil {
 		return nil, errors.New("Unable to load config from file: " + err.Error())
@@ -51,7 +51,7 @@ func NewSMTPNotificationAgent(hostname string, configFile string, usernameToEmai
 
 }
 
-//Generate an empty config filepath
+// Generate an empty config filepath
 func GenerateEmptyConfigFile(configFilepath string) error {
 	demoConfig := Agent{}
 	//Stringify the empty struct
@@ -61,7 +61,7 @@ func GenerateEmptyConfigFile(configFilepath string) error {
 	}
 
 	//Write to file
-	err = ioutil.WriteFile(configFilepath, js, 0775)
+	err = os.WriteFile(configFilepath, js, 0775)
 	return err
 
 }
@@ -104,7 +104,7 @@ func (a Agent) ConsumerNotification(incomingNotification *notification.Notificat
 		thisEmail := thisEntry[1]
 
 		//Load email template
-		template, _ := ioutil.ReadFile("system/www/smtpn.html")
+		template, _ := os.ReadFile("system/www/smtpn.html")
 		t := fasttemplate.New(string(template), "{{", "}}")
 		s := t.ExecuteString(map[string]interface{}{
 			"receiver":  "Hello " + thisUser + ",",

+ 23 - 25
mod/share/share.go

@@ -17,7 +17,6 @@ import (
 	"image/jpeg"
 	"io"
 	"io/fs"
-	"io/ioutil"
 	"log"
 	"math"
 	"mime"
@@ -56,7 +55,7 @@ type Manager struct {
 	options Options
 }
 
-//Create a new Share Manager
+// Create a new Share Manager
 func NewShareManager(options Options) *Manager {
 	//Return a new manager object
 	return &Manager{
@@ -94,7 +93,7 @@ func (s *Manager) HandleOPGServing(w http.ResponseWriter, r *http.Request, share
 	draw.Draw(resultopg, base.Bounds(), base, image.Point{0, 0}, draw.Src)
 
 	//Append filename to the image
-	fontBytes, err := ioutil.ReadFile("./system/share/fonts/TaipeiSansTCBeta-Light.ttf")
+	fontBytes, err := os.ReadFile("./system/share/fonts/TaipeiSansTCBeta-Light.ttf")
 	if err != nil {
 		fmt.Println("[share/opg] " + err.Error())
 		http.NotFound(w, r)
@@ -261,7 +260,7 @@ func (s *Manager) HandleOPGServing(w http.ResponseWriter, r *http.Request, share
 
 }
 
-//Main function for handle share. Must be called with http.HandleFunc (No auth)
+// Main function for handle share. Must be called with http.HandleFunc (No auth)
 func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 	//New download method variables
 	subpathElements := []string{}
@@ -325,7 +324,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 			}
 		} else if len(subpathElements) == 1 {
 			//ID is missing. Serve the id input page
-			content, err := ioutil.ReadFile("system/share/index.html")
+			content, err := os.ReadFile("system/share/index.html")
 			if err != nil {
 				//Handling index not found. Is server updated correctly?
 				w.WriteHeader(http.StatusInternalServerError)
@@ -648,7 +647,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 				return
 			} else {
 				//Show download page. Do not allow serving
-				content, err := ioutil.ReadFile("./system/share/downloadPageFolder.html")
+				content, err := os.ReadFile("./system/share/downloadPageFolder.html")
 				if err != nil {
 					http.NotFound(w, r)
 					return
@@ -785,7 +784,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 				}
 			} else {
 				//Serve the download page
-				content, err := ioutil.ReadFile("./system/share/downloadPage.html")
+				content, err := os.ReadFile("./system/share/downloadPage.html")
 				if err != nil {
 					http.NotFound(w, r)
 					return
@@ -813,7 +812,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 					previewTemplate = filepath.Join(templateRoot, "default.html")
 				}
 
-				tp, err := ioutil.ReadFile(previewTemplate)
+				tp, err := os.ReadFile(previewTemplate)
 				if err != nil {
 					tp = []byte("")
 				}
@@ -863,7 +862,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 			return
 		} else {
 			//Send not found page
-			content, err := ioutil.ReadFile("./system/share/notfound.html")
+			content, err := os.ReadFile("./system/share/notfound.html")
 			if err != nil {
 				http.NotFound(w, r)
 				return
@@ -883,7 +882,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 
 }
 
-//Check if a file is shared
+// Check if a file is shared
 func (s *Manager) HandleShareCheck(w http.ResponseWriter, r *http.Request) {
 	//Get the vpath from paramters
 	vpath, err := utils.PostPara(r, "path")
@@ -932,7 +931,7 @@ func (s *Manager) HandleShareCheck(w http.ResponseWriter, r *http.Request) {
 
 }
 
-//Create new share from the given path
+// Create new share from the given path
 func (s *Manager) HandleCreateNewShare(w http.ResponseWriter, r *http.Request) {
 	//Get the vpath from paramters
 	vpath, err := utils.PostPara(r, "path")
@@ -1153,11 +1152,11 @@ func (s *Manager) HandleListAllShares(w http.ResponseWriter, r *http.Request) {
 }
 
 /*
-	Check if the user can open the share in File Manager
+Check if the user can open the share in File Manager
 
-	There are two conditions where the user can open the file in file manager
-	1. If the user is the owner of the file
-	2. If the user is NOT the owner of the file but the target fsh is public accessible and in user's fsh list
+There are two conditions where the user can open the file in file manager
+1. If the user is the owner of the file
+2. If the user is NOT the owner of the file but the target fsh is public accessible and in user's fsh list
 */
 func (s *Manager) UserCanOpenShareInFileManager(share *shareEntry.ShareOption, userinfo *user.User) bool {
 	if share.Owner == userinfo.Username {
@@ -1178,7 +1177,7 @@ func (s *Manager) UserCanOpenShareInFileManager(share *shareEntry.ShareOption, u
 	return false
 }
 
-//Craete a new file or folder share
+// Craete a new file or folder share
 func (s *Manager) CreateNewShare(userinfo *user.User, srcFsh *filesystem.FileSystemHandler, vpath string) (*shareEntry.ShareOption, error) {
 	//Translate the vpath to realpath
 	return s.options.ShareEntryTable.CreateNewShare(srcFsh, vpath, userinfo.Username, userinfo.GetUserPermissionGroupNames())
@@ -1189,7 +1188,7 @@ func ServePermissionDeniedPage(w http.ResponseWriter) {
 	w.WriteHeader(http.StatusForbidden)
 	pageContent := []byte("Permissioned Denied")
 	if utils.FileExists("system/share/permissionDenied.html") {
-		content, err := ioutil.ReadFile("system/share/permissionDenied.html")
+		content, err := os.ReadFile("system/share/permissionDenied.html")
 		if err == nil {
 			pageContent = content
 		}
@@ -1198,12 +1197,11 @@ func ServePermissionDeniedPage(w http.ResponseWriter) {
 }
 
 /*
-	Validate Share Mode string
-	will return
-	1. bool => Is valid
-	2. permission type: {basic / groups / users}
-	3. mode string
-
+Validate Share Mode string
+will return
+1. bool => Is valid
+2. permission type: {basic / groups / users}
+3. mode string
 */
 func validateShareModes(mode string) (bool, string, []string) {
 	// user:a,b,c,d
@@ -1285,7 +1283,7 @@ func (s *Manager) GetPathHashFromShare(thisShareOption *shareEntry.ShareOption)
 	return shareEntry.GetPathHash(fsh, vpath, userinfo.Username)
 }
 
-//Check and clear shares that its pointinf files no longe exists
+// Check and clear shares that its pointinf files no longe exists
 func (s *Manager) ValidateAndClearShares() {
 	//Iterate through all shares within the system
 	s.options.ShareEntryTable.FileToUrlMap.Range(func(k, v interface{}) bool {
@@ -1309,7 +1307,7 @@ func (s *Manager) ValidateAndClearShares() {
 
 }
 
-//Check if the user has the permission to modify this share entry
+// Check if the user has the permission to modify this share entry
 func (s *Manager) CanModifyShareEntry(userinfo *user.User, vpath string) bool {
 	shareEntry := s.GetShareObjectFromUserAndVpath(userinfo, vpath)
 	if shareEntry == nil {

+ 8 - 9
mod/storage/bridge/bridge.go

@@ -3,7 +3,6 @@ package bridge
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"os"
 )
 
@@ -30,17 +29,17 @@ func NewBridgeRecord(filename string) *Record {
 	}
 }
 
-//Read bridge record
+// Read bridge record
 func (r *Record) ReadConfig() ([]*BridgeConfig, error) {
 	result := []*BridgeConfig{}
 
 	if _, err := os.Stat(r.Filename); os.IsNotExist(err) {
 		//File not exists. Create it
 		js, _ := json.Marshal([]*BridgeConfig{})
-		ioutil.WriteFile(r.Filename, js, 0775)
+		os.WriteFile(r.Filename, js, 0775)
 	}
 
-	content, err := ioutil.ReadFile(r.Filename)
+	content, err := os.ReadFile(r.Filename)
 	if err != nil {
 		return result, err
 	}
@@ -52,7 +51,7 @@ func (r *Record) ReadConfig() ([]*BridgeConfig, error) {
 	return result, nil
 }
 
-//Append a new config into the Bridge Record
+// Append a new config into the Bridge Record
 func (r *Record) AppendToConfig(config *BridgeConfig) error {
 	currentConfigs, err := r.ReadConfig()
 	if err != nil {
@@ -73,7 +72,7 @@ func (r *Record) AppendToConfig(config *BridgeConfig) error {
 	return err
 }
 
-//Remove a given config from file
+// Remove a given config from file
 func (r *Record) RemoveFromConfig(FSHUUID string, groupOwner string) error {
 	currentConfigs, err := r.ReadConfig()
 	if err != nil {
@@ -92,7 +91,7 @@ func (r *Record) RemoveFromConfig(FSHUUID string, groupOwner string) error {
 
 }
 
-//Check if the given UUID in this pool is a bridge object
+// Check if the given UUID in this pool is a bridge object
 func (r *Record) IsBridgedFSH(FSHUUID string, groupOwner string) (bool, error) {
 	currentConfigs, err := r.ReadConfig()
 	if err != nil {
@@ -107,9 +106,9 @@ func (r *Record) IsBridgedFSH(FSHUUID string, groupOwner string) (bool, error) {
 	return false, nil
 }
 
-//Write FSHConfig to disk
+// Write FSHConfig to disk
 func (r *Record) WriteConfig(config []*BridgeConfig) error {
 	js, _ := json.MarshalIndent(config, "", " ")
-	err := ioutil.WriteFile(r.Filename, js, 0775)
+	err := os.WriteFile(r.Filename, js, 0775)
 	return err
 }

+ 5 - 6
mod/storage/ftp/aofs.go

@@ -5,7 +5,6 @@ package ftp
 
 import (
 	"errors"
-	"io/ioutil"
 	"os"
 	"path/filepath"
 	"strings"
@@ -208,8 +207,8 @@ func (a aofs) Chtimes(name string, atime time.Time, mtime time.Time) error {
 	return fsh.FileSystemAbstraction.Chtimes(rewritePath, atime, mtime)
 }
 
-//arozos adaptive functions
-//This function rewrite the path from ftp representation to real filepath on disk
+// arozos adaptive functions
+// This function rewrite the path from ftp representation to real filepath on disk
 func (a aofs) pathRewrite(path string) (*filesystem.FileSystemHandler, string, error) {
 	path = filepath.ToSlash(filepath.Clean(path))
 	//log.Println("Original path: ", path)
@@ -224,11 +223,11 @@ func (a aofs) pathRewrite(path string) (*filesystem.FileSystemHandler, string, e
 			}
 		}
 
-		readmeContent, err := ioutil.ReadFile("./system/ftp/README.txt")
+		readmeContent, err := os.ReadFile("./system/ftp/README.txt")
 		if err != nil {
 			readmeContent = []byte("DO NOT UPLOAD FILES INTO THE ROOT DIRECTORY")
 		}
-		ioutil.WriteFile(filepath.Join(a.tmpFolder, "README.txt"), readmeContent, 0755)
+		os.WriteFile(filepath.Join(a.tmpFolder, "README.txt"), readmeContent, 0755)
 
 		//Return the tmpFolder root
 		tmpfs, _ := a.userinfo.GetFileSystemHandlerFromVirtualPath("tmp:/")
@@ -260,7 +259,7 @@ func (a aofs) pathRewrite(path string) (*filesystem.FileSystemHandler, string, e
 	}
 }
 
-//Check if user has access to the given path, mode can be string {read / write}
+// Check if user has access to the given path, mode can be string {read / write}
 func (a aofs) checkAllowAccess(fsh *filesystem.FileSystemHandler, path string, mode int) bool {
 	vpath, err := fsh.FileSystemAbstraction.RealPathToVirtualPath(path, a.userinfo.Username)
 	if err != nil {

+ 4 - 4
mod/storage/sftpserver/sftpserver.go

@@ -3,9 +3,9 @@ package sftpserver
 import (
 	"errors"
 	"io"
-	"io/ioutil"
 	"log"
 	"net"
+	"os"
 	"sync"
 
 	"github.com/pkg/sftp"
@@ -26,8 +26,8 @@ type Instance struct {
 	ConnectedClients sync.Map
 }
 
-//Create a new SFTP Server
-//listeningIP in the format of 0.0.0.0:2022
+// Create a new SFTP Server
+// listeningIP in the format of 0.0.0.0:2022
 func NewSFTPServer(sftpConfig *SFTPConfig) (*Instance, error) {
 	// An SSH server is represented by a ServerConfig, which holds
 	// certificate details and handles authentication of ServerConns.
@@ -45,7 +45,7 @@ func NewSFTPServer(sftpConfig *SFTPConfig) (*Instance, error) {
 		},
 	}
 
-	privateBytes, err := ioutil.ReadFile(sftpConfig.KeyFile)
+	privateBytes, err := os.ReadFile(sftpConfig.KeyFile)
 	if err != nil {
 		return nil, err
 	}

+ 10 - 11
mod/storage/webdav/common.go

@@ -4,7 +4,7 @@ import (
 	"bufio"
 	"encoding/base64"
 	"errors"
-	"io/ioutil"
+	"io"
 	"log"
 	"net/http"
 	"os"
@@ -31,7 +31,7 @@ func sendTextResponse(w http.ResponseWriter, msg string) {
 	w.Write([]byte(msg))
 }
 
-//Send JSON response, with an extra json header
+// Send JSON response, with an extra json header
 func sendJSONResponse(w http.ResponseWriter, json string) {
 	w.Header().Set("Content-Type", "application/json")
 	w.Write([]byte(json))
@@ -48,16 +48,15 @@ func sendOK(w http.ResponseWriter) {
 }
 
 /*
-	The paramter move function (mv)
+The paramter move function (mv)
 
-	You can find similar things in the PHP version of ArOZ Online Beta. You need to pass in
-	r (HTTP Request Object)
-	getParamter (string, aka $_GET['This string])
-
-	Will return
-	Paramter string (if any)
-	Error (if error)
+You can find similar things in the PHP version of ArOZ Online Beta. You need to pass in
+r (HTTP Request Object)
+getParamter (string, aka $_GET['This string])
 
+Will return
+Paramter string (if any)
+Error (if error)
 */
 func mv(r *http.Request, getParamter string, postMode bool) (string, error) {
 	if postMode == false {
@@ -139,7 +138,7 @@ func loadImageAsBase64(filepath string) (string, error) {
 	}
 	f, _ := os.Open(filepath)
 	reader := bufio.NewReader(f)
-	content, _ := ioutil.ReadAll(reader)
+	content, _ := io.ReadAll(reader)
 	encoded := base64.StdEncoding.EncodeToString(content)
 	return string(encoded), nil
 }

+ 73 - 75
mod/subservice/common.go

@@ -1,14 +1,14 @@
 package subservice
 
 import (
-	"os"
-    "log"
+	"bufio"
+	"encoding/base64"
+	"errors"
+	"io"
+	"log"
 	"net/http"
+	"os"
 	"strconv"
-	"errors"
-	"encoding/base64"
-	"bufio"
-	"io/ioutil"
 	"time"
 )
 
@@ -32,7 +32,7 @@ func sendTextResponse(w http.ResponseWriter, msg string) {
 	w.Write([]byte(msg))
 }
 
-//Send JSON response, with an extra json header
+// Send JSON response, with an extra json header
 func sendJSONResponse(w http.ResponseWriter, json string) {
 	w.Header().Set("Content-Type", "application/json")
 	w.Write([]byte(json))
@@ -47,17 +47,17 @@ func sendOK(w http.ResponseWriter) {
 	w.Header().Set("Content-Type", "application/json")
 	w.Write([]byte("\"OK\""))
 }
-/*
-	The paramter move function (mv)
 
-	You can find similar things in the PHP version of ArOZ Online Beta. You need to pass in
-	r (HTTP Request Object)
-	getParamter (string, aka $_GET['This string])
+/*
+The paramter move function (mv)
 
-	Will return
-	Paramter string (if any)
-	Error (if error)
+You can find similar things in the PHP version of ArOZ Online Beta. You need to pass in
+r (HTTP Request Object)
+getParamter (string, aka $_GET['This string])
 
+Will return
+Paramter string (if any)
+Error (if error)
 */
 func mv(r *http.Request, getParamter string, postMode bool) (string, error) {
 	if postMode == false {
@@ -86,113 +86,111 @@ func mv(r *http.Request, getParamter string, postMode bool) (string, error) {
 }
 
 func stringInSlice(a string, list []string) bool {
-    for _, b := range list {
-        if b == a {
-            return true
-        }
-    }
-    return false
+	for _, b := range list {
+		if b == a {
+			return true
+		}
+	}
+	return false
 }
 
-
 func fileExists(filename string) bool {
-    _, err := os.Stat(filename)
-    if os.IsNotExist(err) {
-        return false
-    }
-    return true
+	_, err := os.Stat(filename)
+	if os.IsNotExist(err) {
+		return false
+	}
+	return true
 }
 
-
-func isDir(path string) bool{
-	if (fileExists(path) == false){
+func isDir(path string) bool {
+	if fileExists(path) == false {
 		return false
 	}
 	fi, err := os.Stat(path)
-    if err != nil {
-        log.Fatal(err)
-        return false
-    }
-    switch mode := fi.Mode(); {
-    case mode.IsDir():
-        return true
-    case mode.IsRegular():
-        return false
+	if err != nil {
+		log.Fatal(err)
+		return false
+	}
+	switch mode := fi.Mode(); {
+	case mode.IsDir():
+		return true
+	case mode.IsRegular():
+		return false
 	}
 	return false
 }
 
 func inArray(arr []string, str string) bool {
 	for _, a := range arr {
-	   if a == str {
-		  return true
-	   }
+		if a == str {
+			return true
+		}
 	}
 	return false
- }
+}
 
- func timeToString(targetTime time.Time) string{
-	 return targetTime.Format("2006-01-02 15:04:05")
- }
+func timeToString(targetTime time.Time) string {
+	return targetTime.Format("2006-01-02 15:04:05")
+}
 
- func intToString(number int) string{
+func intToString(number int) string {
 	return strconv.Itoa(number)
- }
+}
 
- func stringToInt(number string) (int, error){
+func stringToInt(number string) (int, error) {
 	return strconv.Atoi(number)
- }
+}
 
- func stringToInt64(number string) (int64, error){
+func stringToInt64(number string) (int64, error) {
 	i, err := strconv.ParseInt(number, 10, 64)
 	if err != nil {
 		return -1, err
 	}
 	return i, nil
- }
+}
 
- func int64ToString(number int64) string{
-	convedNumber:=strconv.FormatInt(number,10)
+func int64ToString(number int64) string {
+	convedNumber := strconv.FormatInt(number, 10)
 	return convedNumber
- }
+}
 
- func getUnixTime() int64{
+func getUnixTime() int64 {
 	return time.Now().Unix()
- }
+}
 
- func loadImageAsBase64(filepath string) (string, error){
-	if !fileExists(filepath){
+func loadImageAsBase64(filepath string) (string, error) {
+	if !fileExists(filepath) {
 		return "", errors.New("File not exists")
 	}
 	f, _ := os.Open(filepath)
-    reader := bufio.NewReader(f)
-    content, _ := ioutil.ReadAll(reader)
+	reader := bufio.NewReader(f)
+	content, _ := io.ReadAll(reader)
 	encoded := base64.StdEncoding.EncodeToString(content)
 	return string(encoded), nil
- }
+}
 
- func pushToSliceIfNotExist(slice []string, newItem string) []string {
+func pushToSliceIfNotExist(slice []string, newItem string) []string {
 	itemExists := false
-	for _, item := range slice{
-		if item == newItem{
+	for _, item := range slice {
+		if item == newItem {
 			itemExists = true
 		}
 	}
 
-	if !itemExists{
+	if !itemExists {
 		slice = append(slice, newItem)
 	}
 
 	return slice
- }
+}
 
- func removeFromSliceIfExists(slice []string, target string) []string {
-	 newSlice := []string{}
-	 for _, item := range slice{
-		 if item != target{
+func removeFromSliceIfExists(slice []string, target string) []string {
+	newSlice := []string{}
+	for _, item := range slice {
+		if item != target {
 			newSlice = append(newSlice, item)
-		 }
-	 }
+		}
+	}
 
-	 return newSlice;
- }
+	return newSlice
+}

+ 2 - 3
mod/subservice/subservice.go

@@ -3,7 +3,6 @@ package subservice
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"log"
 	"net/http"
 	"net/url"
@@ -153,7 +152,7 @@ func (sr *SubServiceRouter) Launch(servicePath string, startupMode bool) error {
 	//Check if there are config files that replace the -info tag. If yes, use it instead.
 	out := []byte{}
 	if fileExists(servicePath + "/moduleInfo.json") {
-		launchConfig, err := ioutil.ReadFile(servicePath + "/moduleInfo.json")
+		launchConfig, err := os.ReadFile(servicePath + "/moduleInfo.json")
 		if err != nil {
 			if startupMode {
 				log.Fatal("Failed to read moduleInfo.json: "+binaryname, err)
@@ -488,7 +487,7 @@ func (sr *SubServiceRouter) KillSubService(serviceDir string) error {
 			}
 
 			//Write a suspended file into the module
-			ioutil.WriteFile("subservice/"+ss.ServiceDir+"/.disabled", []byte(""), 0755)
+			os.WriteFile("subservice/"+ss.ServiceDir+"/.disabled", []byte(""), 0755)
 		}
 	}
 

+ 1 - 1
mod/time/scheduler/handlers.go

@@ -219,7 +219,7 @@ func (a *Scheduler) HandleShowLog(w http.ResponseWriter, r *http.Request) {
 		//Show log content
 		filename = strings.ReplaceAll(filepath.ToSlash(filename), "/", "")
 		if fileExists(filepath.Join(logFolder, filename)) {
-			logContent, err := ioutil.ReadFile(filepath.Join(logFolder, filename))
+			logContent, err := os.ReadFile(filepath.Join(logFolder, filename))
 			if err != nil {
 				sendTextResponse(w, "Unable to load log file: "+filename)
 			} else {

+ 5 - 5
mod/time/scheduler/helper.go

@@ -2,13 +2,13 @@ package scheduler
 
 import (
 	"encoding/json"
-	"io/ioutil"
+	"os"
 )
 
-//Load a list of jobs from file
+// Load a list of jobs from file
 func loadJobsFromFile(cronfile string) ([]*Job, error) {
 	//Try to read the cronfile
-	filecontent, err := ioutil.ReadFile(cronfile)
+	filecontent, err := os.ReadFile(cronfile)
 	if err != nil {
 		return []*Job{}, err
 	}
@@ -23,13 +23,13 @@ func loadJobsFromFile(cronfile string) ([]*Job, error) {
 	return prevousJobs, nil
 }
 
-//save the changes in job list to file
+// save the changes in job list to file
 func (a *Scheduler) saveJobsToCronFile() error {
 	js, err := json.Marshal(a.jobs)
 	if err != nil {
 		return err
 	}
-	return ioutil.WriteFile(a.options.CronFile, js, 0775)
+	return os.WriteFile(a.options.CronFile, js, 0775)
 }
 
 func (a *Scheduler) cronlog(message string) {

+ 3 - 3
mod/time/scheduler/scheduler.go

@@ -3,8 +3,8 @@ package scheduler
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"log"
+	"os"
 	"path/filepath"
 	"time"
 
@@ -55,7 +55,7 @@ func NewScheduler(option *ScheudlerOption) (*Scheduler, error) {
 		//Cronfile not exists. Create it
 		emptyJobList := []*Job{}
 		ls, _ := json.Marshal(emptyJobList)
-		err := ioutil.WriteFile(option.CronFile, ls, 0755)
+		err := os.WriteFile(option.CronFile, ls, 0755)
 		if err != nil {
 			return nil, err
 		}
@@ -171,7 +171,7 @@ func (a *Scheduler) Close() {
 	}
 }
 
-//Add an job object to system scheduler
+// Add an job object to system scheduler
 func (a *Scheduler) AddJobToScheduler(job *Job) error {
 	a.jobs = append(a.jobs, job)
 	return nil

+ 4 - 4
mod/time/timezone/timezone.go

@@ -2,8 +2,8 @@ package timezone
 
 import (
 	"encoding/json"
-	"io/ioutil"
 	"net/http"
+	"os"
 	"os/exec"
 	"runtime"
 	"strings"
@@ -24,13 +24,13 @@ import (
 	TODO: timezone problems.
 */
 
-//returnFormat shoulbn't be exported
+// returnFormat shoulbn't be exported
 type returnFormat struct {
 	Time     string `json:"time"`
 	Timezone string `json:"timezone"`
 }
 
-//WindowsTimeZoneStruct shouldn't be exported.
+// WindowsTimeZoneStruct shouldn't be exported.
 type WindowsTimeZoneStruct struct {
 	SupplementalData struct {
 		Version struct {
@@ -81,7 +81,7 @@ func ShowTime(w http.ResponseWriter, r *http.Request) {
 }
 
 func ConvertWinTZtoLinuxTZ(WinTZ string) string {
-	file, _ := ioutil.ReadFile("./system/time/wintz.json")
+	file, _ := os.ReadFile("./system/time/wintz.json")
 	WinTZLinuxTz := WindowsTimeZoneStruct{}
 	json.Unmarshal([]byte(file), &WinTZLinuxTz)
 	for _, data := range WinTZLinuxTz.SupplementalData.WindowsZones.MapTimezones.MapZone {

+ 4 - 4
mod/updates/handler.go

@@ -3,9 +3,9 @@ package updates
 import (
 	"encoding/json"
 	"fmt"
-	"io/ioutil"
 	"log"
 	"net/http"
+	"os"
 	"runtime"
 	"time"
 
@@ -137,7 +137,7 @@ func HandleUpdateDownloadRequest(w http.ResponseWriter, r *http.Request) {
 
 }
 
-//Handle getting information for vendor update
+// Handle getting information for vendor update
 func HandleGetUpdatePlatformInfo(w http.ResponseWriter, r *http.Request) {
 	type UpdatePackageInfo struct {
 		Config UpdateConfig
@@ -146,7 +146,7 @@ func HandleGetUpdatePlatformInfo(w http.ResponseWriter, r *http.Request) {
 	}
 
 	//Check if update config find. If yes, parse that
-	updateFileContent, err := ioutil.ReadFile("./system/update.json")
+	updateFileContent, err := os.ReadFile("./system/update.json")
 	if err != nil {
 		utils.SendErrorResponse(w, "No vendor update config found")
 		return
@@ -171,7 +171,7 @@ func HandleGetUpdatePlatformInfo(w http.ResponseWriter, r *http.Request) {
 	utils.SendJSONResponse(w, string(js))
 }
 
-//Handle check if there is a pending update
+// Handle check if there is a pending update
 func HandlePendingCheck(w http.ResponseWriter, r *http.Request) {
 	if utils.FileExists("./updates/") && utils.FileExists("./updates/web/") && utils.FileExists("./updates/system/") {
 		//Update is pending

+ 5 - 5
mod/updates/updates.go

@@ -2,14 +2,14 @@ package updates
 
 import (
 	"errors"
-	"io/ioutil"
+	"io"
 	"net/http"
 	"os"
 	"path/filepath"
 	"time"
 )
 
-//Download updates from given URL, return real time progress of stage (int),  progress (int) and status text (string)
+// Download updates from given URL, return real time progress of stage (int),  progress (int) and status text (string)
 func DownloadUpdatesFromURL(binaryURL string, webpackURL string, checksumURL string, progressUpdateFunction func(int, float64, string)) error {
 	//Create the update download folder
 	os.RemoveAll("./updates")
@@ -96,7 +96,7 @@ func DownloadUpdatesFromURL(binaryURL string, webpackURL string, checksumURL str
 			errorMessage = err.Error()
 			return err
 		}
-		checksumFileContent, err := ioutil.ReadFile(checksumDownloadTarget)
+		checksumFileContent, err := os.ReadFile(checksumDownloadTarget)
 		if err != nil {
 			errorMessage = err.Error()
 			return err
@@ -146,7 +146,7 @@ func DownloadUpdatesFromURL(binaryURL string, webpackURL string, checksumURL str
 	return nil
 }
 
-//Get the update sizes, return binary size, webpack size and error if any
+// Get the update sizes, return binary size, webpack size and error if any
 func GetUpdateSizes(binaryURL string, webpackURL string) (int, int, error) {
 	bps, err := getDownloadFileSize(binaryURL)
 	if err != nil {
@@ -170,7 +170,7 @@ func GetLauncherVersion() (string, error) {
 		return "", errors.New("No launcher found. Unable to restart")
 	}
 
-	content, err := ioutil.ReadAll(resp.Body)
+	content, err := io.ReadAll(resp.Body)
 	if err != nil {
 		return "", errors.New("Read launcher response failed")
 	}

+ 2 - 2
mod/utils/template.go

@@ -1,8 +1,8 @@
 package utils
 
 import (
-	"io/ioutil"
 	"net/http"
+	"os"
 
 	"github.com/valyala/fasttemplate"
 )
@@ -17,7 +17,7 @@ import (
 */
 
 func Templateload(filename string, replacement map[string]interface{}) (string, error) {
-	content, err := ioutil.ReadFile(filename)
+	content, err := os.ReadFile(filename)
 	if err != nil {
 		return "", nil
 	}

+ 8 - 8
mod/utils/utils.go

@@ -4,7 +4,7 @@ import (
 	"bufio"
 	"encoding/base64"
 	"errors"
-	"io/ioutil"
+	"io"
 	"log"
 	"net/http"
 	"os"
@@ -19,12 +19,12 @@ import (
 
 */
 
-//Response related
+// Response related
 func SendTextResponse(w http.ResponseWriter, msg string) {
 	w.Write([]byte(msg))
 }
 
-//Send JSON response, with an extra json header
+// Send JSON response, with an extra json header
 func SendJSONResponse(w http.ResponseWriter, json string) {
 	w.Header().Set("Content-Type", "application/json")
 	w.Write([]byte(json))
@@ -80,7 +80,7 @@ func Mv(r *http.Request, getParamter string, postMode bool) (string, error) {
 }
 */
 
-//Get GET parameter
+// Get GET parameter
 func GetPara(r *http.Request, key string) (string, error) {
 	keys, ok := r.URL.Query()[key]
 	if !ok || len(keys[0]) < 1 {
@@ -90,7 +90,7 @@ func GetPara(r *http.Request, key string) (string, error) {
 	}
 }
 
-//Get POST paramter
+// Get POST paramter
 func PostPara(r *http.Request, key string) (string, error) {
 	r.ParseForm()
 	x := r.Form.Get(key)
@@ -137,12 +137,12 @@ func LoadImageAsBase64(filepath string) (string, error) {
 	}
 	f, _ := os.Open(filepath)
 	reader := bufio.NewReader(f)
-	content, _ := ioutil.ReadAll(reader)
+	content, _ := io.ReadAll(reader)
 	encoded := base64.StdEncoding.EncodeToString(content)
 	return string(encoded), nil
 }
 
-//Use for redirections
+// Use for redirections
 func ConstructRelativePathFromRequestURL(requestURI string, redirectionLocation string) string {
 	if strings.Count(requestURI, "/") == 1 {
 		//Already root level
@@ -155,7 +155,7 @@ func ConstructRelativePathFromRequestURL(requestURI string, redirectionLocation
 	return redirectionLocation
 }
 
-//Check if given string in a given slice
+// Check if given string in a given slice
 func StringInArray(arr []string, str string) bool {
 	for _, a := range arr {
 		if a == str {

+ 4 - 6
mod/wsshell/wsshell.go

@@ -3,7 +3,6 @@ package wsshell
 import (
 	"bufio"
 	"io"
-	"io/ioutil"
 	"log"
 	"net/http"
 	"os"
@@ -18,11 +17,10 @@ import (
 )
 
 /*
-	Bash Module
-	author: tobychui
-
-	This module handles the connection of bash terminal to websocket interface
+Bash Module
+author: tobychui
 
+This module handles the connection of bash terminal to websocket interface
 */
 var upgrader = websocket.Upgrader{
 	ReadBufferSize:  1024,
@@ -143,7 +141,7 @@ func (t *Terminal) HandleOpen(w http.ResponseWriter, r *http.Request) {
 
 	} else if runtime.GOOS == "linux" {
 		//Send message of the day
-		content, err := ioutil.ReadFile("/etc/motd")
+		content, err := os.ReadFile("/etc/motd")
 		if err != nil {
 			//Unable to read the motd, use the arozos default one
 			c.WriteMessage(1, []byte("Terminal Connected. Start type something!"))

+ 3 - 3
mod/www/www.go

@@ -2,9 +2,9 @@ package www
 
 import (
 	"io"
-	"io/ioutil"
 	"net/http"
 	"net/url"
+	"os"
 	"path/filepath"
 	"strings"
 
@@ -34,7 +34,7 @@ type Handler struct {
 }
 
 /*
-	New WebRoot Handler create a new handler for handling and routing webroots
+New WebRoot Handler create a new handler for handling and routing webroots
 */
 func NewWebRootHandler(options Options) *Handler {
 	//Create the homepage database table
@@ -178,7 +178,7 @@ func serveNotFoundTemplate(w http.ResponseWriter, r *http.Request) {
 func handleWebrootError(w http.ResponseWriter) {
 	w.WriteHeader(http.StatusInternalServerError)
 	if utils.FileExists("./system/www/nowebroot.html") {
-		content, err := ioutil.ReadFile("./system/www/nowebroot.html")
+		content, err := os.ReadFile("./system/www/nowebroot.html")
 		if err != nil {
 			w.Write([]byte("500 - Internal Server Error"))
 		} else {

+ 1 - 2
storage.go

@@ -3,7 +3,6 @@ package main
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"log"
 	"os"
 	"path/filepath"
@@ -87,7 +86,7 @@ func LoadBaseStoragePool() error {
 	fsHandlers = append(fsHandlers, tmpHandler)
 
 	//Load all the storage config from file
-	rawConfig, err := ioutil.ReadFile(*storage_config_file)
+	rawConfig, err := os.ReadFile(*storage_config_file)
 	if err != nil {
 		//File not found. Use internal storage only
 		systemWideLogger.PrintAndLog("Storage", "Storage configuration file not found. Using internal storage only.", err)

+ 18 - 19
storage.pool.go

@@ -3,7 +3,6 @@ package main
 import (
 	"encoding/json"
 	"errors"
-	"io/ioutil"
 	"log"
 	"net/http"
 	"os"
@@ -60,7 +59,7 @@ func StoragePoolEditorInit() {
 
 }
 
-//Handle editing of a given File System Handler
+// Handle editing of a given File System Handler
 func HandleFSHEdit(w http.ResponseWriter, r *http.Request) {
 	opr, _ := utils.PostPara(r, "opr")
 	group, err := utils.PostPara(r, "group")
@@ -147,7 +146,7 @@ func HandleFSHEdit(w http.ResponseWriter, r *http.Request) {
 		//Merge the old config file if exists
 		oldConfigs := []fs.FileSystemOption{}
 		if fs.FileExists(configFile) {
-			originalConfigFile, _ := ioutil.ReadFile(configFile)
+			originalConfigFile, _ := os.ReadFile(configFile)
 			err := json.Unmarshal(originalConfigFile, &oldConfigs)
 			if err != nil {
 				systemWideLogger.PrintAndLog("Storage", err.Error(), err)
@@ -156,7 +155,7 @@ func HandleFSHEdit(w http.ResponseWriter, r *http.Request) {
 
 		oldConfigs = append(oldConfigs, newFsOption)
 		js, _ := json.MarshalIndent(oldConfigs, "", " ")
-		err = ioutil.WriteFile(configFile, js, 0775)
+		err = os.WriteFile(configFile, js, 0775)
 		if err != nil {
 			utils.SendErrorResponse(w, err.Error())
 			return
@@ -171,7 +170,7 @@ func HandleFSHEdit(w http.ResponseWriter, r *http.Request) {
 	}
 }
 
-//Get the FSH configuration for the given group and uuid
+// Get the FSH configuration for the given group and uuid
 func getFSHConfigFromGroupAndUUID(group string, uuid string) (*fs.FileSystemOption, error) {
 	//Spot the desired config file
 	targerFile := ""
@@ -192,7 +191,7 @@ func getFSHConfigFromGroupAndUUID(group string, uuid string) (*fs.FileSystemOpti
 	}
 
 	//Load and parse the file
-	configContent, err := ioutil.ReadFile(targerFile)
+	configContent, err := os.ReadFile(targerFile)
 	if err != nil {
 		return nil, err
 	}
@@ -235,7 +234,7 @@ func setFSHConfigByGroupAndId(group string, uuid string, options fs.FileSystemOp
 	}
 
 	//Load and parse the file
-	configContent, err := ioutil.ReadFile(targerFile)
+	configContent, err := os.ReadFile(targerFile)
 	if err != nil {
 		return err
 	}
@@ -271,10 +270,10 @@ func setFSHConfigByGroupAndId(group string, uuid string, options fs.FileSystemOp
 
 	//Write config back to file
 	js, _ := json.MarshalIndent(newConfig, "", " ")
-	return ioutil.WriteFile(targerFile, js, 0775)
+	return os.WriteFile(targerFile, js, 0775)
 }
 
-//Handle Storage Pool toggle on-off
+// Handle Storage Pool toggle on-off
 func HandleFSHToggle(w http.ResponseWriter, r *http.Request) {
 	fsh, _ := utils.PostPara(r, "fsh")
 	if fsh == "" {
@@ -348,7 +347,7 @@ func HandleFSHToggle(w http.ResponseWriter, r *http.Request) {
 
 }
 
-//Handle reload of storage pool
+// Handle reload of storage pool
 func HandleStoragePoolReload(w http.ResponseWriter, r *http.Request) {
 	pool, _ := utils.PostPara(r, "pool")
 
@@ -466,7 +465,7 @@ func HandleStoragePoolRemove(w http.ResponseWriter, r *http.Request) {
 			//No config. Create an empty one
 			initConfig := []fs.FileSystemOption{}
 			js, _ := json.MarshalIndent(initConfig, "", " ")
-			ioutil.WriteFile(targetConfigFile, js, 0775)
+			os.WriteFile(targetConfigFile, js, 0775)
 		}
 	}
 
@@ -493,7 +492,7 @@ func HandleStoragePoolRemove(w http.ResponseWriter, r *http.Request) {
 		//Remove it from the json file
 		//Read and parse from old config
 		oldConfigs := []fs.FileSystemOption{}
-		originalConfigFile, _ := ioutil.ReadFile(targetConfigFile)
+		originalConfigFile, _ := os.ReadFile(targetConfigFile)
 		err = json.Unmarshal(originalConfigFile, &oldConfigs)
 		if err != nil {
 			utils.SendErrorResponse(w, "Failed to parse original config file")
@@ -512,7 +511,7 @@ func HandleStoragePoolRemove(w http.ResponseWriter, r *http.Request) {
 		if len(newConfigs) > 0 {
 			js, _ := json.Marshal(newConfigs)
 			resultingJson := pretty.Pretty(js)
-			ioutil.WriteFile(targetConfigFile, resultingJson, 0777)
+			os.WriteFile(targetConfigFile, resultingJson, 0777)
 		} else {
 			os.Remove(targetConfigFile)
 		}
@@ -521,7 +520,7 @@ func HandleStoragePoolRemove(w http.ResponseWriter, r *http.Request) {
 	utils.SendOK(w)
 }
 
-//Constract a fsoption from form
+// Constract a fsoption from form
 func buildOptionFromRequestForm(payload string) (fs.FileSystemOption, error) {
 	newFsOption := fs.FileSystemOption{}
 	err := json.Unmarshal([]byte(payload), &newFsOption)
@@ -573,7 +572,7 @@ func HandleStorageNewFsHandler(w http.ResponseWriter, r *http.Request) {
 	//If file exists, merge it to
 	oldConfigs := []fs.FileSystemOption{}
 	if fs.FileExists(configFile) {
-		originalConfigFile, _ := ioutil.ReadFile(configFile)
+		originalConfigFile, _ := os.ReadFile(configFile)
 		err := json.Unmarshal(originalConfigFile, &oldConfigs)
 		if err != nil {
 			systemWideLogger.PrintAndLog(err,nil)
@@ -586,7 +585,7 @@ func HandleStorageNewFsHandler(w http.ResponseWriter, r *http.Request) {
 	js, _ := json.Marshal(oldConfigs)
 	resultingJson := pretty.Pretty(js)
 
-	err = ioutil.WriteFile(configFile, resultingJson, 0775)
+	err = os.WriteFile(configFile, resultingJson, 0775)
 	if err != nil {
 		//Write Error. This could sometime happens on Windows host for unknown reason
 		js, _ := json.Marshal(errorObject{
@@ -624,7 +623,7 @@ func HandleListStoragePoolsConfig(w http.ResponseWriter, r *http.Request) {
 	}
 
 	//Read and serve it
-	configContent, err := ioutil.ReadFile(targetFile)
+	configContent, err := os.ReadFile(targetFile)
 	if err != nil {
 		utils.SendErrorResponse(w, err.Error())
 		return
@@ -633,7 +632,7 @@ func HandleListStoragePoolsConfig(w http.ResponseWriter, r *http.Request) {
 	}
 }
 
-//Return all storage pool mounted to the system, aka base pool + pg pools
+// Return all storage pool mounted to the system, aka base pool + pg pools
 func HandleListStoragePools(w http.ResponseWriter, r *http.Request) {
 	filter, _ := utils.GetPara(r, "filter")
 
@@ -663,7 +662,7 @@ func HandleListStoragePools(w http.ResponseWriter, r *http.Request) {
 	utils.SendJSONResponse(w, string(js))
 }
 
-//Handler for bridging two FSH, require admin permission
+// Handler for bridging two FSH, require admin permission
 func HandleFSHBridging(w http.ResponseWriter, r *http.Request) {
 	//Get the target pool and fsh to bridge
 	basePool, err := utils.PostPara(r, "base")

+ 94 - 96
subservice/WsTTY/common.go

@@ -1,15 +1,15 @@
 package main
 
 import (
-	"os"
-    "log"
+	"bufio"
+	"encoding/base64"
+	"errors"
+	"io"
+	"log"
 	"net/http"
+	"os"
 	"strconv"
 	"strings"
-	"errors"
-	"encoding/base64"
-	"bufio"
-	"io/ioutil"
 	"time"
 )
 
@@ -33,7 +33,7 @@ func sendTextResponse(w http.ResponseWriter, msg string) {
 	w.Write([]byte(msg))
 }
 
-//Send JSON response, with an extra json header
+// Send JSON response, with an extra json header
 func sendJSONResponse(w http.ResponseWriter, json string) {
 	w.Header().Set("Content-Type", "application/json")
 	w.Write([]byte(json))
@@ -48,17 +48,17 @@ func sendOK(w http.ResponseWriter) {
 	w.Header().Set("Content-Type", "application/json")
 	w.Write([]byte("\"OK\""))
 }
-/*
-	The paramter move function (mv)
 
-	You can find similar things in the PHP version of ArOZ Online Beta. You need to pass in
-	r (HTTP Request Object)
-	getParamter (string, aka $_GET['This string])
+/*
+The paramter move function (mv)
 
-	Will return
-	Paramter string (if any)
-	Error (if error)
+You can find similar things in the PHP version of ArOZ Online Beta. You need to pass in
+r (HTTP Request Object)
+getParamter (string, aka $_GET['This string])
 
+Will return
+Paramter string (if any)
+Error (if error)
 */
 func mv(r *http.Request, getParamter string, postMode bool) (string, error) {
 	if postMode == false {
@@ -87,136 +87,134 @@ func mv(r *http.Request, getParamter string, postMode bool) (string, error) {
 }
 
 func stringInSlice(a string, list []string) bool {
-    for _, b := range list {
-        if b == a {
-            return true
-        }
-    }
-    return false
+	for _, b := range list {
+		if b == a {
+			return true
+		}
+	}
+	return false
 }
 
-
 func fileExists(filename string) bool {
-    _, err := os.Stat(filename)
-    if os.IsNotExist(err) {
-        return false
-    }
-    return true
+	_, err := os.Stat(filename)
+	if os.IsNotExist(err) {
+		return false
+	}
+	return true
 }
 
-
-func IsDir(path string) bool{
-	if (fileExists(path) == false){
+func IsDir(path string) bool {
+	if fileExists(path) == false {
 		return false
 	}
 	fi, err := os.Stat(path)
-    if err != nil {
-        log.Fatal(err)
-        return false
-    }
-    switch mode := fi.Mode(); {
-    case mode.IsDir():
-        return true
-    case mode.IsRegular():
-        return false
+	if err != nil {
+		log.Fatal(err)
+		return false
+	}
+	switch mode := fi.Mode(); {
+	case mode.IsDir():
+		return true
+	case mode.IsRegular():
+		return false
 	}
 	return false
 }
 
 func inArray(arr []string, str string) bool {
 	for _, a := range arr {
-	   if a == str {
-		  return true
-	   }
+		if a == str {
+			return true
+		}
 	}
 	return false
- }
+}
 
- func timeToString(targetTime time.Time) string{
-	 return targetTime.Format("2006-01-02 15:04:05")
- }
+func timeToString(targetTime time.Time) string {
+	return targetTime.Format("2006-01-02 15:04:05")
+}
 
- func IntToString(number int) string{
+func IntToString(number int) string {
 	return strconv.Itoa(number)
- }
+}
 
- func StringToInt(number string) (int, error){
+func StringToInt(number string) (int, error) {
 	return strconv.Atoi(number)
- }
+}
 
- func StringToInt64(number string) (int64, error){
+func StringToInt64(number string) (int64, error) {
 	i, err := strconv.ParseInt(number, 10, 64)
 	if err != nil {
 		return -1, err
 	}
 	return i, nil
- }
+}
 
- func Int64ToString(number int64) string{
-	convedNumber:=strconv.FormatInt(number,10)
+func Int64ToString(number int64) string {
+	convedNumber := strconv.FormatInt(number, 10)
 	return convedNumber
- }
+}
 
- func GetUnixTime() int64{
+func GetUnixTime() int64 {
 	return time.Now().Unix()
- }
+}
 
- func LoadImageAsBase64(filepath string) (string, error){
-	if !fileExists(filepath){
+func LoadImageAsBase64(filepath string) (string, error) {
+	if !fileExists(filepath) {
 		return "", errors.New("File not exists")
 	}
 	f, _ := os.Open(filepath)
-    reader := bufio.NewReader(f)
-    content, _ := ioutil.ReadAll(reader)
+	reader := bufio.NewReader(f)
+	content, _ := io.ReadAll(reader)
 	encoded := base64.StdEncoding.EncodeToString(content)
 	return string(encoded), nil
- }
+}
 
- func PushToSliceIfNotExist(slice []string, newItem string) []string {
+func PushToSliceIfNotExist(slice []string, newItem string) []string {
 	itemExists := false
-	for _, item := range slice{
-		if item == newItem{
+	for _, item := range slice {
+		if item == newItem {
 			itemExists = true
 		}
 	}
 
-	if !itemExists{
+	if !itemExists {
 		slice = append(slice, newItem)
 	}
 
 	return slice
- }
+}
 
- func RemoveFromSliceIfExists(slice []string, target string) []string {
-	 newSlice := []string{}
-	 for _, item := range slice{
-		 if item != target{
+func RemoveFromSliceIfExists(slice []string, target string) []string {
+	newSlice := []string{}
+	for _, item := range slice {
+		if item != target {
 			newSlice = append(newSlice, item)
-		 }
-	 }
+		}
+	}
 
-	 return newSlice;
- }
+	return newSlice
+}
 
- //Get the IP address of the current authentication user
+// Get the IP address of the current authentication user
 func ReflectUserIP(w http.ResponseWriter, r *http.Request) {
-    requestPort,_ :=  mv(r, "port", false)
-    showPort := false;
-    if (requestPort == "true"){
-        //Show port as well
-        showPort = true;
-    }
-    IPAddress := r.Header.Get("X-Real-Ip")
-    if IPAddress == "" {
-        IPAddress = r.Header.Get("X-Forwarded-For")
-    }
-    if IPAddress == "" {
-        IPAddress = r.RemoteAddr
-    }
-    if (!showPort){
-        IPAddress = IPAddress[:strings.LastIndex(IPAddress, ":")]
-
-    }
-    w.Write([]byte(IPAddress))
-    return;
-}
+	requestPort, _ := mv(r, "port", false)
+	showPort := false
+	if requestPort == "true" {
+		//Show port as well
+		showPort = true
+	}
+	IPAddress := r.Header.Get("X-Real-Ip")
+	if IPAddress == "" {
+		IPAddress = r.Header.Get("X-Forwarded-For")
+	}
+	if IPAddress == "" {
+		IPAddress = r.RemoteAddr
+	}
+	if !showPort {
+		IPAddress = IPAddress[:strings.LastIndex(IPAddress, ":")]
+
+	}
+	w.Write([]byte(IPAddress))
+	return
+}

+ 1 - 2
subservice/WsTTY/main.go

@@ -1,7 +1,6 @@
 package main
 
 import (
-	"io/ioutil"
 	"log"
 	"net/http"
 	"os"
@@ -112,7 +111,7 @@ func main() {
 		cmd.Stderr = os.Stderr
 		if err := cmd.Start(); err != nil {
 			//Fail to start gotty. Disable this module
-			ioutil.WriteFile(".disabled", []byte(""), 0755)
+			os.WriteFile(".disabled", []byte(""), 0755)
 			return
 		}
 	} else {

+ 10 - 11
subservice/WsTTY/mod/wsshell/common.go

@@ -4,7 +4,7 @@ import (
 	"bufio"
 	"encoding/base64"
 	"errors"
-	"io/ioutil"
+	"io"
 	"log"
 	"net/http"
 	"os"
@@ -31,7 +31,7 @@ func sendTextResponse(w http.ResponseWriter, msg string) {
 	w.Write([]byte(msg))
 }
 
-//Send JSON response, with an extra json header
+// Send JSON response, with an extra json header
 func sendJSONResponse(w http.ResponseWriter, json string) {
 	w.Header().Set("Content-Type", "application/json")
 	w.Write([]byte(json))
@@ -48,16 +48,15 @@ func sendOK(w http.ResponseWriter) {
 }
 
 /*
-	The paramter move function (mv)
+The paramter move function (mv)
 
-	You can find similar things in the PHP version of ArOZ Online Beta. You need to pass in
-	r (HTTP Request Object)
-	getParamter (string, aka $_GET['This string])
-
-	Will return
-	Paramter string (if any)
-	Error (if error)
+You can find similar things in the PHP version of ArOZ Online Beta. You need to pass in
+r (HTTP Request Object)
+getParamter (string, aka $_GET['This string])
 
+Will return
+Paramter string (if any)
+Error (if error)
 */
 func mv(r *http.Request, getParamter string, postMode bool) (string, error) {
 	if postMode == false {
@@ -139,7 +138,7 @@ func loadImageAsBase64(filepath string) (string, error) {
 	}
 	f, _ := os.Open(filepath)
 	reader := bufio.NewReader(f)
-	content, _ := ioutil.ReadAll(reader)
+	content, _ := io.ReadAll(reader)
 	encoded := base64.StdEncoding.EncodeToString(content)
 	return string(encoded), nil
 }

+ 4 - 6
subservice/WsTTY/mod/wsshell/wsshell.go

@@ -3,7 +3,6 @@ package wsshell
 import (
 	"bufio"
 	"io"
-	"io/ioutil"
 	"log"
 	"net/http"
 	"os"
@@ -18,11 +17,10 @@ import (
 )
 
 /*
-	Bash Module
-	author: tobychui
-
-	This module handles the connection of bash terminal to websocket interface
+Bash Module
+author: tobychui
 
+This module handles the connection of bash terminal to websocket interface
 */
 var upgrader = websocket.Upgrader{
 	ReadBufferSize:  1024,
@@ -143,7 +141,7 @@ func (t *Terminal) HandleOpen(w http.ResponseWriter, r *http.Request) {
 
 	} else if runtime.GOOS == "linux" {
 		//Send message of the day
-		content, err := ioutil.ReadFile("/etc/motd")
+		content, err := os.ReadFile("/etc/motd")
 		if err != nil {
 			//Unable to read the motd, use the arozos default one
 			c.WriteMessage(1, []byte("Terminal Connected. Start type something!"))

+ 4 - 4
subservice/demo/main.go

@@ -1,7 +1,7 @@
 package main
 
 import (
-	"io/ioutil"
+	"io"
 	"log"
 	"net/http"
 	"os"
@@ -22,7 +22,7 @@ var (
 	In this example, the proxy path is demo/*
 */
 
-//Kill signal handler. Do something before the system the core terminate.
+// Kill signal handler. Do something before the system the core terminate.
 func SetupCloseHandler() {
 	c := make(chan os.Signal, 2)
 	signal.Notify(c, os.Interrupt, syscall.SIGTERM)
@@ -74,7 +74,7 @@ func main() {
 
 }
 
-//API Test Demo. This showcase how can you access arozos resources with RESTFUL API CALL
+// API Test Demo. This showcase how can you access arozos resources with RESTFUL API CALL
 func apiTestDemo(w http.ResponseWriter, r *http.Request) {
 	//Get username and token from request
 	username, token := handler.GetUserInfoFromRequest(w, r)
@@ -99,7 +99,7 @@ func apiTestDemo(w http.ResponseWriter, r *http.Request) {
 		log.Println(err)
 	} else {
 		//Try to read the resp body
-		bodyBytes, err := ioutil.ReadAll(resp.Body)
+		bodyBytes, err := io.ReadAll(resp.Body)
 		if err != nil {
 			log.Println(err)
 			w.Write([]byte(err.Error()))

+ 9 - 9
system.go

@@ -2,9 +2,9 @@ package main
 
 import (
 	"encoding/json"
-	"io/ioutil"
 	"log"
 	"net/http"
+	"os"
 	"path/filepath"
 	"strings"
 
@@ -14,10 +14,10 @@ import (
 )
 
 /*
-	System Identification API
+System Identification API
 
-	This module handles cross cluster scanning, responses and more that related
-	to functions that identifiy this as a ArOZ Online device
+This module handles cross cluster scanning, responses and more that related
+to functions that identifiy this as a ArOZ Online device
 */
 func SystemIDInit() {
 	//Initialize device UUID if not exists
@@ -81,7 +81,7 @@ func SystemIDInit() {
 }
 
 /*
-	Ping function. This function handles the request
+Ping function. This function handles the request
 */
 func systemIdHandlePing(w http.ResponseWriter, r *http.Request) {
 	w.Header().Set("Access-Control-Allow-Origin", "*")
@@ -103,13 +103,13 @@ func systemIdGenerateSystemUUID() {
 			//User has defined the uuid. Use user defined one instead.
 			thisuuid = *system_uuid
 		}
-		err := ioutil.WriteFile("./system/dev.uuid", []byte(thisuuid), 0755)
+		err := os.WriteFile("./system/dev.uuid", []byte(thisuuid), 0755)
 		if err != nil {
 			log.Fatal(err)
 		}
 		deviceUUID = thisuuid
 	} else {
-		thisuuid, err := ioutil.ReadFile("./system/dev.uuid")
+		thisuuid, err := os.ReadFile("./system/dev.uuid")
 		if err != nil {
 			log.Fatal("Failed to read system uuid file (system/dev.uuid).")
 		}
@@ -118,7 +118,7 @@ func systemIdGenerateSystemUUID() {
 }
 
 func systemIdGetSystemUUID() string {
-	fileUUID, err := ioutil.ReadFile("./system/dev.uuid")
+	fileUUID, err := os.ReadFile("./system/dev.uuid")
 	if err != nil {
 		systemWideLogger.PrintAndLog("Storage", "Unable to read system UUID from dev.uuid file", err)
 		log.Fatal(err)
@@ -133,7 +133,7 @@ func systemHandleListLicense(w http.ResponseWriter, r *http.Request) {
 	for _, file := range licenses {
 		fileName := filepath.Base(file)
 		name := strings.TrimSuffix(fileName, filepath.Ext(fileName))
-		content, _ := ioutil.ReadFile(file)
+		content, _ := os.ReadFile(file)
 		results = append(results, []string{name, string(content)})
 	}