mirror of
https://github.com/OpenVPN/openvpn.git
synced 2024-09-20 12:02:28 +02:00
94cebf8261
This is a new "samples" plugin which does not do many useful things,
besides
- show how a plugin is programmed
- how the various messages get dispatched
- how to pass back information from a client-connect/v2 plugin
- how to do async-cc plugins [not yet implemented]
the operation of the plugin is controlled by UV_WANT_* environment
variables
controlled by the client ("--setenv UV_WANT_CC_FAIL 1 --push-peer-info"),
to "fail CLIENT_CONNECT" or "use async-cc for CLIENT_CONNECT_V2" or
"send 'disable' back from ...") - which is useful for automated testing
of server success/defer/fail code paths for the CLIENT_CONNECT_* functions.
See samples/sample-plugins/client-connect/README for details how to do
this.
v2:
- implement async / deferred operation both for CLIENT_CONNECT and
CLIENT_CONNECT_V2 plugin calls
- implement returning openvpn-controlled (setenv) config snippets
(so the client side can verify in automated testing that the plugin
operated correctly, without hard-coding something in the plugin code)
v3:
- remove -Wno-unused-variable from Makefile
- remove unused "char ** argv" (commented out, but kept as reference)
v4:
- upgrade to use the build infra brought by commit 0b5141d8f9
- remove local Makefile
- include "config.h" to get what is needed to get rid of the strdup()
warning
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200917161909.11573-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21047.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
39 lines
1.4 KiB
Plaintext
39 lines
1.4 KiB
Plaintext
OpenVPN plugin examples.
|
|
|
|
Examples provided:
|
|
|
|
sample-client-connect.c
|
|
|
|
- hook to all plugin hooks that openvpn offers
|
|
- log which hook got called
|
|
- on CLIENT_CONNECT or CLIENT_CONNECT_V2 set some config variables
|
|
(controlled by "setenv plugin_cc_config ..." and "plugin_cc2_config"
|
|
in openvpn's config)
|
|
|
|
- if the environment variable UV_WANT_CC_FAIL is set, fail
|
|
- if the environment variable UV_WANT_CC_DISABLE is set, reject ("disable")
|
|
- if the environment variable UV_WANT_CC_ASYNC is set, go to
|
|
asynchronous/deferred mode on CLIENT_CONNECT, and sleep for
|
|
${UV_WANT_CC_ASYNC} seconds
|
|
|
|
- if the environment variable UV_WANT_CC2_FAIL is set, fail CC2
|
|
- if the environment variable UV_WANT_CC2_DISABLE is set, reject ("disable")
|
|
- if the environment variable UV_WANT_CC2_ASYNC is set, go to
|
|
asynchronous/deferred mode on CLIENT_CONNECT_V2, and sleep for
|
|
${UV_WANT_CC2_ASYNC} seconds
|
|
|
|
(this can be client-controlled with --setenv UV_WANT_CC_ASYNC nnn
|
|
etc. --> for easy testing server code paths)
|
|
|
|
To build for unixy platforms (not very sophisticated right now, needs gmake):
|
|
|
|
.../sample-plugins$ gmake client-connect/sample-client-connect.so
|
|
|
|
(This plugin has not been tested on Windows, and might not even work due
|
|
to its use of fork() and wait(). Let us know if it does or needs patches)
|
|
|
|
|
|
To use in OpenVPN, add to config file:
|
|
|
|
plugin sample-client-connect.so (Linux/BSD/etc.)
|