Select group based on TCP contents
Posted by a10jliu
User Scenario:
Need to use one VIP (same IP) for different applications. All applications run on smart phones which has its own client; choose different service group based on the the first 2 TCP Payload bytes.
Code:
when CLIENT_ACCEPTED {
TCP::collect 2
}
when CLIENT_DATA {
if { [TCP::payload 2] equals "G1" } {
pool liujin_139.14_9000
}
if { [TCP::payload 2] equals "YM" } {
pool shensui_139.2_8888
}
if { [TCP::payload 2] equals "ZH" } {
pool cntv_139.69_7001
}
if { [TCP::payload 2] equals "ZG" } {
pool cntv_139.70_7001
}
if { [TCP::payload 2] equals "ZF" } {
pool cntv_139.3_7001
}
if { [TCP::payload 2] equals "ZA" } {
pool cntv_139.23_7001
}
if { [TCP::payload 2] equals "ZB" } {
pool cntv_139.9_7001
}
if { [TCP::payload 2] equals "ZC" } {
pool cntv_139.8_7001
}
if { [TCP::payload 2] equals "ZD" } {
pool cntv_139.7_7001
}
if { [TCP::payload 2] equals "ZE" } {
pool cntv_139.6_7001
}
if { [TCP::payload 2] equals "YO" } {
pool cntv_139.68_7001
}
if { [TCP::payload 2] equals "YP" } {
pool cntv_139.67_7001
}
if { [TCP::payload 2] equals "YQ" } {
pool cntv_139.66_7001
}
if { [TCP::payload 2] equals "YR" } {
pool cntv_139.65_7001
}
if { [TCP::payload 2] equals "YS" } {
pool cntv_139.64_7001
}
if { [TCP::payload 2] equals "YT" } {
pool cntv_139.63_7001
}
if { [TCP::payload 2] equals "YU" } {
pool cntv_139.62_7001
}
if { [TCP::payload 2] equals "YV" } {
pool cntv_139.61_7001
}
if { [TCP::payload 2] equals "YW" } {
pool cntv_139.60_7001
}
if { [TCP::payload 2] equals "YX" } {
pool cntv_139.59_7001
}
if { [TCP::payload 2] equals "YY" } {
pool cntv_139.26_7001
}
if { [TCP::payload 2] equals "YZ" } {
pool cntv_139.24_7001
}
if { [TCP::payload 2] equals "A1" } {
pool moka_138.161_7001
}
if { [TCP::payload 2] equals "AA" } {
pool zhongjie_138.138_8888
}
if { [TCP::payload 2] equals "AB" } {
pool zhongjieyinan_138.202_8888
}
if { [TCP::payload 2] equals "A3" } {
pool moka_138.159_7001
}
if { [TCP::payload 2] equals "ZN" } {
pool shuziwanshi_138.195_9999
}
if { [TCP::payload 2] equals "00" } {
pool leduo_138.39_8888
}
if { [TCP::payload 2] equals "ZM" } {
pool shenqi_139.48_11001
}
if { [TCP::payload 2] equals "ZL" } {
pool shenqi_139.41_11002
}
if { [TCP::payload 2] equals "ZK" } {
pool shenqi_139.45_11001
}
if { [TCP::payload 2] equals "ZJ" } {
pool shenqi_139.46_11001
}
if { [TCP::payload 2] equals "ZI" } {
pool shenqi_139.47_11001
}
if { [TCP::payload 2] equals "01" } {
pool leduo_138.201_8888
}
if { [TCP::payload 2] equals "02" } {
pool leduo_138.34_8888
}
if { [TCP::payload 2] equals "ZZ" } {
pool zhangshang_139.4_7001
}
if { [TCP::payload 2] equals "ZY" } {
pool zhangshang_139.5_7001
}
if { [TCP::payload 2] equals "ZX" } {
pool zhangshang_139.11_7001
}
if { [TCP::payload 2] equals "ZW" } {
pool zhangshang_139.12_7001
}
if { [TCP::payload 2] equals "ZV" } {
pool zhangshang_139.57_7001
}
if { [TCP::payload 2] equals "ZU" } {
pool zhangshang_139.58_7001
}
if { [TCP::payload 2] equals "YN" } {
pool 99leyou_137.34_18100
}
}
User Scenario:
Need to use one VIP (same IP) for different applications. All applications run on smart phones which has its own client; choose different service group based on the the first 2 TCP Payload bytes.
Code:
when CLIENT_ACCEPTED {
TCP::collect 2
}
when CLIENT_DATA {
if { [TCP::payload 2] equals "G1" } {
pool liujin_139.14_9000
}
if { [TCP::payload 2] equals "YM" } {
pool shensui_139.2_8888
}
if { [TCP::payload 2] equals "ZH" } {
pool cntv_139.69_7001
}
if { [TCP::payload 2] equals "ZG" } {
pool cntv_139.70_7001
}
if { [TCP::payload 2] equals "ZF" } {
pool cntv_139.3_7001
}
if { [TCP::payload 2] equals "ZA" } {
pool cntv_139.23_7001
}
if { [TCP::payload 2] equals "ZB" } {
pool cntv_139.9_7001
}
if { [TCP::payload 2] equals "ZC" } {
pool cntv_139.8_7001
}
if { [TCP::payload 2] equals "ZD" } {
pool cntv_139.7_7001
}
if { [TCP::payload 2] equals "ZE" } {
pool cntv_139.6_7001
}
if { [TCP::payload 2] equals "YO" } {
pool cntv_139.68_7001
}
if { [TCP::payload 2] equals "YP" } {
pool cntv_139.67_7001
}
if { [TCP::payload 2] equals "YQ" } {
pool cntv_139.66_7001
}
if { [TCP::payload 2] equals "YR" } {
pool cntv_139.65_7001
}
if { [TCP::payload 2] equals "YS" } {
pool cntv_139.64_7001
}
if { [TCP::payload 2] equals "YT" } {
pool cntv_139.63_7001
}
if { [TCP::payload 2] equals "YU" } {
pool cntv_139.62_7001
}
if { [TCP::payload 2] equals "YV" } {
pool cntv_139.61_7001
}
if { [TCP::payload 2] equals "YW" } {
pool cntv_139.60_7001
}
if { [TCP::payload 2] equals "YX" } {
pool cntv_139.59_7001
}
if { [TCP::payload 2] equals "YY" } {
pool cntv_139.26_7001
}
if { [TCP::payload 2] equals "YZ" } {
pool cntv_139.24_7001
}
if { [TCP::payload 2] equals "A1" } {
pool moka_138.161_7001
}
if { [TCP::payload 2] equals "AA" } {
pool zhongjie_138.138_8888
}
if { [TCP::payload 2] equals "AB" } {
pool zhongjieyinan_138.202_8888
}
if { [TCP::payload 2] equals "A3" } {
pool moka_138.159_7001
}
if { [TCP::payload 2] equals "ZN" } {
pool shuziwanshi_138.195_9999
}
if { [TCP::payload 2] equals "00" } {
pool leduo_138.39_8888
}
if { [TCP::payload 2] equals "ZM" } {
pool shenqi_139.48_11001
}
if { [TCP::payload 2] equals "ZL" } {
pool shenqi_139.41_11002
}
if { [TCP::payload 2] equals "ZK" } {
pool shenqi_139.45_11001
}
if { [TCP::payload 2] equals "ZJ" } {
pool shenqi_139.46_11001
}
if { [TCP::payload 2] equals "ZI" } {
pool shenqi_139.47_11001
}
if { [TCP::payload 2] equals "01" } {
pool leduo_138.201_8888
}
if { [TCP::payload 2] equals "02" } {
pool leduo_138.34_8888
}
if { [TCP::payload 2] equals "ZZ" } {
pool zhangshang_139.4_7001
}
if { [TCP::payload 2] equals "ZY" } {
pool zhangshang_139.5_7001
}
if { [TCP::payload 2] equals "ZX" } {
pool zhangshang_139.11_7001
}
if { [TCP::payload 2] equals "ZW" } {
pool zhangshang_139.12_7001
}
if { [TCP::payload 2] equals "ZV" } {
pool zhangshang_139.57_7001
}
if { [TCP::payload 2] equals "ZU" } {
pool zhangshang_139.58_7001
}
if { [TCP::payload 2] equals "YN" } {
pool 99leyou_137.34_18100
}
}
0