@@ -140,48 +140,16 @@ private String getUserAgentStringLc()
140
140
}
141
141
142
142
/**
143
- * When using ProxyPass, requestCycle().getHttpServletRequest(). getRemoteAddr() returns the IP
144
- * of the machine forwarding the request. In order to maintain the clients ip address, the
145
- * server places it in the <a
146
- * href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#x-headers">X-Forwarded-For</a>
147
- * Header.
148
- *
149
- * Proxies may also mask the original client IP with tokens like "hidden" or "unknown".
150
- * If so, the last proxy ip address is returned.
143
+ * Returns the IP address from {@code HttpServletRequest.getRemoteAddr()}.
151
144
*
152
145
* @param requestCycle
153
146
* the request cycle
154
- * @return remoteAddr IP address of the client, using the X-Forwarded-For header and defaulting
155
- * to: getHttpServletRequest().getRemoteAddr()
147
+ * @return remoteAddr IP address of the client, using
148
+ * {@code getHttpServletRequest().getRemoteAddr()}
156
149
*/
157
150
protected String getRemoteAddr (RequestCycle requestCycle )
158
151
{
159
152
ServletWebRequest request = (ServletWebRequest )requestCycle .getRequest ();
160
- HttpServletRequest req = request .getContainerRequest ();
161
- String remoteAddr = request .getHeader ("X-Forwarded-For" );
162
-
163
- if (remoteAddr != null )
164
- {
165
- if (remoteAddr .contains ("," ))
166
- {
167
- // sometimes the header is of form client ip,proxy 1 ip,proxy 2 ip,...,proxy n ip,
168
- // we just want the client
169
- remoteAddr = Strings .split (remoteAddr , ',' )[0 ].trim ();
170
- }
171
- try
172
- {
173
- // If ip4/6 address string handed over, simply does pattern validation.
174
- InetAddress .getByName (remoteAddr );
175
- }
176
- catch (UnknownHostException e )
177
- {
178
- remoteAddr = req .getRemoteAddr ();
179
- }
180
- }
181
- else
182
- {
183
- remoteAddr = req .getRemoteAddr ();
184
- }
185
- return remoteAddr ;
153
+ return request .getContainerRequest ().getRemoteAddr ();
186
154
}
187
155
}
0 commit comments