feat: make hook redirect IP configurable from launcher
The DLL now reads openfut.cfg from its own directory on DLL_PROCESS_ATTACH and uses the IP it contains as the redirect target instead of hardcoding 127.0.0.1. Falls back to 127.0.0.1 if the file is absent. The launcher writes openfut.cfg alongside version.dll when deploying, and the Setup tab exposes a "Redirect IP" field with an "Update" button that rewrites openfut.cfg in-place without redeploying the DLL. Useful when running the emulator on a different machine on the LAN. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+41
-1
@@ -315,7 +315,11 @@ impl LauncherApp {
|
||||
ui.colored_label(Color32::from_rgb(220, 60, 60), "✘ Not deployed");
|
||||
ui.add_space(8.0);
|
||||
if ui.add_enabled(dll_built, egui::Button::new("Deploy")).clicked() {
|
||||
match setup::deploy_hook_dll(dll_src, game_dir) {
|
||||
match setup::deploy_hook_dll(
|
||||
dll_src,
|
||||
game_dir,
|
||||
&self.config.hook_redirect_ip,
|
||||
) {
|
||||
Ok(()) => {
|
||||
self.setup_message = Some((true, "Hook DLL deployed as version.dll.".into()));
|
||||
self.hook_deployed = true;
|
||||
@@ -326,6 +330,38 @@ impl LauncherApp {
|
||||
}
|
||||
});
|
||||
|
||||
ui.add_space(8.0);
|
||||
|
||||
// IP configuration — always editable; Update writes openfut.cfg in-place
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Redirect IP:");
|
||||
let changed = ui
|
||||
.add(egui::TextEdit::singleline(&mut self.config.hook_redirect_ip)
|
||||
.desired_width(160.0))
|
||||
.changed();
|
||||
if changed {
|
||||
self.config_dirty = true;
|
||||
}
|
||||
if ui.add_enabled(self.hook_deployed, egui::Button::new("Update")).clicked() {
|
||||
match setup::update_hook_config(
|
||||
Path::new(&self.config.fifa_game_dir),
|
||||
&self.config.hook_redirect_ip,
|
||||
) {
|
||||
Ok(()) => {
|
||||
self.config.save();
|
||||
self.config_dirty = false;
|
||||
self.setup_message = Some((true, format!(
|
||||
"Config updated — hook will redirect to {}.",
|
||||
self.config.hook_redirect_ip
|
||||
)));
|
||||
}
|
||||
Err(e) => self.setup_message = Some((false, format!("Failed: {e}"))),
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.label(egui::RichText::new("Tip: use 127.0.0.1 if the emulator is on this machine, or the LAN IP if it's on another.")
|
||||
.weak().small());
|
||||
|
||||
ui.add_space(8.0);
|
||||
ui.separator();
|
||||
ui.add_space(4.0);
|
||||
@@ -461,6 +497,10 @@ impl LauncherApp {
|
||||
ui.label("FIFA 23 game dir:");
|
||||
changed |= ui.text_edit_singleline(&mut self.config.fifa_game_dir).changed();
|
||||
ui.end_row();
|
||||
|
||||
ui.label("Redirect IP:");
|
||||
changed |= ui.text_edit_singleline(&mut self.config.hook_redirect_ip).changed();
|
||||
ui.end_row();
|
||||
});
|
||||
|
||||
if changed {
|
||||
|
||||
@@ -15,6 +15,8 @@ pub struct LauncherConfig {
|
||||
pub hook_dll_path: String,
|
||||
/// FIFA 23 game folder inside the Proton prefix (where the DLL is deployed).
|
||||
pub fifa_game_dir: String,
|
||||
/// IP the hook DLL redirects EA hostnames to (written to openfut.cfg).
|
||||
pub hook_redirect_ip: String,
|
||||
}
|
||||
|
||||
impl Default for LauncherConfig {
|
||||
@@ -54,6 +56,7 @@ impl Default for LauncherConfig {
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.into(),
|
||||
hook_redirect_ip: "127.0.0.1".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-6
@@ -68,10 +68,11 @@ fn run_elevated(script: &str) -> anyhow::Result<()> {
|
||||
|
||||
// ── DLL hook deployment ───────────────────────────────────────────────────────
|
||||
|
||||
/// Deploy openfut_hook.dll into the FIFA 23 game directory.
|
||||
/// Uses a name that FIFA 23 loads but doesn't need from system: `version.dll`.
|
||||
/// Proton will prefer the local copy over the system one.
|
||||
pub fn deploy_hook_dll(dll_src: &Path, game_dir: &Path) -> anyhow::Result<()> {
|
||||
/// Deploy openfut_hook.dll into the FIFA 23 game directory and write
|
||||
/// openfut.cfg with the redirect IP the hook will use.
|
||||
/// Uses `version.dll` as the hijack name — FIFA 23 loads it but defers to
|
||||
/// the system copy, so Proton picks up our local one first.
|
||||
pub fn deploy_hook_dll(dll_src: &Path, game_dir: &Path, redirect_ip: &str) -> anyhow::Result<()> {
|
||||
if !dll_src.exists() {
|
||||
anyhow::bail!(
|
||||
"Hook DLL not found at {}. Build it first with:\n\
|
||||
@@ -81,8 +82,18 @@ pub fn deploy_hook_dll(dll_src: &Path, game_dir: &Path) -> anyhow::Result<()> {
|
||||
);
|
||||
}
|
||||
std::fs::create_dir_all(game_dir)?;
|
||||
let dest = game_dir.join("version.dll");
|
||||
std::fs::copy(dll_src, &dest)?;
|
||||
std::fs::copy(dll_src, game_dir.join("version.dll"))?;
|
||||
std::fs::write(game_dir.join("openfut.cfg"), redirect_ip)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Update only openfut.cfg without redeploying the DLL.
|
||||
pub fn update_hook_config(game_dir: &Path, redirect_ip: &str) -> anyhow::Result<()> {
|
||||
let cfg = game_dir.join("openfut.cfg");
|
||||
if !cfg.exists() {
|
||||
anyhow::bail!("Hook DLL not deployed yet — deploy first.");
|
||||
}
|
||||
std::fs::write(cfg, redirect_ip)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user