From a4f7353ce6688d69c636bbff8e18f03997ae562f Mon Sep 17 00:00:00 2001 From: meehl <12648828+meehl@users.noreply.github.com> Date: Sat, 17 Oct 2026 17:05:13 +0200 Subject: [PATCH] Implement missing `luasocket` method --- src/pob/modules/luasocket.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/pob/modules/luasocket.rs b/src/pob/modules/luasocket.rs index b3cbcd3..85b46be 100644 --- a/src/pob/modules/luasocket.rs +++ b/src/pob/modules/luasocket.rs @@ -95,6 +95,24 @@ impl UserData for LuaTcpIp4Server { Ok(()) }); + methods.add_method_mut( + "setoption", + |_, _this, (name, _value): (String, mlua::Value)| { + match name.as_str() { + "reuseaddr" => { + // NOTE: ignore for now. not sure why this is even set by PoB. + // `TcpListener` doesn't give access to this options so if this + // turns out to be important, switch to `socket2` crate which + // offers more advanced configurations options. + Ok(1) + } + _ => Err(mlua::Error::external(format!( + "unsupported socket option `{name}`" + ))), + } + }, + ); + methods.add_method_mut("accept", |lua, this, ()| { let Some(listener) = &this.listener else { return Err(mlua::Error::external("socket is not bound"));