diff --git a/fssc/fssc b/fssc/fssc index f2995c8..9083106 100644 Binary files a/fssc/fssc and b/fssc/fssc differ diff --git a/fssc/internal/handler/webconsole.go b/fssc/internal/handler/webconsole.go index fb2d400..bba71cd 100644 --- a/fssc/internal/handler/webconsole.go +++ b/fssc/internal/handler/webconsole.go @@ -1,6 +1,7 @@ package handler import ( + "fmt" "fssc/config" "fssc/internal/util" "fssc/web" @@ -8,17 +9,34 @@ import ( "net/http" "os" "path/filepath" - "strings" ) // web 控制台 func WebConsole(w http.ResponseWriter, r *http.Request) { + //file flag + isfile := r.URL.Query().Get("file") + // 路径 urlpath := r.URL.Query().Get("p") - upath := strings.TrimSuffix(urlpath, "console") + //文件名 + fname := r.URL.Query().Get("f") + //转码 + abupath := util.Base64dec(urlpath) + abfname := util.Base64dec(fname) + fmt.Printf("after base64: path: %s,file:%s\n", abupath, abfname) + + // url + if isfile == "0" { + abupath = filepath.Join(abupath, abfname) + } + + // upath := strings.TrimSuffix(abupath, "console") // serve download page for send - realFilePath := filepath.Join(config.G.FilePath, upath) - downloadPath := filepath.Join(filepath.Base(config.G.FilePath), r.URL.Path[1:]) + realFilePath := filepath.Join(config.G.FilePath, abupath) + downloadPath := filepath.Join(filepath.Base(config.G.FilePath), abupath) + // 相对路径 + relpath := filepath.Join(abupath, "../") + // fileInfo, err := os.Stat(realFilePath) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -32,6 +50,7 @@ func WebConsole(w http.ResponseWriter, r *http.Request) { IsDir bool FileName string DownloadPath string + Relpath string //相对路径 UrlPath string Files []os.DirEntry }{ @@ -39,8 +58,9 @@ func WebConsole(w http.ResponseWriter, r *http.Request) { Loip: config.G.LocalIP, Rundir: config.G.FilePath, DownloadPath: downloadPath, - UrlPath: strings.TrimSuffix(r.URL.Path, "/"), - // UrlPath: r.URL.Path, + Relpath: relpath, + // UrlPath: strings.TrimSuffix(r.URL.Path, "/"), + UrlPath: abupath, } if fileInfo.IsDir() { diff --git a/fssc/main.go b/fssc/main.go index 9a87e3f..a99d571 100644 --- a/fssc/main.go +++ b/fssc/main.go @@ -33,8 +33,7 @@ func sendClient() error { url := fmt.Sprintf("http://%s:%s", config.G.LocalIP, config.G.Port) fmt.Printf("Server address: %s\n", url) - //http.HandleFunc("/", handler.SendHandler) - //http.Handle("/", http.FS()"/static/vfs") + http.HandleFunc("/", handler.SendHandler) // ico http.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "image/x-icon") diff --git a/fssc/web/wbconsole.tmpl b/fssc/web/wbconsole.tmpl index 296eacf..003a31b 100644 --- a/fssc/web/wbconsole.tmpl +++ b/fssc/web/wbconsole.tmpl @@ -2,7 +2,7 @@
-监听目录:{{.DownloadPath}}
-相对目录: {{.Rundir}}
+监听目录:{{.Rundir}}
+相对目录: {{.DownloadPath}}
+