Forum Discussion
st0n3_87491
Nimbostratus
Aug 13, 2009Persistence based on IMAP-User
Hi there,
as topic say I would like to have a persistence to a node based on his IMAP-Userlogin.
I managed to find out this using a stream Profile and wrote this iRule so far:
when CLIENT_ACCEPTED {
STREAM::expression @LOGIN\.*@
STREAM::enable
event STREAM_MATCHED enable
}
when STREAM_MATCHED {
set match [getfield [STREAM::match] " " 2]
set client "[IP::client_addr]:[TCP::client_port]"
set vip [IP::local_addr]:[TCP::local_port]
set node "[IP::server_addr]:[TCP::server_port]"
log local0.info "$match $client $vip $node"
STREAM::disable
}
This iRule now just logs
Jul 15 19:08:54 tmm tmm[1867]: Rule persistence_irule_user : nocppp XX.XX.XXX.XXX:XXXXX(CLIENT-IP: PORT) XXX.XXX.XXX.XXX:XXX(VIP-IP: PORT) XXX.XXX.XXX.XXX:XXXX(NODE-ID: PORT)
As already mentioned in the next step I would like to have a persistance based on that LOGIN/Client-IP: PORT.
How can I manage this?
Next question is what happens to the persistent requests when the node goes down?
Maybe there are totally other solutions for that...because I have a performance issue on that solution, too.
Thanks in advance
Christian
- The_Bhattman
Nimbostratus
Hi Christian,if { $persistantX !="" } { persistant uie $persistantX 1800 }
- hoolio
Cirrostratus
I tried something similar using a stream profile and iRule to add a persistence record based on the server response content. You could try using a similar approach for the request content. - st0n3_87491
Nimbostratus
Thanks to the both of you !!! - hoolio
Cirrostratus
Hi Chris, - st0n3_87491
Nimbostratus
when CLIENT_ACCEPTED { Clear the variable imap_login if it exists already on this TCP connection if {[info exists imap_login]}{ unset imap_login } Define STREAM-expression and enable STREAM STREAM::expression @LOGIN\.*@ STREAM::enable Enable the STREAM_MATCHED event as it could have been disabled if there was a prior response on this TCP connection event STREAM_MATCHED enable } when STREAM_MATCHED { Save the matched value set imap_login [getfield [STREAM::match] " " 2] Check if $imap_login isn't empty if { $imap_login != "" }{ $imap_login isn't empty...so let's continue log local0. "IMAP Login Information found...continuing" The iRule parser doesn't allow the persist command in STREAM_MATCHED. It works though, so hide the command from the parser set persist_cmd "persist add uie $imap_login" log local0. "[IP::client_addr]:[TCP::client_port]: Parsed: $imap_login \$persist_cmd: $persist_cmd" eval $persist_cmd persist add uie $imap_login log local0. "[IP::client_addr]:[TCP::client_port]: Added persistence record for $imap_login on server [IP::server_addr]:[TCP::server_port]. Exiting event for this response." event STREAM_MATCHED disable } else { $imap_login is empty...let's stop this here log local0. "no IMAP Login Information found...aborting" } }
- st0n3_87491
Nimbostratus
doesn't work:Aug 26 13:33:41 tmm tmm[1698]: Rule persistence_imap_login_new : IP:49174: New TCP connection with persistence record: Aug 26 13:33:41 tmm tmm[1698]: Rule persistence_imap_login_new : IP:49174: Selected server IMAP-NEW IP 1430 Aug 26 13:33:41 tmm tmm[1698]: Rule persistence_imap_login_new : IP:49174: Connected server IP Aug 26 13:33:41 tmm tmm[1698]: Rule persistence_imap_login_new : IP:49174: Matched: LOGIN Aug 26 13:33:41 tmm tmm[1698]: Rule persistence_imap_login_new : no IMAP Login Information found...aborting
Check if $imap_login isn't empty if { $imap_login != "" }{
- hoolio
Cirrostratus
Can you test multiple requests? Previously, the ltm log showed a match for the LOGIN of user1... I'm wondering if the request may have changed? Else, maybe the wrapping of the regex in curly braces broke this? Can you retry with the STREAM::expression set to: - st0n3_87491
Nimbostratus
The removal of the braces helped...but persistence still doesn't work...Aug 26 15:26:26 tmm tmm[1698]: Rule persistence_imap_login_new : IP:48776: New TCP connection with persistence record: Aug 26 15:26:26 tmm tmm[1698]: Rule persistence_imap_login_new : IP:48776: Selected server IMAP-NEW IP 1430 Aug 26 15:26:26 tmm tmm[1698]: Rule persistence_imap_login_new : IP:48776: Connected server IP Aug 26 15:26:26 tmm tmm[1698]: Rule persistence_imap_login_new : IP:48776: Matched: LOGIN "user1@sampledomain.com" "password" Aug 26 15:26:26 tmm tmm[1698]: Rule persistence_imap_login_new : IP:48776: Parsed: "user1@sampledomain.com" $persist_cmd: persist add uie "user1@sampledomain.com" 1800 Aug 26 15:26:26 tmm tmm[1698]: Rule persistence_imap_login_new : IP:48776: Added persistence record for "user1@sampledomain.com" on server IP:1430. Exiting event for this response.
- hoolio
Cirrostratus
That's looking better. So do you see the persistence record lookup succeed on a subsequent request in the first log line of the rule? If you check on the command line, using 'b persist all show all', do you see the persistence record listed? - st0n3_87491
Nimbostratus
Hi,| Mode universal Value user1@sampledomain.com | virtual IP:imap node IP:1430 age 1631sec
if {$persist_lookup != ""}{ persist uie $persist_lookup $timeout }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects