Last active
January 31, 2023 15:50
-
-
Save lrhazi/f8583aa0cc036eba25a74e4c800eee76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when HTTP_REQUEST { | |
if {[HTTP::has_responded]}{return} | |
set collect_length 2048 | |
if {([HTTP::uri] eq "/login") && ([HTTP::method] eq "POST")} { | |
# check content length | |
if {[HTTP::header "Content-Length"] ne "" && [HTTP::header "Content-Length"] <= $collect_length }{ | |
set content_length [HTTP::header "Content-Length"] | |
} else { | |
set content_length $collect_length | |
} | |
if { $content_length > 0} { | |
HTTP::collect $content_length | |
} | |
} | |
} | |
when HTTP_REQUEST_DATA { | |
if {[HTTP::has_responded]}{return} | |
set username [findstr [HTTP::payload] "username=" 9 &] | |
# log local0. "Login name = $username" | |
} | |
when LB_SELECTED { | |
if {[HTTP::has_responded]}{return} | |
set hsl [HSL::open -proto UDP -pool syslog-pool] | |
set msg "c_ip=[IP::client_addr]" | |
set msg [concat $msg "vip=[clientside {IP::local_addr}]"] | |
set msg [concat $msg "s_ip=[LB::server addr]"] | |
set msg [concat $msg "m=[HTTP::method]"] | |
set msg [concat $msg "v=[HTTP::version]"] | |
set msg [concat $msg "p=[HTTP::path]"] | |
set msg [concat $msg "q=[HTTP::query]"] | |
set msg [concat $msg "u=$username"] | |
set r_headers "" | |
foreach aHeader [HTTP::header names] { | |
set r_headers [join [list $r_headers " " "h_${aHeader}" = {"} [HTTP::header value $aHeader] {"}] ""] | |
} | |
set msg [concat $msg $r_headers] | |
HSL::send ${hsl} "<130> log-http-requests: $msg\n" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment