mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 19:25:15 +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,8 +41,14 @@ 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 */
|
||||||
message.name = request.rmtaddr.getAddress().getHostAddress();
|
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.message = String.valueOf(o.get("message"));
|
message.message = String.valueOf(o.get("message"));
|
||||||
|
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
|
Loading…
Reference in New Issue
Block a user