mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-1020: Relocate HostName conversion and clean up formatting.
This commit is contained in:
@@ -135,9 +135,6 @@ public class RestrictionVerificationService {
|
|||||||
public static RestrictionType allowedByHostRestrictions(String allowedHostsString,
|
public static RestrictionType allowedByHostRestrictions(String allowedHostsString,
|
||||||
String deniedHostsString, String remoteAddress) {
|
String deniedHostsString, String remoteAddress) {
|
||||||
|
|
||||||
// Convert the string to a HostName
|
|
||||||
HostName remoteHostName = new HostName(remoteAddress);
|
|
||||||
|
|
||||||
// If attributes do not exist or are empty then the action is allowed.
|
// If attributes do not exist or are empty then the action is allowed.
|
||||||
if ((allowedHostsString == null || allowedHostsString.isEmpty())
|
if ((allowedHostsString == null || allowedHostsString.isEmpty())
|
||||||
&& (deniedHostsString == null || deniedHostsString.isEmpty()))
|
&& (deniedHostsString == null || deniedHostsString.isEmpty()))
|
||||||
@@ -152,19 +149,27 @@ public class RestrictionVerificationService {
|
|||||||
return RestrictionType.IMPLICIT_DENY;
|
return RestrictionType.IMPLICIT_DENY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert the string to a HostName
|
||||||
|
HostName remoteHostName = new HostName(remoteAddress);
|
||||||
|
|
||||||
// Split denied hosts attribute and process each entry, checking them
|
// Split denied hosts attribute and process each entry, checking them
|
||||||
// against the current remote address, and returning false if a match is
|
// against the current remote address, and returning a deny restriction
|
||||||
// found.
|
// if a match is found, or if an error occurs in processing a host in
|
||||||
|
// the list.
|
||||||
List<HostName> deniedHosts = HostRestrictionParser.parseHostList(deniedHostsString);
|
List<HostName> deniedHosts = HostRestrictionParser.parseHostList(deniedHostsString);
|
||||||
for (HostName hostName : deniedHosts) {
|
for (HostName hostName : deniedHosts) {
|
||||||
try {
|
|
||||||
if (hostName.isAddress() && hostName.toAddress().contains(remoteHostName.asAddress()))
|
|
||||||
return RestrictionType.EXPLICIT_DENY;
|
|
||||||
|
|
||||||
else
|
try {
|
||||||
|
if (hostName.isAddress()
|
||||||
|
&& hostName.toAddress().contains(remoteHostName.asAddress())) {
|
||||||
|
return RestrictionType.EXPLICIT_DENY;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
for (IPAddress currAddr : hostName.toAllAddresses())
|
for (IPAddress currAddr : hostName.toAllAddresses())
|
||||||
if (currAddr.matches(remoteHostName.asAddressString()))
|
if (currAddr.matches(remoteHostName.asAddressString()))
|
||||||
return RestrictionType.EXPLICIT_DENY;
|
return RestrictionType.EXPLICIT_DENY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (UnknownHostException | HostNameException e) {
|
catch (UnknownHostException | HostNameException e) {
|
||||||
LOGGER.warn("Unknown or invalid host in denied hosts list: \"{}\"", hostName);
|
LOGGER.warn("Unknown or invalid host in denied hosts list: \"{}\"", hostName);
|
||||||
|
Reference in New Issue
Block a user