Forum Discussion
Stream::Replace Will Not Work
when CLIENT_ACCEPTED {
STREAM::expression :LOGIN\ .*:
STREAM::enable
}
when STREAM_MATCHED {
STREAM::replace "$logon $username $pass [STREAM::match]"
if {[STREAM::match] starts_with "LOGIN"}{
log local0. "Replace string conditional: true"
STREAM::replace "[string map {L G} [STREAM::match]]"
}
log local0. "Stream filter matched: [STREAM::match]"
}
For whatever reason, it won't replace anything. Once I get the code to do simple replacements, I hope to replace the entire stream with variables that I define. Hopefully someone can point out what I am doing wrong.
Please note that I am testing this by attempting to log in with an email client attaching to IMAP. I am able to cause failures by replacing with STREAM::expression but, again, any replacement attempts with STREAM::replace will not work. The IMAP packet format is LOGIN "username" "password". So logically, if I replace the letter L with anything else it would fail. Again, I can do it with STREAM::expression but not STREAM::replace.
- c_p_i_o_17707Historic F5 AccountI think that you are using the STREAM::expression command incorrectly.
- jvuong004_98902NimbostratusThanks for the response. Actually, the delimiter can be set to a number of items. It just depends on what you decide upon. I was using the @ sign at first but since I was appending domain names that have @domain.com it was not parsing out correctly. Please note that the STREAM::expression line does work and does match. I have it logging out and it works just fine. I have alternate code that runs my replacements just fine. Alternate code is below:
Behavior of below code:
----------------------------
Input: LOGIN "username" "password"
Output: LOGIN "username@domain.com" "password"
****************************************
Reference Article for using alternate delimiters:
****************************************
http://devcentral.f5.com/Tutorials/...sions.aspx
Quote:"The first character in the field () defines the delimiter bounding each field for this replacement, and must not appear anywhere else in the target string. can be any one of the following characters:.*/-:_?=@,&(period, asterisk, forward slash, dash, colon, underscore, question mark, equals, at, comma, ampersand)" - Colin_Walker_12Historic F5 AccountAre you getting log entires with the STREAM::match block? The code looks fine, so I'm thinking there is something else afoot here.
- jvuong004_98902NimbostratusI am. Which is odd. I am tailing the log and I am getting print outs saying that it is matching but no stream replacement is occuring.
Oct 13 22:59:26 tmm tmm[1878]: Rule IMAP_Domain_append.irule : CONDITIONAL HIT
Oct 13 22:59:26 tmm tmm[1878]: Rule IMAP_Domain_append.irule : Stream filter matched: LOGIN "username" "password"
Oct 13 22:59:26 tmm tmm[1878]: 01200004:5: Packet rejected remote IP 147.140.19.81 port 138 local IP 147.140.19.255 port 138 proto UDP: Port closed.
- Michael_YatesNimbostratusHi jvuong004,
when HTTP_RESPONSE { STREAM::expression ":foo:: :bar::" STREAM::enable } when STREAM_MATCHED { log local0. "Stream filter matched: [STREAM::match]" STREAM::replace "[string map {"foo" "I replaced foo" "bar" "I replaced bar"} [STREAM::match]]" }
- jvuong004_98902NimbostratusThanks for the response. Unfortunately I am not using HTTP and using strictly IMAP, so the HTTP_Response event does not work. I tried it anyways and received HTTP profile required error.
- jvuong004_98902NimbostratusDoes anyone have any other suggestions? I was wondering if there are any known issues with the version that I am using? We are currently on 9.4.7. Everywhere I look my code looks correct. Please let me know if you guys need any more information from me.
Recent Discussions
Related Content
* 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