The JavaScript request filter is the most flexible of all request filters. It can potentially be called for any request packet type, and can modify traffic in any way it sees fit.
Packet types : optional. If specified, a comma-separated list of packet types for which this filter should be called, for instance:Â Prepare,Execute. Spaces are ignored. If this is not specified, the filter will be invoked for all request packets.
Client IPs: optional. If specified, a comma-separated (or line break separated) list of IP4 or IP6 addresses or regular expressions for IP addresses. Example: 12.34.56.78,regex:98\.76\.54\..*
Users: optional. If specified, a comma-separated (or line break separated) list of user names or regular expressions for user names. Example: jdoe,wsmith,regex:acct_.*,regex:.*-mkt
A Cassandra client sends a Startup packet to formally open a connection to a Cassandra server. This packet, among other things, usually contains the name of the driver and its version. It may be useful to modify this so that the server sees a different version than what the client really is.
To do so, you would create a JavaScript request filter with the parameter:
Packet types: Startup
You would then add the following code to the filter. Note that you can change this filter's behavior based on the actual client's version, IP, etc...
context.packet.setEntry("DRIVER_NAME", "My driver");
context.packet.setEntry("DRIVER_VERSION", "1.0");