mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-25 03:35:18 +01:00
Add support for using X-Forwarded-From for better proxy IP handling on
webchat
This commit is contained in:
parent
397f97800c
commit
40ee132277
@ -41,7 +41,13 @@ public class SendMessageHandler implements HttpHandler {
|
|||||||
|
|
||||||
JSONObject o = (JSONObject)parser.parse(reader);
|
JSONObject o = (JSONObject)parser.parse(reader);
|
||||||
final Message message = new Message();
|
final Message message = new Message();
|
||||||
//message.name = String.valueOf(o.get("name")); //Can't trust client....we don't need to on internal web server
|
/* If proxied client address, get original */
|
||||||
|
if(request.fields.containsKey("X-Forwarded-For"))
|
||||||
|
message.name = request.fields.get("X-Forwarded-For");
|
||||||
|
/* If from loopback, we're probably getting from proxy - need to trust client */
|
||||||
|
else if(request.rmtaddr.getAddress().isLoopbackAddress())
|
||||||
|
message.name = String.valueOf(o.get("name"));
|
||||||
|
else
|
||||||
message.name = request.rmtaddr.getAddress().getHostAddress();
|
message.name = request.rmtaddr.getAddress().getHostAddress();
|
||||||
message.message = String.valueOf(o.get("message"));
|
message.message = String.valueOf(o.get("message"));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user