First commit

This commit is contained in:
2024-11-15 10:47:51 +07:00
commit 2d647fd470
2 changed files with 51 additions and 0 deletions

47
src/AASMini/AASMini.java Normal file
View File

@@ -0,0 +1,47 @@
package AASMini;
import org.pmw.tinylog.Logger;
import java.net.InetAddress;
import java.net.Socket;
public class AASMini {
private final String targetIP;
private final int targetPort;
private Socket socket;
/**
* Create a new AAS Mini object
* @param ip IP Address of the AAS Mini
* @param port Port of the AAS Mini
*/
public AASMini(String ip , int port){
this.targetIP = ip;
this.targetPort = port;
}
/**
* Connect to AAS Mini
* @return true if connected, false otherwise
*/
public boolean Connect(){
try{
if (InetAddress.getByName(targetIP).isReachable(2000)){
if (targetPort > 0 && targetPort < 65535){
Socket sock = new Socket(targetIP, targetPort);
if (sock.isConnected()){
Logger.info("Connected to {}:{{}", targetIP, targetPort);
socket = sock;
return true;
}
} else Logger.error("Invalid port number {}", targetPort);
} else Logger.error("Failed to reach {}", targetIP);
} catch (Exception e){
Logger.error("Failed to connect to {}:{}, Error : {}", targetIP, targetPort, e.getMessage());
}
return false;
}
}

View File

@@ -0,0 +1,4 @@
package ProtegeGX;
public class ProtegeGX {
}