summaryrefslogtreecommitdiffstats
path: root/server/proxy/modules/README.md
blob: f1d2206ec30d7aa3cc4feab830725bd87565d515 (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Proxy module API

`freerdp-proxy` has an API for hooking/filtering certain events/messages.
A module can register callbacks to events, allowing to record the data and control whether to pass/ignore, or right out drop the connection.

During startup, the proxy reads its modules from the configuration:

```ini
[Plugins]
Modules = demo,cap
```

These modules are loaded in a best effort manner. Additionally there is a configuration field for modules that must be loaded,
so the proxy refuses to start if they are not found:

```ini
[Plugins]
Required = demo,cap
```

Modules must be installed as shared libraris in the `<base install>/lib/freerdp3/proxy` folder and match the pattern
`proxy-<name>-plugin.<ext>` (e.g. `proxy-demo-plugin.so`) to be found.
For security reasons loading by full path is not supported and only the installation path is used for lookup.

## Currently supported hook events

### Client

* ClientInitConnect:     Called before the client tries to open a connection
* ClientUninitConnect:   Called after the client has disconnected
* ClientPreConnect:      Called in client PreConnect callback
* ClientPostConnect:     Called in client PostConnect callback
* ClientPostDisconnect:  Called in client PostDisconnect callback
* ClientX509Certificate: Called in client X509 certificate verification callback
* ClientLoginFailure:    Called in client login failure callback
* ClientEndPaint:        Called in client EndPaint callback

### Server

* ServerPostConnect:     Called after a client has connected
* ServerPeerActivate:    Called after a client has activated
* ServerChannelsInit:    Called after channels are initialized
* ServerChannelsFree:    Called after channels are cleaned up
* ServerSessionEnd:      Called after the client connection disconnected

## Currently supported filter events

* KeyboardEvent:         Keyboard event, e.g. all key press and release events
* MouseEvent:            Mouse event, e.g. mouse movement and button press/release events
* ClientChannelData:     Client static channel data
* ServerChannelData:     Server static channel data
* DynamicChannelCreate:  Dynamic channel create
* ServerFetchTargetAddr: Fetch target address (e.g. RDP TargetInfo)
* ServerPeerLogon:       A peer is logging on

## Developing a new module
* Create a new file that includes `freerdp/server/proxy/proxy_modules_api.h`.
* Implement the `proxy_module_entry_point` function and register the callbacks you are interested in.
* Each callback receives two parameters:
    * `connectionInfo* info` holds connection info of the raised event.
    * `void* param` holds the actual event data. It should be casted by the filter to the suitable struct from `filters_api.h`.
* Each callback must return a `BOOL`:
    * `FALSE`: The event will not be proxied.
    * `TRUE`: The event will be proxied.

A demo can be found in `filter_demo.c`.