Proxy data Definition

meishuu/tera-proxy-game: Modular event handling through
Configuring Backup Proxy - Veeam Backup and Replication

Thus, a loadable module's export must be a constructible function with at least one parameter, which will be an instance of DispatchWrapper. Since this function is called with new, the context of this will be unique to each connection to the proxy allowing support for multiple clients.

For examples, see the tera-proxy developer documentation.

DispatchWrapper

An instance of DispatchWrapper is created for each module loaded by Dispatch. It keeps track of a module's name and has a handful of methods which mostly forward parameters to the base Dispatch instance. It is often named dispatch for conciseness and legacy reasons, which might be confusing, but in most cases as a module author you won't need to interact with the base Dispatch object.

base

Points to the base Dispatch instance. Useful if you want to track something per-connection given an instance of a DispatchWrapper, where you can make a WeakMap with dispatch.base as a key (see slash for an example).

hookOnce(name, version, [options], callback)

Adds a hook for a packet. The hookOnce version will remove the hook after it has run once.

name will usually be the name of the message being watched for, such as "S_LOGIN", but it can also be "*" to catch all messages. You may also use lowerCamelCase for names, removing all underscores and using lowercase unless the character was originally preceded by an underscore (such as "sLogin").

version should be an integer representing the desired packet version as given by the corresponding tera-data definition file, or it can be "*" to use the latest version. Alternatively, "raw" can be used to create a raw hook, which does not perform any parsing and instead passes the callback the raw (decrypted) data buffer.

options is an optional object with the following optional properties:

order: A lower number causes this hook to run before hooks with a higher order. This defaults to 0, so you can imagine negative values running closer to the source side and positive values running closer to the destination side. This is helpful for modules that way want to examine packets before another module modifies or silences them, or filter to what the receiving side will see by running later than most other hooks.

filter: An object of filters to apply. The hook will not receive any packets which do not match the filter. Each filter is a ternary flag: true applies the positive filter, false applies it negatively, and null disables the filter. All of them are optional.

fake: Filters "fake" packets—those generated through Dispatch. Default: false (only allow real packets). If true, matches only packets generated through Dispatch. Any hook that receives fake packets must be careful not to create an infinite loop.

incoming: Filters packets based on destination. Default: null (ignore destination). If true, matches only packets sent to the client. If false, matches only packets sent to the server.

modified: Filters packets if they have been altered by a previous hook. Default: null (ignore modification status). If true, matches only packets modified by previous hooks. If false, matches only unmodified packets.

silenced: Filters packets if they have been silenced by a previous hook. Default: false (only allow unsilenced packets). If true, matches only packets that have had a previous hook return false to prevent the packet from being sent. Any hook that receives a silenced packet may un-silence the packet by returning true.

callback is the callback function for the hook, which receives:

For a normal hook (version is not "raw"), event: An object containing the parsed message data (see tera-data). fake: true if this packet was generated through the proxy, false otherwise. Return value is true if event is modified, or false to stop and silence the message. Other return values are ignored. If you change event but do not return true, the changes will not be saved. For a raw hook, code: The opcode of the message as an integer. data: The Buffer of the raw message data. fromServer: true if the message was sent by the server, false otherwise. fake: true if this packet was generated through the proxy, false otherwise. Return value is a Buffer of the modified message data to use, or false to stop and silence the message. Other return values are ignored. Note that unlike for normal hooks, modifications to the original buffer will be saved and used regardless of whether you return true.

The event for a normal hook and the data for a raw hook also have four properties corresponding to the four filters. Each flag is either true or false; see the above section on filters for more information.

$fake $incoming $modified $silenced

Returns an object representing the hook. Its properties are not set in stone and are not meant to be changed, so do not depend on them. If you have a use case where you absolutely need to do something with the properties, please submit a GitHub issue describing it.

unhook(hook)

Removes a hook. It will no longer be called. Pass in the result of a call to Dispatch#hook.

toServer(name, version, data)

Constructs and sends a packet to either the TERA client or server.

If buffer is used, it will simply be sent as-is (before encryption).

If data is used, it must be an object (to be serialized by tera-data-parser). name must be the packet name and version should be the version number as given by the tera-data definition file, or "*" for the latest version.

load(name, [from, [required, [args...]]])

Load the module referenced by name using from.require. You will likely want to pass the module from the calling context in order to emulate a require from there; otherwise, it will default to loading the module as if require were called from inside tera-proxy-game. See the module.require documentation for more details.

Source: github.com


Related posts:

  1. Reverse proxy Definition
  2. Proxy Statement Definition
  3. Proxy Holder Definition
  4. Proxy Medical Definition
  5. Proxy Votes Definition