-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin-spec.txt
35 lines (30 loc) · 1.74 KB
/
plugin-spec.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Plugin files are python modules.
Plugins SHOULD contain the following global variables:
AUTHOR: String containing name or handle of plugin author, or list of the same.
CONTACT: String containing contact details (preferably an email address) for author, or list of the same.
DESCRIPTION: String containing description of plugin.
Plugins MAY contain the following defined functions:
on_start():
Run on plugin initialisation. If an exception is raised here, plugin is disabled and a warning is given.
on_tick(users):
Run approximately every server tick (200ms). Users is a list of all currently connected User objects.
on_packet(packet, user, to_server):
This function is called for every packet passing through the proxy.
packet is a Packet and contains packet data.
user is a User and contains session data.
to_server is a bool and is True for client->server packets, False for server->client.
This function may return:
a Packet
a list of Packet
and each packet in the list will be passed along to the next plugin in the chain.
Note that returning [] has the effect of dropping the packet.
Note also that it is common to simply modify the given Packet before returning it.
If a plugin wishes to log to the main logger, it MAY use the root logger available through the logging module.
However, in general, the plugin SHOULD use its own logging path.
Plugins MAY import any of the items contained in the top level directory.
As an exception, plugins MAY NOT import proxy.py
Plugins SHOULD make use of the functions given in helpers.py
Plugins MUST NOT:
Modify the real-time process timer, or the SIGALRM handler
Take overly long to run (the entire proxy is blocking on you)
In addition, the User and Packet objects should not be considered thread-safe.