ILXPlugin¶
new ILXPlugin()→ {object}
- Since:
- BIP-IP TMOS 13.0
The ILXPlugin class is the entry point to the ILX Plugin feature. The ILXPlugin class manages communication between the TMM and a Node.js plugin application. The primary functions of the ILXPlugin class are to a) configure initial communication settings, b) start the plugin server, and c) provide a callback that is invoked when a new virtual server flow is created, represented by the ILXFlow class.
To start the pluginterface create an ILXPlugin object (at most one is allowed), setup the ‘clientConnected’ event handler, configure ILXPlugin options and call ILXPlugin.start(options). See ilx_flow.js for a description of events and methods on the ILXFlow class.
Returns:
Example:
var f5 = require('f5-nodejs');
var plugin = new f5.ILXPlugin();
plugin.on('connect', function(flow) {
<plugin code>
});
plugin.start();
Methods¶
getDataGroup(datagroup)→ {ILXDatagroup}¶
Returns a datagroup object. You must associated a datagroup to the plugin extension before you can call this method. You must not call this method before the ` <#event:initialized>`__
ILXPlugin#event:initialized
event or it will throw an exception. The datagroup is automatically updated in the plugin when records are modified. See also TMSH help with
tmsh help ilx plugin
.
Parameters:¶
Name | Type | Description |
---|---|---|
datagroup
|
string | the fully qualified name of the datagroup. Eg. /Common/MyDatagroup |
Example:¶
var f5 = require('f5-nodejs');
var plugin = new f5.ILXPlugin();
//Get the DG after plugin connects to TMM
var dg = {};
plugin.on('initialized', function () {
dg = plugin.getDataGroup('/Common/some_dg');
})
plugin.on('connect', function(flow) {
// Block the bad guy's IP
if (dg.lookup(flow.client.remoteAddress)) {
console.log('Blocked conflow from IP "' + flow.client.remoteAddress + '".');
return flow.destroy();
}
flow.client.allow();
});
var options = new f5.ILXPluginOptions();
options.handleServerData = false;
options.handleClientData = false;
options.handleClientOpen = true;
plugin.start(options);
setGlobalTraceLevel(level)¶
Parameters:¶
Name | Type | Description |
---|---|---|
level
|
number | See ` <#~traceLevel>`__ ILXPlugin~traceLev
el |
setTraceLevel(level)¶
Parameters:¶
Name | Type | Description |
---|---|---|
level
|
number | See ` <#~traceLevel>`__ ILXPlugin~traceLev
el |
start([options])¶
Parameters:¶
Name | Type | Attributes | Description |
---|---|---|---|
options
|
ILXPluginOptio ns | <optional> | ILXPluginOption s object |
startHttpServer(cb)¶
Start the plugin as a node.js http server. The callback function is the same as would be passed to the node.js http.createServer(requestListener) method. Note that the event ILXFlow#connect will not be emitted for new client connections.
The ILXPluginOptions property disableServer is automatically set. Any communication with downstream servers must be managed by the plugin using ` <ILXStream.html#connect>`__
ILXStream#connect
. Note: This can only be used when the virtual server does NOT have an HTTP profile.
Parameters:¶
Name | Type | Description |
---|---|---|
cb
|
ILXPlugin~requestCal lback | Node.js HTTP request callback function. |
Examples:¶
// As simple HTTP server
var f5 = require('f5-nodejs');
function httpRequest(req, res) {
res.end("got it: " + req.method + " " + req.url + "\n", "ascii");
}
var plugin = new f5.ILXPlugin();
plugin.startHttpServer(httpRequest);
// With Express.js
var f5 = require('f5-nodejs');
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.status(200).send('<html><h1>Hello from express.</h1></html>');
});
var plugin = new f5.ILXPlugin();
plugin.startHttpServer(app);
Type Definitions¶
requestCallback(request, response)¶
This callback is invoked when an HTTP request is received by the plugin when the plugin has been started in HTTP server mode (` <#startHttpServer>`__
ILXPlugin#startHttpServer
). The request and response objects are standard Node.js HTTP request and response objects.
Parameters:¶
Name | Type | Description |
---|---|---|
request
|
object | HTTP request object |
response
|
object | HTTP response object |
traceLevel¶
The traceLevel number used in various methods has a range of 0-30 (but any positive number value is acceptable). Levels are as follows -
- 0 - Disables trace logging (default)
- >=1 - Log configuration messages
- >10 - Log general function call location information
- >20 - Will include function call information in the packet path
- >30 - Will include packet content that is sent and received to/from TMM.
Events¶
connect¶
The ILXPlugin#connect event will be emitted when the plugin receives a new client connection (if the plugin has been started using ILXPlugin.start). Executes a callback function with argument of flow object.
If the plugin has been started using ILXPlugin.startHttpServer the client socket will be handed to the native node.js HTTP implementation and HTTP requests will be passed to the callback function given to ILXPlugin.startHttpServer.
Example:¶
plugin.on('connect', function(flow) {....}
<plugin code>
});
initialized¶
uninitialized¶
The BIG-IP API Reference documentation contains community-contributed content. F5 does not monitor or control community code contributions. We make no guarantees or warranties regarding the available code, and it may contain errors, defects, bugs, inaccuracies, or security vulnerabilities. Your access to and use of any code available in the BIG-IP API reference guides is solely at your own risk.