docs & feat: add license & attribution notice (Apache-2.0 / GPL-3.0) and core system enhancements

This commit is contained in:
CAtlas0784 committed 2026-11-01 20:14:36 +07:00
1 parent 507836d367
commit ce6aabfc55
47 files changed
+5674 -724

No files matched your search

@@ -0,0 +1,46 @@
package sdkserver
import (
"encoding/base64"
"net/http/httptest"
"testing"
"gac-hkrpg-go/internal/common"
"gac-hkrpg-go/protocol/proto"
google "google.golang.org/protobuf/proto"
)
func TestAndroidGatewayResolvesBuildSuffix(t *testing.T) {
const version = "OSBETAAndroid4.6.54_D16927089_A16927089_L16927077"
metadata := VersionConfig{AssetBundleURL: "https://example.test/assets", AssetBundleURLB: "https://example.test/backup", ExResourceURL: "https://example.test/data", LuaURL: "https://example.test/lua", IfixURL: "https://example.test/ifix", LuaVersion: "123", IfixVersion: "4"}
state := &appState{runtime: common.RuntimeConfig{PublicGameHost: "127.0.0.1", GamePort: 23301}, hotfixMap: map[string]VersionConfig{
"OSBETAAndroid4.6.54": metadata,
version: {}, // An earlier failed lookup may have cached an empty entry.
}}
rec := httptest.NewRecorder()
queryGateway(state)(rec, httptest.NewRequest("GET", "/query_gateway?version="+version, nil))
if rec.Code != 200 {
t.Fatalf("HTTP status = %d", rec.Code)
}
wire, err := base64.StdEncoding.DecodeString(rec.Body.String())
if err != nil {
t.Fatal(err)
}
var got proto.Gateserver
if err := google.Unmarshal(wire, &got); err != nil {
t.Fatal(err)
}
if got.Ip != "127.0.0.1" || got.Port != 23301 || got.AssetBundleUrl != metadata.AssetBundleURL || got.AssetBundleUrlB != metadata.AssetBundleURLB || got.ExResourceUrl != metadata.ExResourceURL || got.LuaUrl != metadata.LuaURL || got.IfixUrl != metadata.IfixURL || got.LuaVersion != metadata.LuaVersion || got.IfixVersion != metadata.IfixVersion {
t.Fatalf("unexpected gateway response: %v", &got)
}
}
func TestAndroidGatewayPrefersExactBuildMetadata(t *testing.T) {
state := &appState{hotfixMap: map[string]VersionConfig{
"OSBETAAndroid4.6.54": {AssetBundleURL: "release"},
"OSBETAAndroid4.6.54_D1": {AssetBundleURL: "specific"},
}}
if got := state.getOrInsertHotfix("OSBETAAndroid4.6.54_D1", ""); got.AssetBundleURL != "specific" {
t.Fatalf("exact build lost: %+v", got)
}
}