diff options
Diffstat (limited to 'tunnel/src/main/java/com/wireguard/config')
9 files changed, 27 insertions, 0 deletions
diff --git a/tunnel/src/main/java/com/wireguard/config/Attribute.java b/tunnel/src/main/java/com/wireguard/config/Attribute.java index 1e9e25f0..659f7cf4 100644 --- a/tunnel/src/main/java/com/wireguard/config/Attribute.java +++ b/tunnel/src/main/java/com/wireguard/config/Attribute.java @@ -5,12 +5,15 @@ package com.wireguard.config; +import com.wireguard.util.NonNullForAll; + import java.util.Iterator; import java.util.regex.Matcher; import java.util.regex.Pattern; import java9.util.Optional; +@NonNullForAll public final class Attribute { private static final Pattern LINE_PATTERN = Pattern.compile("(\\w+)\\s*=\\s*([^\\s#][^#]*)"); private static final Pattern LIST_SEPARATOR = Pattern.compile("\\s*,\\s*"); diff --git a/tunnel/src/main/java/com/wireguard/config/BadConfigException.java b/tunnel/src/main/java/com/wireguard/config/BadConfigException.java index 6d41b065..89b3af2c 100644 --- a/tunnel/src/main/java/com/wireguard/config/BadConfigException.java +++ b/tunnel/src/main/java/com/wireguard/config/BadConfigException.java @@ -5,10 +5,13 @@ package com.wireguard.config; +import com.wireguard.util.NonNullForAll; + import androidx.annotation.Nullable; import com.wireguard.crypto.KeyFormatException; +@NonNullForAll public class BadConfigException extends Exception { private final Location location; private final Reason reason; diff --git a/tunnel/src/main/java/com/wireguard/config/Config.java b/tunnel/src/main/java/com/wireguard/config/Config.java index 62651b08..f86eb6fd 100644 --- a/tunnel/src/main/java/com/wireguard/config/Config.java +++ b/tunnel/src/main/java/com/wireguard/config/Config.java @@ -5,6 +5,8 @@ package com.wireguard.config; +import com.wireguard.util.NonNullForAll; + import androidx.annotation.Nullable; import com.wireguard.config.BadConfigException.Location; @@ -29,6 +31,7 @@ import java.util.Set; * <p> * Instances of this class are immutable. */ +@NonNullForAll public final class Config { private final Interface interfaze; private final List<Peer> peers; diff --git a/tunnel/src/main/java/com/wireguard/config/InetAddresses.java b/tunnel/src/main/java/com/wireguard/config/InetAddresses.java index 1479b5ff..9b0ab965 100644 --- a/tunnel/src/main/java/com/wireguard/config/InetAddresses.java +++ b/tunnel/src/main/java/com/wireguard/config/InetAddresses.java @@ -5,6 +5,8 @@ package com.wireguard.config; +import com.wireguard.util.NonNullForAll; + import java.lang.reflect.Method; import java.net.Inet4Address; import java.net.Inet6Address; @@ -17,6 +19,7 @@ import androidx.annotation.Nullable; /** * Utility methods for creating instances of {@link InetAddress}. */ +@NonNullForAll public final class InetAddresses { @Nullable private static final Method PARSER_METHOD; private static final Pattern WONT_TOUCH_RESOLVER = Pattern.compile("^(((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?)|((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))$"); diff --git a/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java b/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java index a442258e..69c60806 100644 --- a/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java +++ b/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java @@ -5,6 +5,8 @@ package com.wireguard.config; +import com.wireguard.util.NonNullForAll; + import androidx.annotation.Nullable; import org.threeten.bp.Duration; @@ -25,6 +27,7 @@ import java9.util.Optional; * <p> * Instances of this class are externally immutable. */ +@NonNullForAll public final class InetEndpoint { private static final Pattern BARE_IPV6 = Pattern.compile("^[^\\[\\]]*:[^\\[\\]]*"); private static final Pattern FORBIDDEN_CHARACTERS = Pattern.compile("[/?#]"); diff --git a/tunnel/src/main/java/com/wireguard/config/InetNetwork.java b/tunnel/src/main/java/com/wireguard/config/InetNetwork.java index f89322fd..0c993fc8 100644 --- a/tunnel/src/main/java/com/wireguard/config/InetNetwork.java +++ b/tunnel/src/main/java/com/wireguard/config/InetNetwork.java @@ -5,6 +5,8 @@ package com.wireguard.config; +import com.wireguard.util.NonNullForAll; + import java.net.Inet4Address; import java.net.InetAddress; @@ -13,6 +15,7 @@ import java.net.InetAddress; * <p> * Instances of this class are immutable. */ +@NonNullForAll public final class InetNetwork { private final InetAddress address; private final int mask; diff --git a/tunnel/src/main/java/com/wireguard/config/Interface.java b/tunnel/src/main/java/com/wireguard/config/Interface.java index 54944424..efe00ce7 100644 --- a/tunnel/src/main/java/com/wireguard/config/Interface.java +++ b/tunnel/src/main/java/com/wireguard/config/Interface.java @@ -5,6 +5,8 @@ package com.wireguard.config; +import com.wireguard.util.NonNullForAll; + import androidx.annotation.Nullable; import com.wireguard.config.BadConfigException.Location; @@ -35,6 +37,7 @@ import java9.util.stream.StreamSupport; * <p> * Instances of this class are immutable. */ +@NonNullForAll public final class Interface { private static final int MAX_UDP_PORT = 65535; private static final int MIN_UDP_PORT = 0; diff --git a/tunnel/src/main/java/com/wireguard/config/ParseException.java b/tunnel/src/main/java/com/wireguard/config/ParseException.java index c79d1fa1..f4da7ccd 100644 --- a/tunnel/src/main/java/com/wireguard/config/ParseException.java +++ b/tunnel/src/main/java/com/wireguard/config/ParseException.java @@ -5,10 +5,13 @@ package com.wireguard.config; +import com.wireguard.util.NonNullForAll; + import androidx.annotation.Nullable; /** */ +@NonNullForAll public class ParseException extends Exception { private final Class<?> parsingClass; private final CharSequence text; diff --git a/tunnel/src/main/java/com/wireguard/config/Peer.java b/tunnel/src/main/java/com/wireguard/config/Peer.java index 37fcfa69..ef91a306 100644 --- a/tunnel/src/main/java/com/wireguard/config/Peer.java +++ b/tunnel/src/main/java/com/wireguard/config/Peer.java @@ -5,6 +5,8 @@ package com.wireguard.config; +import com.wireguard.util.NonNullForAll; + import androidx.annotation.Nullable; import com.wireguard.config.BadConfigException.Location; @@ -28,6 +30,7 @@ import java9.util.Optional; * <p> * Instances of this class are immutable. */ +@NonNullForAll public final class Peer { private final Set<InetNetwork> allowedIps; private final Optional<InetEndpoint> endpoint; |