Skip to content
This repository has been archived by the owner on May 29, 2022. It is now read-only.
/ network-tools Public archive

Tools for network operations and TOR exit node checking.

License

Notifications You must be signed in to change notification settings

alexsgi/network-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NetworkTools

CI

THIS PROJECT IS DEPRECATED AND WON'T BE CONTINUED. SWITCH TO OTHER TOOLS INSTEAD.

Tools for some network operations like ping, tracert with Java. Check if an IP address is a TOR exit node.

1. Import

Gradle:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    implementation 'com.github.alexsgi:network-tools:VERSION'
}

Maven:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.github.alexsgi</groupId>
        <artifactId>network-tools</artifactId>
        <version>VERSION</version>
    </dependency>
</dependencies>

2. Features

Network operations:

Ping: (DEPRECATED)

NetworkTools.ping(String url, CommandCallback callback);
NetworkTools.ping("www.example.com", new CommandCallback() {
    @Override 
    public void onFinish(String output) {
        System.out.println(output);
    }
    
    @Override 
    public void onError(Exception e) {
        e.printStackTrace();
    }  
});

Traceroute (tracert , traceroute): (DEPRECATED)

NetworkTools.traceroute(String url, CommandCallback callback);
NetworkTools.tracerout("www.example.com", new CommandCallback() {
    @Override 
    public void onFinish(String output) {
        System.out.println(ouput);
    }
    
    @Override 
    public void onError(Exception e) {
        e.printStackTrace();
    }  
});

Important : ping and tracerout always check if the OS is Windows or Linux. On this way it runs another command on the command line (Linux : tracerout ; Windows : tracert). String output is not formatted - just the output of the OS.

still in development


Check for devices in network :

NetworkTools.checkForHosts(String subnet, HostCallback callback);
NetworkTools.checkForHosts(String subnet, HostCallback callback, int timeout);
NetworkTools.checkForHosts(String subnet, HostCallback callback, int timeout, int beginIndex);
NetworkTools.checkForHosts(String subnet, HostCallback callback, int timeout, int beginIndex, int endIndex);
NetworkTools.checkForHosts("192.168.178", new HostCallback() {  
    @Override  
    public void onDeviceFound(String host) {  
        System.out.println(host + " is reachable");
    }  
  
    @Override  
    public void onFinish(String[] hosts) {  
	    System.out.println(hosts.length + " devices found in network");
    }  
});

Notice :
default timeout: 1000 ms
default begin index: 0
default end index: 254


TOR exit node verification :

All TOR exit node addresses are online available. Let's check if an IP address is a TOR exit address:

TorData.checkIpIsExitNode("XX.XXX.XXX.XXX", new CommandCallback() {
    @Override 
    public void onFinish(String output) {  
        if(output == null) {
            System.out.println("IP is not a TOR exit node");
        } else {
            System.err.println("TOR exit node found !");
        }
    }  
  
    @Override  
    public void onError(Exception e) {
        e.printStackTrace();
    }  
});

Following options are available:

static ArrayList<ExitNode> getAllExitNodes();
static void setTorExitAddressURL(String newUrl);
static void resetTorExitAddressURL();