Forum Discussion

vvskaladhar_488's avatar
vvskaladhar_488
Icon for Nimbostratus rankNimbostratus
Dec 22, 2015

Irule

HI, i am new to irules . i am trying below irule

                    when LOAD_BALANCER_COOKIE_NAME = "SOURCE_IP";

public static String getRemoteIPAddress(HttpServletRequest request) { Cookie cookie = getCookie(request, LOAD_BALANCER_COOKIE_NAME); if (cookie == null) { return request.getRemoteAddr(); }

if (cookie.getValue() == null || StringUtils.isEmpty(cookie.getValue())) { return request.getRemoteAddr(); } return cookie.getValue(); }

i am seeing below errror

01070151:3: Rule [/Common/test] error: /Common/test:1: error: [wrong args][when LOAD_BALANCER_COOKIE_NAME = "SOURCE_IP";] /Common/test:3: error: [undefined procedure: public][public static String getRemoteIPAddress(HttpServletRequest request) { Cookie cookie = getCookie(request, LOAD_BALANCER_COOKIE_NAME); if (cookie == null) { return request.getRemoteAddr(); }

if (cookie.getValue() == null || StringUtils.isEmpty(cookie.getValue())) { return request.getRemoteAddr(); } return cookie.getValue(); }]

Can some one help me correcting the irule.

4 Replies

  • Hi Vvskaladhar,

     

    an iRule has to be written in TCL (Tool Command Language), but the code you're using is written in Java.

     

    To help you further you may want to explain us, which task you have to perform with this rule?

     

    Cheers, Kai