Commit 92d435b3 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Use a bitwise AND operator when restricting login inet addresses. JM-352


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1718 b35dd754-fafc-0310-a699-88a17e54d16e
parent 2a0dfd05
......@@ -132,9 +132,11 @@ public class ClientSession extends Session {
// is authorized to connect to the server
if (!allowedIPs.containsKey(connection.getInetAddress().getHostAddress())) {
byte[] address = connection.getInetAddress().getAddress();
String range1 = address[0] + "." + address[1] + "." + address[2] + ".*";
String range2 = address[0] + "." + address[1] + ".*.*";
String range3 = address[0] + ".*.*.*";
String range1 = (address[0] & 0xff) + "." + (address[1] & 0xff) + "." +
(address[2] & 0xff) +
".*";
String range2 = (address[0] & 0xff) + "." + (address[1] & 0xff) + ".*.*";
String range3 = (address[0] & 0xff) + ".*.*.*";
if (!allowedIPs.containsKey(range1) && !allowedIPs.containsKey(range2) &&
!allowedIPs.containsKey(range3)) {
// Client cannot connect from this IP address so end the stream and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment