mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
Fix: secured loading path under windows (#851)
* Fix: secured loading path under windows * fix sign file foramts
This commit is contained in:
parent
ae840dca6f
commit
b8af713998
@ -7,6 +7,7 @@ import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/v2fly/BrowserBridge/handler"
|
||||
@ -79,7 +80,7 @@ func BridgeResource(rw http.ResponseWriter, r *http.Request, path string) {
|
||||
if content == "" {
|
||||
content = "index.html"
|
||||
}
|
||||
data, err := securedload.GetAssetSecured("browserforwarder/" + content)
|
||||
data, err := securedload.GetAssetSecured(filepath.Join("browserforwarder", content))
|
||||
if err != nil {
|
||||
err = newError("cannot load necessary resources").Base(err)
|
||||
http.Error(rw, err.Error(), http.StatusForbidden)
|
||||
|
@ -20,16 +20,16 @@ type EmbeddedHashProtectedLoader struct {
|
||||
|
||||
func (e EmbeddedHashProtectedLoader) VerifyAndLoad(filename string) ([]byte, error) {
|
||||
platformFileName := filepath.FromSlash(filename)
|
||||
filecontent, err := filesystem.ReadFile(platform.GetAssetLocation(platformFileName))
|
||||
fileContent, err := filesystem.ReadFile(platform.GetAssetLocation(platformFileName))
|
||||
if err != nil {
|
||||
return nil, newError("Cannot find file", filename).Base(err)
|
||||
}
|
||||
fileHash := sha256.Sum256(filecontent)
|
||||
fileHash := sha256.Sum256(fileContent)
|
||||
fileHashAsString := hex.EncodeToString(fileHash[:])
|
||||
if filenameverified, ok := e.checkedFile[fileHashAsString]; ok {
|
||||
for _, filenameVerifiedIndividual := range strings.Split(filenameverified, ";") {
|
||||
if fileNameVerified, ok := e.checkedFile[fileHashAsString]; ok {
|
||||
for _, filenameVerifiedIndividual := range strings.Split(fileNameVerified, ";") {
|
||||
if strings.HasSuffix(filenameVerifiedIndividual, filename) {
|
||||
return filecontent, nil
|
||||
return fileContent, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package securedload
|
||||
|
||||
func GetAssetSecured(name string) ([]byte, error) {
|
||||
|
||||
var err error
|
||||
for k, v := range knownProtectedLoader {
|
||||
loadedData, errLoad := v.VerifyAndLoad(name)
|
||||
|
Loading…
Reference in New Issue
Block a user