websocket_restrict.md 1.8 KB


Some people may wanna impose some restrictions on websocket-connected users, one of deez nuts things could be limiting the ports they can use. Read more about Unreal's websocket support right here.

Since websocket support for non-SSL ports works right out of the box, you're going to need a new listen block for non-SSL connections from websocket users. I used port 8080 for the keks but you can really use as many as you want.

Config block:

listen {
    ip *;
    port 8080;
    options {
        websocket {
            // One of these must be specified, depending on your client
            //type text;
            //type binary;
websocket_restrict {
    port 8080;
    //port 8443; // If you have an SSL listen block too
    zlinetime 60;
    channels {
        "#chan1"; // Don't forget the "" to make sure Unreal doesn't interpret it as a comment ;]

Now, if any websocket users connect to a port that isn't 8080 their IP will get GZ-Lined for the amount of seconds specified with zlinetime (defaults to 60). The other way around is true as well; regular clients connecting to a websocket port will be awarded the same GZ-Line. I originally had to do that for websocket users cuz they aren't fully online yet, so the special frames wouldn't be formed and sent. This resulted in the client sending the GET / command about 5 times and that resulted in 5 snotices too. =] I did the same for regular clients to remain consistent.

The channels list is optional; if omitted there will be no channel restrictions, otherwise they can only join the specified ones. They also only apply to websocket users, so regular clients can join their channels too.