fix: sync current handlers, repair relic data and restore visible launcher consoles

This commit is contained in:
CAtlas0784 committed 2026-10-16 22:19:52 +07:00
1 parent 163d4433e6
commit 74f3c4411b
46 files changed
+4599 -1402

No files matched your search

+16 -12
View File
@@ -1,5 +1,5 @@
// Package sdkserver is the Go port of the Rust sdkserver: HTTP dispatch +
// auth + SRTools save upload, listening on :21000.
// auth + SRTools save upload, using the shared runtime configuration.
package sdkserver
import (
@@ -11,13 +11,12 @@ import (
"os"
"sync"
"gac-hkrpg-go/internal/common"
google "google.golang.org/protobuf/proto"
goproto "gac-hkrpg-go/protocol/proto"
)
const Port = 21000
// VersionConfig is one entry of versions.json.
type VersionConfig struct {
AssetBundleURL string `json:"asset_bundle_url"`
@@ -27,6 +26,7 @@ type VersionConfig struct {
}
type appState struct {
runtime common.RuntimeConfig
mu sync.Mutex
hotfixMap map[string]VersionConfig
}
@@ -129,7 +129,7 @@ func fetchHotfix(version, dispatchSeed string) (VersionConfig, error) {
}, nil
}
// parseVersionString extracts region/branch, e.g. "OSBETAWin4.6.51" -> OS,BETA.
// parseVersionString extracts region/branch, e.g. a version with the OSBETAWin prefix -> OS,BETA.
func parseVersionString(s string) (string, string) {
branches := []string{"PREbeta", "BETA", "PROD", "DEV", "PRE", "GM", "CECREATION"}
if len(s) < 2 {
@@ -154,14 +154,14 @@ func writeJSON(w http.ResponseWriter, v any) {
_ = json.NewEncoder(w).Encode(v)
}
func queryDispatch(w http.ResponseWriter, _ *http.Request) {
func queryDispatch(w http.ResponseWriter, _ *http.Request, runtime common.RuntimeConfig) {
rsp := &goproto.Dispatch{
Retcode: 0,
RegionList: []*goproto.RegionInfo{{
Name: "GaC hkrpg GO",
Title: "GaC hkrpg GO",
EnvType: "9",
DispatchUrl: fmt.Sprintf("http://127.0.0.1:%d/query_gateway", Port),
DispatchUrl: runtime.PublicSDKURL + "/query_gateway",
}},
}
bin, err := google.Marshal(rsp)
@@ -186,8 +186,8 @@ func queryGateway(state *appState) http.HandlerFunc {
cfg := state.getOrInsertHotfix(version, seed)
rsp := &goproto.Gateserver{
Ip: "127.0.0.1",
Port: 23301,
Ip: state.runtime.PublicGameHost,
Port: uint32(state.runtime.GamePort),
AssetBundleUrl: cfg.AssetBundleURL,
AssetBundleUrlB: cfg.AssetBundleURL,
ExResourceUrl: cfg.ExResourceURL,
@@ -344,11 +344,15 @@ func srToolsSave(w http.ResponseWriter, r *http.Request) {
// Listen starts the HTTP sdkserver.
func Listen() error {
state := &appState{hotfixMap: loadHotfix()}
runtime, err := common.LoadRuntimeConfig()
if err != nil {
return err
}
state := &appState{hotfixMap: loadHotfix(), runtime: runtime}
Log(fmt.Sprintf("loaded %d hotfix versions", len(state.hotfixMap)))
mux := http.NewServeMux()
mux.HandleFunc("/query_dispatch", queryDispatch)
mux.HandleFunc("/query_dispatch", func(w http.ResponseWriter, r *http.Request) { queryDispatch(w, r, runtime) })
mux.HandleFunc("/query_gateway", queryGateway(state))
mux.HandleFunc("/{product_name}/mdk/shield/api/login", func(w http.ResponseWriter, r *http.Request) { loginReply(w) })
mux.HandleFunc("/{product_name}/mdk/shield/api/verify", func(w http.ResponseWriter, r *http.Request) { loginReply(w) })
@@ -366,9 +370,9 @@ func Listen() error {
notFound(w, r)
})
addr := fmt.Sprintf("0.0.0.0:%d", Port)
addr := runtime.SDKAddress()
Log("sdkserver is listening at " + addr)
Log(fmt.Sprintf("REST API Gateway is live at http://localhost:%d/ (for GaC-Srtool)", Port))
Log(fmt.Sprintf("REST API Gateway is live at %s/ (for GaC-Srtool)", runtime.PublicSDKURL))
return http.ListenAndServe(addr, mux)
}