Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.deano2390:stunclient:-SNAPSHOT'
}
dependencies {
implementation("com.github.deano2390:stunclient:-SNAPSHOT")
}
<dependency>
<groupId>com.github.deano2390</groupId>
<artifactId>stunclient</artifactId>
<version>-SNAPSHOT</version>
</dependency>
libraryDependencies += "com.github.deano2390" % "stunclient" % "-SNAPSHOT"
:dependencies [[com.github.deano2390/stunclient "-SNAPSHOT"]]
STUN client for Android
Forked from https://github.com/mangefoo/stunclient itself based on https://github.com/tking/JSTUN
Add the jitpack repo to your your project's build.gradle at the end of repositories
/build.gradle
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
Then add the dependency to your module's build.gradle:
/app/build.gradle
dependencies {
compile 'com.github.deano2390:stunclient:0.4'
}
So far I have only usd this to obtain my public IP address from a STUN server:
try {
String publicIPV4, publicIPV6;
LoggerFactory.setObserver(JoinGridHandler.this);
//String stunServer = "numb.viagenie.ca"; // server supports IPV6
String stunServer = "stun.xten.com";
PublicIPDiscoveryTest test = new PublicIPDiscoveryTest(InetAddress.getByName("0.0.0.0"), stunServer, 3478);
DiscoveryInfo discoveryInfo = test.test();
if (discoveryInfo != null) {
if (discoveryInfo.getPublicIPV4() != null) {
publicIPV4 = discoveryInfo.getPublicIPV4().getHostAddress();
}
if (discoveryInfo.getPublicIPV6() != null) {
publicIPV6 = discoveryInfo.getPublicIPV6();
}
}
} catch (Exception e) {
e.printStackTrace();
}