Forum Discussion
Lee_Sutcliffe
May 23, 2019Nacreous
Ok so here we go.
First you need an iRule that passes the client IP address into iRules LX (you'll want to put the LX call in a catch for a prod environment)
when CLIENT_ACCEPTED {
set rpcHandle [ILX::init "fs-pl" "fs-ex"]
set result [ILX::call $rpcHandle "writeFile" "[IP::client_addr]"]
log local0. "$result"
}
Then this is a simple iRules LX script that will write out a test file with the value of the IP you passed in.
It will write out the file to the extension folder which will vary.. it will also change slightly each time it executes
For example, my file was located here:
/var/sdm/plugin_store/plugins/:Common:fs-pl_83750_4/extensions/fs-ex/test.txt
the next time, it was located here:
/var/sdm/plugin_store/plugins/:Common:fs-pl_83750_5/extensions/fs-ex/test.txt
var f5 = require('f5-nodejs');
var ilx = new f5.ILXServer();
var fs = require('fs');
function writeFile(req, res) {
var ip = req.params()[0];
fs.writeFile('test.txt', ip, function (err) {
if (err) {
res.reply(err);
} else {
res.reply("file written successfully");
}
});
}
ilx.addMethod('writeFile', writeFile);
ilx.listen();
Hope that helps
Lee
- Andy_McGrathMay 23, 2019Cumulonimbus
Nice solution, glad I could help :D