Coder Social home page Coder Social logo

tera-proxy-sls's Introduction

tera-proxy-sls

Spawns an HTTP proxy server to modify a TERA server list.

Example:

var SlsProxy = require('sls');
var proxy = new SlsProxy({
  customServers: {
    4009: { name: 'Celestial Chills', port: 9999, overwrite: false }
  }
});
proxy.listen('127.0.0.1', () => console.log('listening'));
process.on('SIGHUP', () => proxy.close());

API Reference:

new SlsProxy(opts)

Constructor with the following allowed options:

  • host: The hostname for the target server list. Default: sls.service.enmasse.com
  • port: The port for the target server list and for the proxy server. Default: 8080
  • customServers: An object of custom servers. See setServers below for details. Default: {}
  • listenHostname: The hostname for the proxy server to accept connections on. See net.server.listen. Default: 127.0.0.1

proxy.setServers(servers)

Sets the custom server object where servers is a mapping of server IDs with custom options.

For each server, valid options are:

  • ip: The IP to point to for the custom server. Default: 127.0.0.1
  • port: The port for the custom server. Default: null (no change)
  • name: The name to use for this server in the list. Default: null (no change)
  • overwrite: If true, this custom server will completely replace the original one in the list. Default: false

If overwrite is false for a server ID, then the crowdness for the new server will have a sort value of 0 to give it priority over the old server when TERA selects which one to automatically log into.

proxy.fetch(callback)

Fetches a map of server IDs and simplified properties from the official list.

callback receives two parameters:

  • err: The error, or null if none.
  • servers: An object mapping IDs to objects containing server metadata.

Example result:

{
  "4004": {
    "id": "4004",
    "ip": "208.67.49.28",
    "port": "10001",
    "name": "Tempest Reach"
  },
  "4009": {
    "id": "4009",
    "ip": "208.67.49.68",
    "port": "10001",
    "name": "Celestial Hills - Roleplay"
  },
  "4012": {
    "id": "4012",
    "ip": "208.67.49.92",
    "port": "10001",
    "name": "Mount Tyrannas"
  }
}

proxy.listen(hostname, callback)

Starts an HTTP server listening on hostname, using callback as the handler for the listening event (see net.Server#listening). If there was an error, it will be passed as the first parameter to callback.

This also modifies /etc/hosts to point proxy.host to 127.0.0.1, which may fail without administrative permissions.

proxy.close()

Closes the HTTP server and removes the entry from /etc/hosts.

This should be called on termination if proxy.listen is called. Otherwise, the entry in the hosts file will remain, even though the SLS proxy server is no longer running. It is not necessary to call this if listen errors, but there shouldn't be any harm in doing this step anyway.

tera-proxy-sls's People

Contributors

meishuu avatar

Watchers

James Cloos avatar Pavel Angulo avatar

Forkers

kuzaki gepard-me

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.