OpenSim-NGC / OpenSim-Tranquillity

OpenSim Core ++. Provides Bug Fixes and some new ideas that enhance the reliability and performance of OpenSim Core Yeti.
Other
23 stars 13 forks source link

Inter-region script to script http fails when regions are in same server - works with 0.9.2.2 broken in 0.9.3 merge #82

Open renevega opened 2 months ago

renevega commented 2 months ago

I see many script warnings about http requests being filtered. It happens when a script communicates via http to other scripts. This does not happen in 0.9.2.2 dotnet. Someone changed the code that determines if an http request should be denied when it is directed to a local address (same server). Though that is important, there used to be a built-in exception to permit local_address:anyport/lslhttp[s]/* because that pattern represents a request to a script.

Unfortunately, the "OutboundDisallowForUserScriptsExcept = ..." setting has no syntax to specify this pattern explicitly in 0.9.3/NGC. There are already several special case routing checks for /lslhttp[s]/ in several modules, and the same internal exception should be present in the filter checking code.

This current behavior breaks many product scripts that communicate across regions.

mdickson commented 2 months ago

Can I get an example of the script warning text being logged. It will help track down whats changed

renevega commented 2 months ago

[09:30] llHttpRequest: Request to http://ns5001390.ip-192-95-32.net:9023/lslhttp/2e6b2734-96d2-41c4-b147-301f96848fcc/ disallowed by filter [09:30] llHttpRequest: Request to http://ns5001390.ip-192-95-32.net:9023/lslhttp/2e6b2734-96d2-41c4-b147-301f96848fcc/ disallowed by filter

This is an llHTTPRequest to a scripted object in same region. Will fail if request is to any region same or other in the same server. Will succeed if sent to a region in a different server.

renevega commented 2 months ago

Look in /OpenSim/Framework/OutboundUrlFilter.cs

renevega commented 2 months ago

Set up two objects: Sender and Receiver. Place the following scripts in their respective object. URL Sender:

string  MyURL = "";
default
{
    state_entry()
    {
        llSay( 0, "Sender ready");
    }

    touch_start(integer num)
    {
        // Touch to start the process
        llRequestURL();
    }

    http_request(key qid, string method, string body)
    {
        if (method == URL_REQUEST_GRANTED)
        {
            MyURL = body;
            llSay(999, MyURL);
        }

        else if (method == "POST")
        {
            // respond to the ping
            llHTTPResponse(qid, 202, "pos," + (string)(llGetRegionCorner() + llGetPos()));
        }
    }
}

URL Receiver:

string  SenderURL = "";

default
{
    state_entry()
    {
        llSay( 0, "Listening");
        llListen(999, "", "", "");
    }

    touch_start(integer num)
    {
        // Touch to reset and stop the procesws
        llResetScript();
    }

    listen(integer chan, string name, key id, string msg)
    {
        // The sender gives a URL for inter/intrea region comms.
        if (llSubStringIndex(msg, "http") == 0)
        {
            SenderURL = msg;
            llSay(0, "Sender URL = " + msg);
            llSetTimerEvent(5.0);
        }
    }

    timer()
    {
        // Ping the Sender
        key rid = llHTTPRequest(SenderURL, [HTTP_METHOD, "POST"], "ping");
        if (rid == NULL_KEY)
        {
            llSay(0, "HTTP send failed");
            llSetTimerEvent(0);
        }
    }

    http_response(key reqid, integer status, list metadata, string body)
    {
        llSay(0, "response status=" +(string)status +"  body=" +body);
    }
}

When it works (as in NGC 8937, output looks like this upon touch of sender object: [17:14] Rcvr: Listening [17:14] Rcvr: Sender URL = http://discoverygrid.net:9001/lslhttp/c07463ba-344a-45ff-ad76-30ed8a81fbb7/ [17:14] Rcvr: response status=202 body=pos,<236218.725113, 252504.739662, 147.077545> [17:14] Rcvr: response status=202 body=pos,<236218.725113, 252504.739662, 147.077545>


(touch receiver object) [17:14] Rcvr: Listening

When it fails, as in 8915 to 8940, output looks like this: (touch sender) [17:17] Rcvr: Listening [17:17] Rcvr: Sender URL = http://ns567030.ip-51-79-21.net:9001/lslhttp/3cacf771-956d-4477-8456-99cc33c7a046/ with script errors; 7:17] llHttpRequest: Request to http://ns567030.ip-51-79-21.net:9001/lslhttp/3cacf771-956d-4477-8456-99cc33c7a046/ disallowed by filter

renevega commented 2 months ago

branch feature/fix-lslhttp