[RELEASE] node-sro-proxy - Opensource middleware/security layer

12/13/2020 15:53 Legolas_#16
Do you think add multiagent support? Awesome project :)
12/14/2020 20:28 Otakanikaru#17
Quote:
Originally Posted by Legolas_ View Post
Do you think add multiagent support? Awesome project :)
i'll see what I can do about it - dont have myself an multi-agent server setup as I'm ok running my one on 1k slots only..

If anyone minds telling me which opcode controls this ill do it.
12/14/2020 20:56 JellyBitz#18
Quote:
Originally Posted by Artuuro_lv View Post
If anyone minds telling me which opcode controls this ill do it.
It's not an opcode. It's handled by the login queue linked to the QUEUE_ID sent from gameserver which specifies the agent:port to the client to connect.

That beind said, there is two options:
- Run a new agent server with the specified port (you'll change only the IP when you'll going to do the redirection).
- Save the QUEUE_ID link and create the proxy connection depending on what token it's sent to the agent server (dynamic proxy connection).
12/14/2020 23:17 Otakanikaru#19
Quote:
Originally Posted by JellyBitz View Post
It's not an opcode. It's handled by the login queue linked to the QUEUE_ID sent from gameserver which specifies the agent:port to the client to connect.

That beind said, there is two options:
- Run a new agent server with the specified port (you'll change only the IP when you'll going to do the redirection).
- Save the QUEUE_ID link and create the proxy connection depending on what token it's sent to the agent server (dynamic proxy connection).
Cool - thanks, I'll add that in next commit.

Side note - I've just actually started test-driving production version on my project, so far seems to handle connections very well.
Users, be aware there's something wrong about setting players online/offline correctly in DB - it doesn't affect the proxy from working though - investigating this atm.
01/18/2021 13:57 Otakanikaru#20
[Changelog]
- Each module can now be configured over process.env (see ".bat" files)
- Better online/offline handling
- Fixed HWID limitation

Side note:
I have now been running this on my own project (production) for about a month - connections are very smooth and low latency, increasing players count doesn't affect proxy's performance, HWID / IP blacklisting works, HWID limits works (one thing to mention is that you might need to set all users connected = 0 when you restart the proxy - depends how you switched it off).

Another side note:
I'm considering creating custom features (as a service) on demand and might as well provide this as a SaaS (hosted solution) - anyone interested please contact me on my discord "Artuuro#6727".

Quote:
Originally Posted by Legolas_ View Post
Do you think add multiagent support? Awesome project :)
Figured out it is quite simple
You can use this version of "src/controllers/LoginResponse.js" for multi-agent support, pay attention to comments i've left.

Code:
async function LoginResponse({ config, stream, memory, api }, packet) {
    const { AgentServer } = config.REDIRECT;
    const { writer, reader } = stream;
    const read = new reader(packet.data);
    const status = read.uint8();
    const { get, put } = api.proxy;
    const username = memory.get('username');

    if (status == 1) {
        const {
            data,
        } = await get(`/instances`, {
            filter: JSON.stringify({ username }),
            limit: 1
        });

        const [instance] = data;

        if (instance) {
            await put(`/instances/${instance.id}`, {
                connected: 1
            });

            const token = read.uint32();
            const host = read.string();

            // E.g. from->to IP 127.0.0.1 -> redirects to 192.168.0.1
            const redirects = {
                '127.0.0.1': '192.168.0.1', 
                '127.0.0.2': '192.168.0.2',

            };
            
//add as many agents u want

            const write = new writer();

            write.uint8(status);
            write.uint32(token);

            write.string(redirects[host]); // select the redirection rule

            write.uint16(AgentServer.PORT);

            return {
                packet: {
                    ...packet,
                    data: write.toData(),
                }
            };
        }
    }

    return { exit: true };
}

export default LoginResponse;
JS Saves the day.

UPDATE
- Added simple bot detection (requires client locale 51)
- NoticeRequest packet rewrite
- Login packet fix
- IP:PORT redirection rule system (allows multiple agents, downloadservers)
01/20/2021 17:27 Otakanikaru#21
[changelog]
- Updated thread information
- Added .sh launchers to the repo
- Fixed some minor bugs
- Download missing data folder from here: [Only registered and activated users can see links. Click Here To Register...] (required for IP geolocation and PROXY data access) - you can download your own copies from ip2location otherwise.