Converted to kotlin
This commit is contained in:
parent
8d9bef0ccc
commit
4d0a1c9259
|
@ -13,24 +13,24 @@
|
|||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package dorkbox.network.ipFilter;
|
||||
package dorkbox.network.ipFilter
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.InetSocketAddress
|
||||
|
||||
/**
|
||||
* Implement this interface to create new rules.
|
||||
*/
|
||||
public interface IpFilterRule {
|
||||
interface IpFilterRule {
|
||||
/**
|
||||
* @return This method should return true if remoteAddress is valid according to your criteria. False otherwise.
|
||||
*/
|
||||
boolean matches(InetSocketAddress remoteAddress);
|
||||
fun matches(remoteAddress: InetSocketAddress): Boolean
|
||||
|
||||
/**
|
||||
* @return This method should return {@link IpFilterRuleType#ACCEPT} if all
|
||||
* {@link IpFilterRule#matches(InetSocketAddress)} for which {@link #matches(InetSocketAddress)}
|
||||
* @return This method should return [IpFilterRuleType.ACCEPT] if all
|
||||
* [IpFilterRule.matches] for which [.matches]
|
||||
* returns true should the accepted. If you want to exclude all of those IP addresses then
|
||||
* {@link IpFilterRuleType#REJECT} should be returned.
|
||||
* [IpFilterRuleType.REJECT] should be returned.
|
||||
*/
|
||||
IpFilterRuleType ruleType();
|
||||
fun ruleType(): IpFilterRuleType
|
||||
}
|
|
@ -13,12 +13,11 @@
|
|||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package dorkbox.network.ipFilter;
|
||||
package dorkbox.network.ipFilter
|
||||
|
||||
/**
|
||||
* Used in {@link IpFilterRule} to decide if a matching IP Address should be allowed or denied to connect.
|
||||
* Used in [IpFilterRule] to decide if a matching IP Address should be allowed or denied to connect.
|
||||
*/
|
||||
public enum IpFilterRuleType {
|
||||
ACCEPT,
|
||||
REJECT
|
||||
enum class IpFilterRuleType {
|
||||
ACCEPT, REJECT
|
||||
}
|
|
@ -21,8 +21,9 @@ import java.math.BigInteger
|
|||
import java.net.*
|
||||
|
||||
/**
|
||||
* Use this class to create rules for [RuleBasedIpFilter] that group IP addresses into subnets.
|
||||
* Supports both, IPv4 and IPv6.
|
||||
* Use this class to create rules that group IP addresses into subnets.
|
||||
*
|
||||
* Supports both IPv4 and IPv6.
|
||||
*/
|
||||
class IpSubnetFilterRule : IpFilterRule {
|
||||
companion object {
|
||||
|
@ -70,7 +71,7 @@ class IpSubnetFilterRule : IpFilterRule {
|
|||
}
|
||||
|
||||
private class FakeSubnetFilterRule() : IpFilterRule {
|
||||
override fun matches(remoteAddress: InetSocketAddress?): Boolean {
|
||||
override fun matches(remoteAddress: InetSocketAddress): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user