ruffle-rs / ruffle

A Flash Player emulator written in Rust
https://ruffle.rs
Other
15.4k stars 795 forks source link

Socket connection not working in game Thorvarium #17277

Open MuriloucoLouco opened 1 month ago

MuriloucoLouco commented 1 month ago

Describe the bug

When attempting to connect to a XMLsocket server, the game shows the error The _socket.connect() method call returned false... No errors where reported on the console log. The game was ran with ruffle --tcp-connections allow --socket-allow "127.0.0.1:9000", and just ruffle (no prompt showed up).

Expected behavior

The game should start a socket connection to a server (a local server, 127.0.0.1:9000). This error does not occur in Adobe Flash Player 7, nor Newgounds player. It connects perfectly (in my private server, or just running nc -lvp 9000).

Content Location

https://github.com/MuriloucoLouco/thorvarium/raw/main/swf/1.3/thorvarium1.3_patched.swf

Affected platform

Desktop app

Operating system

Linux

Browser

No response

Additional information

No response

Lord-McSweeney commented 1 month ago

This is failing even before it enters any socket code. The game uses a weird custom socket class:

FFDK.Socket = function(session)
{
    this._session = session;
    this._status = "closed";
};
FFDK.Socket.valueOf = function()
{
    return "[FFDK.Socket Constructor]";
};
FFDK.Socket.prototype.toString = function()
{
    return "[FFDK.Socket (status=" + this._status + ")]";
};
FFDK.Socket.prototype._type = "FFDK.Socket";
FFDK.Socket.prototype.__proto__ = XMLSocket.prototype;
FFDK.Socket.prototype.connectXMLSocket = XMLSocket.prototype.connect;
FFDK.Socket.prototype.closeXMLSocket = XMLSocket.prototype.close;
FFDK.Socket.prototype.getStatus = function()
{
    return this._status;
};
FFDK.Socket.prototype.getSession = function()
{
    return this._session;
};
FFDK.Socket.prototype.connect = function(host, port)
{
    this._status = "opening";
    var r = this.connectXMLSocket(host,port);
    if(!r)
    {
        this._status = "closed";
    }
    return r;
};

Despite XmlSocket using NativeObject, it seems that with this type of fiddling it fails to properly fill out the native data.