mirror of
https://github.com/Walter-Sparrow/lunar-tear.git
synced 2026-07-02 05:43:41 +03:00
Add authentication server, dev CLI, Docker multi-service setup, and cross-platform improvements
This commit is contained in:
@@ -50,6 +50,7 @@ const resourcesURLOriginal = "https://resources.app.nierreincarnation.com"
|
||||
type OctoHTTPServer struct {
|
||||
mux *http.ServeMux
|
||||
ResourcesBaseURL string // if non-empty and exactly 43 chars, list.bin is rewritten to use this base for asset URLs
|
||||
BaseDir string // root directory containing the assets/ tree; empty means current directory
|
||||
revisions *revisionTracker
|
||||
resolver *assetResolver
|
||||
}
|
||||
@@ -124,12 +125,13 @@ func fileMD5Hex(path string, info os.FileInfo) (string, error) {
|
||||
return sum, nil
|
||||
}
|
||||
|
||||
func NewOctoHTTPServer(resourcesBaseURL string) *OctoHTTPServer {
|
||||
func NewOctoHTTPServer(resourcesBaseURL, baseDir string) *OctoHTTPServer {
|
||||
s := &OctoHTTPServer{
|
||||
mux: http.NewServeMux(),
|
||||
ResourcesBaseURL: resourcesBaseURL,
|
||||
BaseDir: baseDir,
|
||||
revisions: newRevisionTracker(),
|
||||
resolver: newAssetResolver(),
|
||||
resolver: newAssetResolver(baseDir),
|
||||
}
|
||||
s.resolver.Prewarm("0")
|
||||
s.mux.HandleFunc("/", s.handleAll)
|
||||
@@ -226,7 +228,7 @@ func (s *OctoHTTPServer) handleOctoV2(w http.ResponseWriter, r *http.Request, pa
|
||||
requestedRevision := parts[len(parts)-1]
|
||||
if requestedRevision != "" {
|
||||
revision := "0"
|
||||
filePath := "assets/revisions/0/list.bin"
|
||||
filePath := filepath.Join(s.BaseDir, "assets", "revisions", "0", "list.bin")
|
||||
if requestedRevision != revision {
|
||||
log.Printf("[OctoV2] Resource list request revision=%s canonicalized to revision=%s", requestedRevision, revision)
|
||||
}
|
||||
@@ -266,7 +268,7 @@ func (s *OctoHTTPServer) serveOctoV1List(w http.ResponseWriter, r *http.Request,
|
||||
requestedRevision = parts[len(parts)-1]
|
||||
}
|
||||
revision := "0"
|
||||
filePath := "assets/revisions/0/list.bin"
|
||||
filePath := filepath.Join(s.BaseDir, "assets", "revisions", "0", "list.bin")
|
||||
if requestedRevision != revision {
|
||||
log.Printf("[OctoV1] list request revision=%s canonicalized to revision=%s", requestedRevision, revision)
|
||||
}
|
||||
@@ -316,11 +318,11 @@ func (s *OctoHTTPServer) serveUnsoAsset(w http.ResponseWriter, r *http.Request,
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
baseDir := filepath.Join("assets", "revisions")
|
||||
revDir := filepath.Join(s.BaseDir, "assets", "revisions")
|
||||
var triedPaths []string
|
||||
var md5Mismatches []string
|
||||
for _, candidate := range resolution.Candidates {
|
||||
rel, err := filepath.Rel(baseDir, candidate.Path)
|
||||
rel, err := filepath.Rel(revDir, candidate.Path)
|
||||
if err != nil || strings.Contains(rel, "..") || filepath.IsAbs(rel) {
|
||||
continue
|
||||
}
|
||||
@@ -409,9 +411,9 @@ func (s *OctoHTTPServer) serveDatabaseBinE(w http.ResponseWriter, r *http.Reques
|
||||
break
|
||||
}
|
||||
}
|
||||
filePath := "assets/release/database.bin.e"
|
||||
filePath := filepath.Join(s.BaseDir, "assets", "release", "database.bin.e")
|
||||
if version != "" {
|
||||
vPath := "assets/release/" + version + ".bin.e"
|
||||
vPath := filepath.Join(s.BaseDir, "assets", "release", version+".bin.e")
|
||||
if _, err := os.Stat(vPath); err == nil {
|
||||
filePath = vPath
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user