fix(seasons): derive the FUT web-file base from openfut.cfg, not a lab IP
`STAGING_FUT_BASE` hardcoded `http://10.10.0.120:8110/fut/` into the hook binary, so the base-supply rewriter only worked on one machine and could not be merged. The prefix now comes from the same `openfut.cfg` / `openfut-common` source of truth as every redirect target: `fut_content_base()` builds `http://<host>:<fut_content_port>/fut/` from the configured host. `OpenFutPorts` gains `fut_content` with a named default (`default_ports::FUT_CONTENT = 8110`) and an optional `fut_content_port=` key, matching how every other OpenFUT port is already handled. A cfg written before the key existed still parses and takes the default — failing it would disarm the network redirect too. Arming fails SAFE: an absent or unusable config arms nothing and the rewriter leaves every url exactly as the client built it, rather than pointing it at a guessed host. This also adds the `openfut-common` dependency to the hook on this branch; main already has it. Proof: the cross-built artifact no longer contains the string 10.10.0.120 (previously compiled in), openfut-common is green at 16 tests including the new config-derived-base and backward-compatibility cases, and the launcher builds.
This commit is contained in:
@@ -53,6 +53,12 @@ pub mod default_ports {
|
||||
pub const BLAZE_REDIRECTOR: u16 = 42127;
|
||||
/// OpenFUT FIFA 17 Blaze main listener.
|
||||
pub const BLAZE_MAIN: u16 = 42130;
|
||||
/// OpenFUT FUT web-file (CDN) content server. Unlike the others this is not
|
||||
/// an EA redirect target: the client never dials it directly, because its
|
||||
/// `RS4::ServerSettings` CDN base arrives EMPTY in the emulator. The hook
|
||||
/// supplies the missing `<base>/fut/` prefix, and the base is built from the
|
||||
/// configured server host plus this port.
|
||||
pub const FUT_CONTENT: u16 = 8110;
|
||||
}
|
||||
|
||||
/// OpenFUT destination ports. Each field is where an intercepted EA source port
|
||||
@@ -66,6 +72,9 @@ pub struct OpenFutPorts {
|
||||
pub blaze_redirector: u16,
|
||||
/// Destination for EA :42127 traffic (Blaze main).
|
||||
pub blaze_main: u16,
|
||||
/// FUT web-file content server. Not a redirect destination — see
|
||||
/// [`default_ports::FUT_CONTENT`].
|
||||
pub fut_content: u16,
|
||||
}
|
||||
|
||||
impl Default for OpenFutPorts {
|
||||
@@ -74,6 +83,7 @@ impl Default for OpenFutPorts {
|
||||
https: default_ports::HTTPS,
|
||||
blaze_redirector: default_ports::BLAZE_REDIRECTOR,
|
||||
blaze_main: default_ports::BLAZE_MAIN,
|
||||
fut_content: default_ports::FUT_CONTENT,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,6 +219,7 @@ impl ServerConfig {
|
||||
"https_port" => ports.https = parse_port(value)?,
|
||||
"blaze_redirector_port" => ports.blaze_redirector = parse_port(value)?,
|
||||
"blaze_main_port" => ports.blaze_main = parse_port(value)?,
|
||||
"fut_content_port" => ports.fut_content = parse_port(value)?,
|
||||
other => {
|
||||
return Err(ConfigError::MalformedConfig(format!(
|
||||
"line {}: unknown key '{other}'",
|
||||
@@ -225,8 +236,27 @@ impl ServerConfig {
|
||||
/// Serialize to the structured `openfut.cfg` format.
|
||||
pub fn to_cfg_string(&self) -> String {
|
||||
format!(
|
||||
"host={}\nhttps_port={}\nblaze_redirector_port={}\nblaze_main_port={}\n",
|
||||
self.host, self.ports.https, self.ports.blaze_redirector, self.ports.blaze_main
|
||||
"host={}\nhttps_port={}\nblaze_redirector_port={}\nblaze_main_port={}\nfut_content_port={}\n",
|
||||
self.host,
|
||||
self.ports.https,
|
||||
self.ports.blaze_redirector,
|
||||
self.ports.blaze_main,
|
||||
self.ports.fut_content
|
||||
)
|
||||
}
|
||||
|
||||
/// Base URL the FUT web-file (CDN) prefix is built from, e.g.
|
||||
/// `http://10.10.0.120:8110/fut/`.
|
||||
///
|
||||
/// The client's `RS4::ServerSettings` CDN base arrives EMPTY in the emulator,
|
||||
/// so FUT web-file urls reach the download entry point as bare relative paths
|
||||
/// and fail. The hook supplies this prefix. Built from the SAME configured
|
||||
/// host as every other redirect, so a lab address is never compiled in.
|
||||
pub fn fut_content_base(&self) -> String {
|
||||
format!(
|
||||
"http://{}:{}/fut/",
|
||||
self.host.trim(),
|
||||
self.ports.fut_content
|
||||
)
|
||||
}
|
||||
|
||||
@@ -414,12 +444,36 @@ mod tests {
|
||||
https: 8443,
|
||||
blaze_redirector: 10041,
|
||||
blaze_main: 42127,
|
||||
fut_content: 8110,
|
||||
},
|
||||
};
|
||||
let s = c.to_cfg_string();
|
||||
assert_eq!(ServerConfig::parse(&s).unwrap(), c);
|
||||
}
|
||||
|
||||
/// The FUT web-file prefix follows the CONFIGURED server, so no lab address
|
||||
/// is ever compiled into the hook.
|
||||
#[test]
|
||||
fn fut_content_base_follows_the_configured_host() {
|
||||
let c = ServerConfig::parse("host=192.168.1.50\n").unwrap();
|
||||
assert_eq!(c.fut_content_base(), "http://192.168.1.50:8110/fut/");
|
||||
|
||||
let c = ServerConfig::parse("host=fut.mylan.home\nfut_content_port=9110\n").unwrap();
|
||||
assert_eq!(c.fut_content_base(), "http://fut.mylan.home:9110/fut/");
|
||||
}
|
||||
|
||||
/// A cfg written before `fut_content_port` existed must still parse, taking
|
||||
/// the default rather than failing the whole config (which would disarm the
|
||||
/// network redirect too).
|
||||
#[test]
|
||||
fn cfg_without_content_port_takes_the_default() {
|
||||
let c = ServerConfig::parse(
|
||||
"host=10.0.0.5\nhttps_port=8443\nblaze_redirector_port=42127\nblaze_main_port=42130\n",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(c.ports.fut_content, default_ports::FUT_CONTENT);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn configured_ipv4_becomes_correct_sockaddr() {
|
||||
// Resolve an IPv4 literal and confirm the sin_addr value.
|
||||
|
||||
Reference in New Issue
Block a user