feat(go): Port full Ananta private server to Go architecture

This commit is contained in:
CAtlas0784 committed 2026-10-29 03:12:00 +07:00
1 parent ca2e80f9b7
commit c73d744649
28 files changed
+3585 -57

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
package gateway
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"ananta-ps/internal/config"
)
func TestGatewayDispatch(t *testing.T) {
cfg := &config.Config{
Client: config.ClientConfig{
ServerID: 801,
},
Network: config.NetworkConfig{
AdvertisedHost: "127.0.0.1",
LoginPorts: []int{5200, 5201},
Proxy: config.ProxyConfig{
LoginListPort: 5801,
},
},
}
gw := New(cfg, "../../Ananta.Proxy/proxy/public", "../../Ananta.Proxy/proxy/certs")
// Test LoginList
req := httptest.NewRequest("GET", "/LoginList", nil)
w := httptest.NewRecorder()
gw.handleDispatch(w, req)
resp := w.Result()
if resp.StatusCode != http.StatusOK {
t.Fatalf("expected 200, got %d", resp.StatusCode)
}
body := w.Body.String()
if !strings.Contains(body, "127.0.0.1:5200") {
t.Fatalf("expected 127.0.0.1:5200 in LoginList, got %s", body)
}
// Test ServerList
req = httptest.NewRequest("GET", "/OuterTest1/serverlist.txt", nil)
w = httptest.NewRecorder()
gw.handleDispatch(w, req)
if w.Result().StatusCode != http.StatusOK {
t.Fatalf("expected 200 for serverlist.txt, got %d", w.Result().StatusCode)
}
if !strings.Contains(w.Body.String(), "QA101,Outer,http://127.0.0.1:5801/LoginList,1,14") {
t.Fatalf("unexpected serverlist body: %s", w.Body.String())
}
}