Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions framework/src/play/server/PlayHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import java.io.File;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.InetSocketAddress;
import java.net.URLEncoder;
import java.net.*;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
Expand Down Expand Up @@ -547,14 +546,14 @@ public void copyResponse(ChannelHandlerContext ctx, Request request, Response re
}

static String getRemoteIPAddress(MessageEvent e) {
String fullAddress = ((InetSocketAddress) e.getRemoteAddress()).getAddress().getHostAddress();
if (fullAddress.matches("/[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+[:][0-9]+")) {
fullAddress = fullAddress.substring(1);
fullAddress = fullAddress.substring(0, fullAddress.indexOf(":"));
} else if (fullAddress.matches(".*[%].*")) {
fullAddress = fullAddress.substring(0, fullAddress.indexOf("%"));
}
return fullAddress;
final InetAddress inetAddress = ((InetSocketAddress) e.getRemoteAddress()).getAddress();
final byte[] address = inetAddress.getAddress();
try { //create a new inetaddress only from numeric ( without host and interface information)
return InetAddress.getByAddress(address).getHostAddress();
} catch (UnknownHostException unknownHostException) { //should never happen, else address is wrong
Logger.error(unknownHostException,"Error: resolving numeric address: %s", inetAddress.getHostAddress());
}
return null;
}

public Request parseRequest(ChannelHandlerContext ctx, HttpRequest nettyRequest, MessageEvent messageEvent) throws Exception {
Expand Down