Code Monkey home page Code Monkey logo

nrelay's Introduction

nrelay

A console based modular client for Realm of the Mad God built with Node.js and TypeScript.

Contents

Docs

Docs covering how to create plugins, all implemented packet structures and their members, and some of the object structures can be found in the docs folder.

Install

Prerequisites

Make sure you have Nodejs installed before running nrelay. You will also need Java installed in order for the updater to work.

  1. Clone the repo to your computer
git clone https://github.com/thomas-crane/nrelay.git/
  1. Change directory into the new nrelay directory
cd nrelay
  1. Install the required dependencies
npm install
  1. Install gulp
npm install -g gulp-cli
  1. Run the build task to compile the source into JavaScript. This will produce a folder called dist/
gulp

Note

Step 6 and 7 are optional, but not performing them will restrict how you can run nrelay. See the Run section for more info.

  1. Install nrelay as an npm module. This will let you use nrelay from any directory in the console.
npm install -g
  1. Link the installed module to this folder to automatically update the module when any code changes happen.
npm link

Setup

Now that nrelay is installed, you will need to set up your acc-config.json file. This can be done in a few steps:

  1. Open the nrelay folder in your file explorer
  2. Rename the file acc-config-sample.json to acc-config.json. (Note: Depending on your computer's settings you might not see the .json part of the file name)
  3. Replace the account info with your own account info.
// acc-config-sample.json
{
    "buildVersion": "X25.1.1",              // The current RotMG build version
    "accounts": [
        {
            "alias": "Main Client",         // The name which appears in logs. This is optional.
            "guid": "[email protected]",       // Your RotMG account email.
            "password": "SecretPassWord11", // Your RotMG account password.
            "serverPref": "AsiaSouthEast"   // The preferred server to connect to.
        }
    ]
}

If you have multiple accounts which you want to run at the same time, you can add them to the acc-config by duplicating the segment in the curly braces { ... }. E.g.

// acc-config-sample.json
{
    "buildVersion": "X25.1.1",
    "accounts": [
        {
            "alias": "Main Client",
            "guid": "[email protected]",
            "password": "SecretPassWord11",
            "serverPref": "AsiaSouthEast"
        },
        {
            "alias": "Secondary Client",
            "guid": "[email protected]",
            "password": "Password22",
            "serverPref": "USSouth"
        }
    ]
}

Using proxies

nrelay supports the use of SOCKSv4, SOCKSv4a, and SOCKSv5 proxies to route client connections through. Proxies can be added in the account config as a property of the account

{
    "alias": "Main Client",
    "guid": "[email protected]",
    "password": "SecretPassWord11",
    "serverPref": "AsiaSouthEast",
    "proxy": {
        "host": "127.0.0.1", // The ip of the proxy
        "port": 8080,        // The port of the proxy. Use a number here, e.g. 8080 not "8080".
        "type": 5            // The type of the proxy. Use 5 for SOCKSv5 and 4 for SOCKSv4 or SOCKSv4a
    }
}

If a proxy is specified, nrelay will route all traffic including the initial web request to get the character lists. Because of this, there may be greater delays when using proxies. The proxy a client is using can also be changed during runtime by using the Client.setProxy(proxy: IProxy): void method.

Using the Local Server

nrelay provides the option to enable a local web server which supports TCP connections. The server can be used to both send to and receive data from nrelay. The server is disabled by default, but can be enabled by adding a property to the account config.

{
    "buildVersion": "X25.1.1",
    "localServer": {
        "enabled": true
    },
    "accounts": [
        // ...
    ]
}

By default, the server will use the port 5680, but this can be changed by adding a port property to the account config.

"localServer": {
    "enabled": true,
    "port": 9000
}

Sending data to the Local Server

After you have connected to the local server, you can send data to it by simply writing data to the socket. nrelay will convert any received data to a UTF8 encoded string. Message paging is not supported, so the entire message should be written at once.

Nodejs example:

const net = require('net');

var socket = net.createConnection(5680, 'localhost', () => {
    console.log('Connected to nrelay server!');
    socket.write('Hello, nrelay!');
});

Receiving data from the Local Server

Data is sent from nrelay in the form of a UTF8 encoded string. All outgoing messages from nrelay include a 4-byte header which indicates the length of the message as an Int32 (excluding the 4 byte header). The header is written to the socket in Little-Endian format, so a message length of 4 would produce the header 04 00 00 00 instead of 00 00 00 04.

For example, the outgoing message 'test' would be received as follows: (this example shows hex encoded bits. The actual data is not hex encoded.)

|  Header   |   Data    |
 04 00 00 00 74 65 73 74
|          4| t  e  s  t|

Run

After setting up the acc-config.json file, nrelay is ready to go. To run nrelay, simply use the command nrelay in the console. If you have setup your acc-config properly (and used the correct credentials) you should see an output similar to this

C:\Documents> nrelay
[17:25:23 | NRelay]           Starting...
...
[17:25:26 | Main Client]      Authorized account
[17:25:26 | Main Client]      Starting connection to AsiaSouthEast
[17:25:26 | Main Client]      Connected to server!
[17:25:26 | Main Client]      Connecting to Nexus
[17:25:27 | Main Client]      Connected!

The alias property in the account config is optional. If one is not specified, the log will use a censored email instead

[17:25:26 | f***@e***.com]    Authorized account
[17:25:26 | f***@e***.com]    Starting connection to AsiaSouthEast
[17:25:26 | f***@e***.com]    Connected to server!

Note

You will only be able to use the command nrelay if you performed step 6 and 7 during the installation. If you didn't do these steps, you will have to run nrelay by following these steps:

  1. Open a console in the nrelay directory
  2. Use the command npm start.

npm start will only work if the console is in the nrelay directory, whereas the nrelay command can be run anywhere.

Command line arguments

There are several command line arguments which can be provided when starting nrelay to change the behaviour.

--debug

This will start nrelay in debug mode. Debug mode provides a higher detail of logging. It is not recommended to use debug mode unless you are experiencing errors and need more info.

--no-update

This will stop nrelay from checking for updates when it starts.

--no-log

This will stop nrelay from writing to the log file.

--force-update

This will force nrelay to download the latest client and assets.

Example

To start nrelay without checking for updates or log file writing, use

nrelay --no-update --no-log

Build

Whenever any changes are made to the TypeScript source files, they will need to be recompiled in order for the changes to take effect.

To recompile the TypeScript simply use

gulp

Acknowledgements

This project uses the following open source software:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.