Skip to content

Commit

Permalink
Remove apache commons validator. We only used one method that can be …
Browse files Browse the repository at this point in the history
…done with a regex.

Minor gradle tweaks
  • Loading branch information
LossyDragon committed May 5, 2024
1 parent 0618325 commit 1299ee6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
8 changes: 3 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ tasks.dokkaJavadoc {
}
}

// Make sure Maven Publishing gets javadock
// Make sure Maven Publishing gets javadoc
// https://stackoverflow.com/a/71172854
lateinit var javadocArtifact: PublishArtifact
tasks {
Expand Down Expand Up @@ -108,12 +108,10 @@ sourceSets.main {
tasks["lintKotlinMain"].dependsOn("formatKotlin")
tasks["check"].dependsOn("jacocoTestReport")
tasks["compileJava"].dependsOn("generateSteamLanguage", "generateProjectVersion", "generateRpcMethods")
// tasks["build"].finalizedBy(dokkaJavadocJar)

dependencies {
implementation(libs.commons.io)
implementation(libs.commons.lang3)
implementation(libs.commons.validator)
implementation(libs.gson)
implementation(libs.kotlin.coroutines)
implementation(libs.kotlin.stdib)
Expand Down Expand Up @@ -145,12 +143,12 @@ publishing {
scm {
connection = "scm:git:git://github.com/Longi94/JavaSteam.git"
developerConnection = "scm:git:ssh://github.com:Longi94/JavaSteam.git"
url = "http://github.com/Longi94/JavaSteam/tree/master"
url = "https://github.com/Longi94/JavaSteam/tree/master"
}
licenses {
license {
name = "MIT License"
url = "http://www.opensource.org/licenses/mit-license.php"
url = "https://www.opensource.org/licenses/mit-license.php"
}
}
developers {
Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ kotlinter = "4.3.0" # https://plugins.gradle.org/plugin/org.jmailen.kotlinter
bouncyCastle = "1.78" # https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on
commons-io = "2.16.0" # https://mvnrepository.com/artifact/commons-io/commons-io
commons-lang3 = "3.14.0" # https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
commons-validator = "1.8.0" # https://mvnrepository.com/artifact/commons-validator/commons-validator
gson = "2.10.1" # https://mvnrepository.com/artifact/com.google.code.gson/gson
jacoco = "0.8.12" # https://www.eclemma.org/jacoco
javaWebSocket = "1.5.6" # https://mvnrepository.com/artifact/org.java-websocket/Java-WebSocket
Expand All @@ -35,7 +34,6 @@ mockitoVersion = "5.11.0" # https://mvnrepository.com/artifact/org.mockito/mocki
bouncyCastle = { module = "org.bouncycastle:bcprov-jdk18on", version.ref = "bouncyCastle" }
commons-io = { module = "commons-io:commons-io", version.ref = "commons-io" }
commons-lang3 = { module = "org.apache.commons:commons-lang3", version.ref = "commons-lang3" }
commons-validator = { module = "commons-validator:commons-validator", version.ref = "commons-validator" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" }
kotlin-stdib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/in/dragonbra/javasteam/util/NetHelpers.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package in.dragonbra.javasteam.util;

import org.apache.commons.validator.routines.InetAddressValidator;

import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* @author lngtr
* @since 2018-02-22
*/
public class NetHelpers {

private static final String IPV4_REGEX = "^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$";

private static final Pattern pattern = Pattern.compile(IPV4_REGEX);

public static InetAddress getIPAddress(int ipAddr) {
ByteBuffer b = ByteBuffer.allocate(4);
b.putInt(ipAddr);
Expand All @@ -39,7 +44,9 @@ public static InetSocketAddress tryParseIPEndPoint(String address) {

String[] split = address.split(":");

if (!InetAddressValidator.getInstance().isValidInet4Address(split[0])) {
Matcher matcher = pattern.matcher(split[0]);

if (!matcher.matches()) {
return null;
}

Expand Down

0 comments on commit 1299ee6

Please sign in to comment.