Unverified Commit f156e385 authored by Lemon-miaow's avatar Lemon-miaow
Browse files

fix(panel): 服务器地址改为一键复制并带上非默认游戏端口,玩家列表去掉无意义的连接地址列,管理员列改称内部地址

parent bb9c2168
Loading
Loading
Loading
Loading
+1 −1
Changes for cmd/felis/api.go: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -392,7 +392,7 @@ func cmdAPI(args []string, stdout, stderr io.Writer) int {
	externalHandler := panel.Handler(a.ExternalHandler(), cfg.Server.RootDomain,
		defaultPanelHostname(cfg.Server.RootDomain, cfg.Auth.PanelHostname),
		defaultAdminHostname(cfg.Server.RootDomain, cfg.Auth.AdminHostname),
		resolvedVersion())
		cfg.Velocity.GamePort, resolvedVersion())
	internalSrv := newAPIServer(*internalAddr, a.InternalHandler())
	externalSrv := newAPIServer(cfg.Server.Listen, externalHandler)

+2 −0
Changes for deploy/bootstrap.sh: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3091,6 +3091,8 @@ egress_mode = "${FELIS_EGRESS_MODE}"
# into k3s by build_game_stack below, so setup never has to be told "build these first".
login_image = "${FELIS_LIMBO_IMAGE}"
lobby_image = "${FELIS_LOBBY_IMAGE}"
# The public port players connect on; the panel shows it in server addresses.
game_port = ${FELIS_GAME_PORT}

[registry]
url = "${REGISTRY_URL}"
+2 −1
Changes for deploy/bootstrap_test.sh: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1412,7 +1412,7 @@ run_write() { # out-file
    persisted_auth_source_blocks() { :; }
    . "$FNFILE"
    FELIS_ROOT_DOMAIN=r.example.com DB_USER=u DB_PASSWORD=p DB_NAME=d MINECRAFT_NS=minecraft \
    FELIS_EGRESS_MODE=nodeport FELIS_LIMBO_IMAGE=li FELIS_LOBBY_IMAGE=lo \
    FELIS_EGRESS_MODE=nodeport FELIS_LIMBO_IMAGE=li FELIS_LOBBY_IMAGE=lo FELIS_GAME_PORT=25570 \
    REGISTRY_URL=registry.felis.svc:5000 BUILD_NS=felis-build FELIS_ARCHIVE_LOCAL_PATH=/a \
    FELIS_OFFSITE_BUCKET= write_felis_toml "$OUT_TOML" 127.0.0.1'
}
@@ -1435,6 +1435,7 @@ expect "a re-run carries the archive retention window" 'retention = "30d"' "$out
expect "a re-run carries the on-demand backup count" 'manual_keep = 3' "$out"
expect "a re-run carries the on-demand backup cooldown" 'manual_cooldown = "1h"' "$out"
expect "the archive mount stays installer-owned" 'local_path = "/a"' "$out"
expect "the panel learns the public game port" 'game_port = 25570' "$out"
expect "a re-run keeps the off-site bucket, set apart from the next section" '[offsite]
endpoint = "https://objects.example"
bucket = "felis-offsite"
+7 −0
Changes for internal/config/config.go: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -108,6 +108,10 @@ type VelocityConfig struct {
	// LobbyImage is the container image for the always-on "lobby" hub (Paper plus
	// the felis-paper /menu plugin). Same skip-when-empty contract as LoginImage.
	LobbyImage string `toml:"lobby_image"`
	// GamePort is the public TCP port the proxy accepts players on (bootstrap's
	// FELIS_GAME_PORT). The panel adds it to the server addresses players copy
	// when it is not Minecraft's default; 0 means that default, 25565.
	GamePort int `toml:"game_port"`
}

// AuthConfig is the [auth] table: the two privileged faces and the access-JWT
@@ -459,6 +463,9 @@ func (c *Config) Validate() error {
	default:
		return fmt.Errorf("config: [registry] build_user_namespaces %q must be auto, on or off", c.Registry.BuildUserNamespaces)
	}
	if p := c.Velocity.GamePort; p < 0 || p > 65535 {
		return fmt.Errorf("config: [velocity] game_port %d must be 1-65535 (0 keeps 25565)", p)
	}
	if n := c.Registry.MaxConcurrentBuilds; n < 0 || n > 6 {
		return fmt.Errorf("config: [registry] max_concurrent_builds %d must be 1-6 (0 keeps 2)", n)
	}
+19 −0
Changes for internal/config/config_test.go: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -117,6 +117,25 @@ build_user_namespaces = "yes"
	}
}

func TestLoadGamePort(t *testing.T) {
	base := `
[server]
root_domain = "mc.example.net"
[database]
url = "postgres://felis@db/felis"
[velocity]
`
	cfg, err := config.Load(writeTOML(t, base+"game_port = 25570\n"))
	if err != nil || cfg.Velocity.GamePort != 25570 {
		t.Fatalf("game_port 25570: cfg=%+v err=%v", cfg, err)
	}
	for _, bad := range []string{"-1", "65536"} {
		if _, err := config.Load(writeTOML(t, base+"game_port = "+bad+"\n")); err == nil || !strings.Contains(err.Error(), "game_port") {
			t.Errorf("game_port %s: err = %v, want it rejected", bad, err)
		}
	}
}

func TestLoadAppliesDefaults(t *testing.T) {
	cfg, err := config.Load(writeTOML(t, `
[server]
Loading