diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..9008f46 --- /dev/null +++ b/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: co.proxychecker.ProxyChecker.startup.ProxyChecker + diff --git a/src/co/proxychecker/ProxyChecker/assets/icon.png b/src/co/proxychecker/ProxyChecker/assets/icon.png new file mode 100644 index 0000000..cccb548 Binary files /dev/null and b/src/co/proxychecker/ProxyChecker/assets/icon.png differ diff --git a/src/co/proxychecker/ProxyChecker/commands/ExportCommand.java b/src/co/proxychecker/ProxyChecker/commands/ExportCommand.java new file mode 100644 index 0000000..c7750c0 --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/commands/ExportCommand.java @@ -0,0 +1,150 @@ +package co.proxychecker.ProxyChecker.commands; + + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; + +import javafx.scene.control.Alert; +import javafx.scene.control.ListView; +import javafx.scene.control.TableView; + +import co.proxychecker.ProxyChecker.gui.AlertBox; +import co.proxychecker.ProxyChecker.components.entities.Proxy; +import co.proxychecker.ProxyChecker.components.entities.ProxyStatus; +import co.proxychecker.ProxyChecker.components.entities.ProxyAnonymity; + +/** + * Class contains static methods that facilitate exporting a Proxies to disk. + */ +public class ExportCommand { + + /** + * Gets a user selected destination file to save all loaded proxies onto, in the format ip:port + * @param listView - collection component + */ + public static void save(ListView listView) { + if (listView.getItems().size() != 0) { + File file = FileCommand.getFileToSave(false); + if (file != null) { + try { + PrintWriter printWriter = new PrintWriter(new FileWriter(file)); + for (String ip_port : listView.getItems()) { + printWriter.write(ip_port + "\n"); + } + printWriter.close(); + AlertBox.show(Alert.AlertType.INFORMATION, "Proxies Exported", + "All proxies have been successfully exported to disk!"); + } catch (IOException e) { + AlertBox.show(Alert.AlertType.ERROR, "Export Failed", + "Unable to export the data. Error: " + e.getMessage()); + } + } + } else { + AlertBox.show(Alert.AlertType.INFORMATION, "No Proxies", + "There's currently no proxies loaded to export!"); + } + } + + /** + * Gets a user selected destination file to export the proxy table in a comma separated value file. + * @param tableView - collection component + */ + public static void save(TableView tableView) { + if (tableView.getItems().size() != 0) { + File file = FileCommand.getFileToSave(true); + if (file != null) { + try { + PrintWriter printWriter = new PrintWriter(new FileWriter(file)); + for (Proxy proxy : tableView.getItems()) { + printWriter.write(getCSV(proxy)); + } + printWriter.close(); + AlertBox.show(Alert.AlertType.INFORMATION, "Table Exported", + "The table has been successfully exported to disk!"); + } catch (IOException e) { + AlertBox.show(Alert.AlertType.ERROR, "Export Failed", + "Unable to export the table. Error: " + e.getMessage()); + } + } + } else { + AlertBox.show(Alert.AlertType.INFORMATION, "No Data", + "There's currently no data to export!"); + } + } + + /** + * Gets a user selected destination file to export the proxy table based on the given ProxyStatus and + * ProxyAnonymity values, in the format ip:port + * @param tableView - collection component + * @param proxyStatus - The ProxyStatus + * @param proxyAnonymity - The ProxyAnonymity (null for all proxies belonging to ProxyStatus) + */ + public static void save(TableView tableView, ProxyStatus proxyStatus, ProxyAnonymity proxyAnonymity) { + if (tableView.getItems().size() != 0) { + File file = FileCommand.getFileToSave(false); + if (file != null) { + try { + PrintWriter printWriter = new PrintWriter(new FileWriter(file)); + for (Proxy proxy : tableView.getItems()) { + + String line = getLine(proxy, proxyStatus, proxyAnonymity); + if (line != null) { // a valid line was given + printWriter.write(line); + } + } + printWriter.close(); + AlertBox.show(Alert.AlertType.INFORMATION, "Data Exported", + "The data has been successfully exported to disk!"); + } catch (IOException e) { + AlertBox.show(Alert.AlertType.ERROR, "Export Failed", + "Unable to export the data. Error: " + e.getMessage()); + } + } + } else { + AlertBox.show(Alert.AlertType.INFORMATION, "No Data", + "There's currently no data to export!"); + } + } + + /** + * Generates comma separated values (csv) for a given Proxy + * @param proxy - The Proxy object + * @return String - csv + */ + private static String getCSV(Proxy proxy) { + StringBuilder sb = new StringBuilder(); + sb.append(proxy.getIp() + ","); + sb.append(proxy.getPort() + ","); + sb.append(proxy.getProxyStatus() + ","); + sb.append(proxy.getProxyAnonymity() + ","); + sb.append(proxy.getCountry() + ","); + sb.append(proxy.getResponseTime() + "\n"); + + return sb.toString(); + } + + /** + * Generates a line in the form ip:port for a given proxy confining to ProxyStatus and ProxyAnonymity + * @param proxy - The Proxy object + * @param proxyStatus - The ProxyStatus + * @param proxyAnonymity - The ProxyAnonymity (null for all proxies belonging to ProxyStatus) + * @return String - in the form ip:port, + * null if the proxy does not confine to the given proxyStatus and/or proxyAnonymity + */ + private static String getLine(Proxy proxy, ProxyStatus proxyStatus, ProxyAnonymity proxyAnonymity) { + if (proxy.getProxyStatus() == proxyStatus) { + if (proxyAnonymity != null) { + if (proxyAnonymity == proxy.getProxyAnonymity()) { + return proxy.getIp() + ":" + proxy.getPort() + "\n"; + } else { + return null; + } + } else { + return proxy.getIp() + ":" + proxy.getPort() + "\n"; + } + } + return null; + } +} diff --git a/src/co/proxychecker/ProxyChecker/commands/FileCommand.java b/src/co/proxychecker/ProxyChecker/commands/FileCommand.java new file mode 100644 index 0000000..74b886a --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/commands/FileCommand.java @@ -0,0 +1,47 @@ +package co.proxychecker.ProxyChecker.commands; + +import java.io.File; +import java.util.List; + +import javafx.stage.FileChooser; + +/** + * Contains static methods that allow selecting a file to save or files to open in a dialog. + */ +public class FileCommand { + + private static FileChooser fileChooser; + + /** + * Show a dialog and get a File to save + * @param table - Whether or not the file dialog is to save a table (csv). + * @return File - The selected File object. + */ + public static File getFileToSave(boolean table) { + fileChooser = new FileChooser(); + fileChooser.setTitle("Save File"); + if(table) { + fileChooser.getExtensionFilters().addAll( + new FileChooser.ExtensionFilter("CSV File", "*.csv") + ); + } else { + fileChooser.getExtensionFilters().addAll( + new FileChooser.ExtensionFilter("TXT Files", "*.txt") + ); + } + return fileChooser.showSaveDialog(null); + } + + /** + * Shows a dialog and gets one or more files to open + * @return List - A list of files selected + */ + public static List getFilesToOpen() { + fileChooser = new FileChooser(); + fileChooser.setTitle("Open File(s)"); + fileChooser.getExtensionFilters().addAll( + new FileChooser.ExtensionFilter("TXT Files", "*.txt") + ); + return fileChooser.showOpenMultipleDialog(null); + } +} diff --git a/src/co/proxychecker/ProxyChecker/commands/LoadCommand.java b/src/co/proxychecker/ProxyChecker/commands/LoadCommand.java new file mode 100644 index 0000000..f888aa3 --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/commands/LoadCommand.java @@ -0,0 +1,69 @@ +package co.proxychecker.ProxyChecker.commands; + +import java.io.*; +import java.util.List; + +import javafx.scene.control.Alert; +import javafx.scene.control.ListView; + +import co.proxychecker.ProxyChecker.components.entities.Proxy; +import co.proxychecker.ProxyChecker.gui.AlertBox; + +/** + * Loads a file or string onto a ListView in the form ip:port + */ +public class LoadCommand { + + /** + * Manages the addition of one or more files onto the ListView + * @param view - Listview to add file contents onto + */ + public static void file(ListView view) { + List list = FileCommand.getFilesToOpen(); + if (list != null) { + for (File file : list) { + try (BufferedReader br = new BufferedReader(new FileReader(file))) { + String line; + while ((line = br.readLine()) != null) { + addItem(line, view); // only add if its a valid line + } + } catch (FileNotFoundException e) { + AlertBox.show(Alert.AlertType.INFORMATION, "File Not Found", + "The file you selected: " + file.getName() + ", doesn't seem to exist!"); + } catch (IOException e) { + AlertBox.show(Alert.AlertType.ERROR, "File Exception", + "Unable to read the file " + file.getName() + ". Error: " + e.getMessage()); + } + } + } + + } + + /** + * Manages the addition of a single string onto the ListView + * @param string - The String to add to the ListView + * @param view - The ListView to add the string onto. + */ + public static void string(String string, ListView view) { + if(view.getItems().contains(string)) { + AlertBox.show(Alert.AlertType.INFORMATION,"Already Loaded", + "The proxy you entered is already loaded and is ready to be checked!"); + } else if(!addItem(string, view)) { // make sure it was added + AlertBox.show(Alert.AlertType.ERROR,"Invalid Proxy Format", + "You must enter in a valid proxy in the format ip:port !"); + } + } + + /** + * Adds a string onto the listview provided its in a valid format + * @param string - The String to add to the ListView + * @param view - The ListView to add the string onto. + * @return Boolean - Whether addition of item onto the listview was successful + */ + private static boolean addItem(String string, ListView view) { + if( (Proxy.isValidFormat(string)) && (!view.getItems().contains(string))) { + return view.getItems().add(string); + } + return false; + } +} diff --git a/src/co/proxychecker/ProxyChecker/commands/ProxyCheckCommand.java b/src/co/proxychecker/ProxyChecker/commands/ProxyCheckCommand.java new file mode 100644 index 0000000..95b1e51 --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/commands/ProxyCheckCommand.java @@ -0,0 +1,108 @@ +package co.proxychecker.ProxyChecker.commands; + +import java.net.HttpURLConnection; +import java.net.InetSocketAddress; +import java.util.concurrent.Executors; +import java.util.concurrent.ExecutorService; + +import javafx.util.Pair; +import javafx.scene.control.*; +import javafx.application.Platform; + +import co.proxychecker.ProxyChecker.components.Settings; +import co.proxychecker.ProxyChecker.components.RequestAPI; +import co.proxychecker.ProxyChecker.components.UserSettings; +import co.proxychecker.ProxyChecker.components.entities.Proxy; +import co.proxychecker.ProxyChecker.components.entities.ProxyStatus; + +/** + * Takes each proxy value in the ListView, performs checks and updates TableView accordingly. + */ +public class ProxyCheckCommand { + + private static int thCount_start = Thread.activeCount(); + private static UserSettings settings = Settings.getConfig(); + + /** + * Setups the thread pool and launches asynchronous checks on the list of proxies + * @param listView - The ListView containing the proxies that will be checked + * @param tableView - The TableView that will be updated with the status of the proxies + */ + public static void check(ListView listView, TableView tableView) { + ExecutorService executorService = Executors.newFixedThreadPool(settings.getThreads()); + for (String proxy : listView.getItems()) { + executorService.submit( + new Checker( + new Proxy( // first creation of the Proxy object from the ListView + proxy, + settings.getProxyType() + ), + tableView + ) + ); + } + + executorService.shutdown(); + } + + /** + * @return Boolean - Whether or not if proxies are still being checked + */ + public static boolean isRunning() { + return (Thread.activeCount() - thCount_start) != 0; + } + + /** + * Task that asynchronous checks each proxy and updates the TableView + */ + private static class Checker implements Runnable { + + private Proxy proxy; + private TableView tableView; + + /** + * + * @param proxy - The Proxy object to check. + * @param tableView + */ + public Checker(Proxy proxy, TableView tableView) { + this.proxy = proxy; + this.tableView = tableView; + } + + @Override + public void run() { + RequestAPI requestAPI = new RequestAPI(settings); + java.net.Proxy proxy = new java.net.Proxy( + this.proxy.getProxyType(), + new InetSocketAddress( + this.proxy.getIp(), + this.proxy.getPort() + ) + ); + + Pair pair = requestAPI.connect(proxy); + if(pair != null) { + try { + this.proxy.setResponseTime(pair.getValue() + " (ms)"); + this.proxy.setProxyStatus(ProxyStatus.ALIVE); + RequestAPI.Response response = requestAPI.getResponse(pair.getKey()); + this.proxy.setProxyAnonymity(response.anonymity); + this.proxy.setCountry(response.country); + + } catch (Exception e) { + this.proxy.setProxyStatus(ProxyStatus.DEAD); + this.proxy.setProxyAnonymity(null); + } + } else { + this.proxy.setProxyStatus(ProxyStatus.DEAD); + this.proxy.setProxyAnonymity(null); + } + + // this has to be done on another thread + Platform.runLater(()-> { + tableView.getItems().add(this.proxy); + }); + } + } +} diff --git a/src/co/proxychecker/ProxyChecker/components/RequestAPI.java b/src/co/proxychecker/ProxyChecker/components/RequestAPI.java new file mode 100644 index 0000000..d2fca7f --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/components/RequestAPI.java @@ -0,0 +1,111 @@ +package co.proxychecker.ProxyChecker.components; + + +import java.net.URL; +import java.net.Proxy; +import java.io.IOException; +import java.io.BufferedReader; +import java.nio.charset.Charset; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; + +import com.google.gson.Gson; + +import javafx.util.Pair; + +import co.proxychecker.ProxyChecker.components.entities.ProxyAnonymity; + +/** + * Manages and makes a request to the API server + */ +public class RequestAPI { + + private UserSettings settings; + private String api_url = "http://api.proxychecker.co/"; + + /** + * The response given by the API server + */ + public class Response { + + public String ip; + public String country; + public ProxyAnonymity anonymity; + + } + + /** + * Create a new RequestAPI object to make API requests + * @param settings - UserSettings + */ + public RequestAPI(UserSettings settings) { + this.settings = settings; + } + + /** + * Takes a json string and parses it using the Response subclass. + * @param json - String to parse + * @return Response + */ + public Response getResponse(String json) { + return new Gson().fromJson(json, Response.class); + } + + /** + * Takes a HttpURLConnection object and reads the web response onto a String + * @param connection - HttpURLConnection that has been connected + * @return Response + * @throws IOException + */ + public Response getResponse(HttpURLConnection connection) throws IOException { + BufferedReader r = new BufferedReader(new InputStreamReader(connection.getInputStream(), + Charset.forName("UTF-8"))); + + StringBuilder sb = new StringBuilder(); + String line; + while ((line = r.readLine()) != null) { + sb.append(line); + } + return new Gson().fromJson(sb.toString(), Response.class); + } + + /** + * Given a proxy makes an attempt to connect to the API server, storing and returning + * the connection and the response time in a javafx.util.Pair + * @param proxy - The Proxy to use when attempting to connect to the API service + * @return null if unable to connect or javafx.util.Pair + */ + public Pair connect(Proxy proxy) { + try { + HttpURLConnection connection; + if(proxy == null) { + connection = (HttpURLConnection) new URL(this.api_url).openConnection(); + } else { + connection = (HttpURLConnection) new URL(this.get_query_url(settings.getIp())).openConnection(proxy); + } + connection.setRequestProperty("User-Agent", "Proxy Checker - (proxychecker.co)"); + connection.setRequestMethod("GET"); + connection.setConnectTimeout(settings.getTimeout()); + + long startTime = System.currentTimeMillis(); + connection.connect(); + long endTime = System.currentTimeMillis(); + return new Pair<>(connection, (endTime - startTime)); + } catch (IOException e) { + return null; + } + } + + /** + * Get the API url to Query based on option ip parameter. + * @param ip - The current users IP address + * @return String - API url to query + */ + private String get_query_url(String ip) { + if (ip == null) { + return api_url; + } else { + return api_url + "?ip=" + ip; + } + } +} diff --git a/src/co/proxychecker/ProxyChecker/components/Settings.java b/src/co/proxychecker/ProxyChecker/components/Settings.java new file mode 100644 index 0000000..19f2bab --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/components/Settings.java @@ -0,0 +1,89 @@ +package co.proxychecker.ProxyChecker.components; + +import java.io.*; + +import com.google.gson.Gson; +import com.google.gson.stream.JsonReader; + + +/** + * Manages Application settings and configuration files and directory + */ +public class Settings { + + private static final String APPLICATION_NAME = "Proxy Checker"; + private static final String APPLICATION_URL = "https://proxychecker.co"; + + public static String getApplicationName() { + return APPLICATION_NAME; + } + + public static String getApplicationUrl() { + return APPLICATION_URL; + } + + /** + * Gets the configuration file and parses it using Gson + * @return UserSettings + */ + public static UserSettings getConfig() { + try { + return new Gson().fromJson(new JsonReader(new FileReader(getConfigFile())), UserSettings.class); + } catch (IOException e) { + return null; + } + } + + /** + * Saves an updated UserSettings to disk + * @param userSettings - UserSettings + * @return boolean - Whether or not the save was successful + */ + public static boolean saveConfig(UserSettings userSettings) { + File file = new File(getSettingsFolder().getAbsolutePath() + File.separator + "config.json"); + try { + FileWriter writer = new FileWriter(file); + writer.write(new Gson().toJson(userSettings)); + writer.close(); + return true; + } catch (IOException e) { + return false; + } + } + + /** + * Get the configuration File object from the settings folder + * @return File + */ + public static File getConfigFile() { + File file = new File(getSettingsFolder().getAbsolutePath() + File.separator + "config.json"); + if(!file.exists()) { + if(!saveConfig(new UserSettings(5000,100))) { + throw new RuntimeException("Unable to save default config.json!"); + } + } + return file; + } + + + /** + * Gets the settings folder and creates it if it doesn't exist in the home directory + * @return File + */ + public static File getSettingsFolder() { + String safe_name = APPLICATION_NAME.replaceAll(" ", "_"); + File file = new File( + System.getProperty("user.home") + File.separator + "." + safe_name + File.separator + ); + if(!file.exists()) { + if(!file.mkdirs()) { + throw new RuntimeException("Unable to create application directory!"); + } + } + return file; + } + + + + +} diff --git a/src/co/proxychecker/ProxyChecker/components/UserSettings.java b/src/co/proxychecker/ProxyChecker/components/UserSettings.java new file mode 100644 index 0000000..5cedce3 --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/components/UserSettings.java @@ -0,0 +1,96 @@ +package co.proxychecker.ProxyChecker.components; + +import java.net.Proxy; + +/** + * Manages the user configurable system settings + */ +public class UserSettings { + + private int timeout; // timeout for checking the proxy + private int threads; // max threads + private String ip = "0.0.0.0"; // ip address of the user + private Proxy.Type type = java.net.Proxy.Type.HTTP; + + /** + * Creates a new UserSettings object + * @param timeout - int the timeout for web requests + * @param threads - int the number of threads to use + */ + public UserSettings(int timeout, int threads) { + this.setTimeout(timeout); + this.setThreads(threads); + } + + /** + * Gets the current IP address of the user + * @return String - IP address + */ + public String getIp() { + return this.ip; + } + + /** + * Gets the current maximum threads allowed to be spawned + * @return int - number of threads + */ + public int getThreads() { + return threads; + } + + /** + * Gets the timeout for web requests + * @return int - the timeout + */ + public int getTimeout() { + return timeout; + } + + /** + * Sets the current users IP address + * @param ip - String IP address + * @return UserSettings + */ + public UserSettings setIp(String ip) { + this.ip = ip; + return this; + } + + /** + * Sets the current preferred timeout for web requests + * @param timeout - int + * @return UserSettings + */ + public UserSettings setTimeout(int timeout) { + this.timeout = timeout; + return this; + } + + /** + * Sets the preffered maximum threads allowed to be spawned + * @param threads - int + * @return UserSettings + */ + public UserSettings setThreads(int threads) { + this.threads = threads; + return this; + } + + /** + * Sets the default proxy type that will be checked + * @param type - java.net.Proxy.Type (HTTP or SOCKS) + * @return UserSettings + */ + public UserSettings setProxyType(Proxy.Type type) { + this.type = type; + return this; + } + + /** + * Gets the default proxy type that will be checked + * @return java.net.Proxy.Type + */ + public Proxy.Type getProxyType() { + return this.type; + } +} diff --git a/src/co/proxychecker/ProxyChecker/components/entities/Proxy.java b/src/co/proxychecker/ProxyChecker/components/entities/Proxy.java new file mode 100644 index 0000000..d58495e --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/components/entities/Proxy.java @@ -0,0 +1,198 @@ +package co.proxychecker.ProxyChecker.components.entities; + +import java.net.Proxy.Type; + +import javafx.util.Pair; + +/** + * The main Proxy entity used throughout the system models a single Proxy + */ +public class Proxy { + + private int port; + private final String ip; + + private String country; + private String response_time; + + private Type type; + private ProxyStatus status; + private ProxyAnonymity level; + + /** + * Default values for the proxy object + */ + private void initProxyDefaults() { + this.response_time = null; // assume proxy is dead + this.setProxyStatus(ProxyStatus.DEAD); + this.setProxyAnonymity(ProxyAnonymity.TRANSPARENT); + } + + /** + * Create a new proxy object given a valid proxy string and type + * @param ip_port - String in the format ip:port + * @param type - java.net.Proxy.Type either HTTP or SOCKS + */ + public Proxy(String ip_port, Type type) { + Pair proxyPair = format(ip_port); + if(proxyPair == null) { + throw new RuntimeException("Proxy() called with a invalid formatted string!"); + } else { + this.ip = proxyPair.getKey(); + this.port = proxyPair.getValue(); + this.setProxyType(type); + this.initProxyDefaults(); + } + } + + /** + * Create a new proxy object given a IP address a port the proxy is running on and the proxy type + * @param ip - Integer the IP address of the proxy + * @param port - Integer the Port the proxy is running on + * @param type - java.net.Proxy.Type either HTTP or SOCKS + */ + public Proxy(String ip, int port, Type type) { + this.ip = ip; + this.port = port; + this.setProxyType(type); + this.initProxyDefaults(); + + } + + /** + * Formats the given string into a new javafx.util.Pair object + * @param ip_port - String in the format ip:port + * @return null if the IP address cannot be formatted (invalid format), + * if it's a valid format returns a javafx.util.Pair object with IP address as the key + * and the Port as the Value + */ + private static Pair format(String ip_port) { + String[] explode = ip_port.split(":"); + if(explode.length == 2) { + try { + int port = Integer.parseInt(explode[1]); + return new Pair<>(explode[0], port); + } catch (Exception e) { + return null; + } + } + return null; + } + + /** + * Determine whether or not a given string is in a valid proxy format + * @param ip_port - String in the format ip:port + * @return Boolean - Whether or not the given string is in the valid form ip:port. + */ + public static boolean isValidFormat(String ip_port) { + return (format(ip_port) != null); + } + + /** + * Get the IP Address of the Proxy + * @return String - IP address + */ + public String getIp() { + return this.ip; + } + + /** + * Get the Port of the Proxy + * @return int - Port + */ + public int getPort() { + return this.port; + } + + /** + * Sets the country of the Proxy + * @param country - String the name of the country + * @return Proxy - current Proxy object + */ + public Proxy setCountry(String country) { + this.country = country; + return this; + } + + /** + * Gets the country of the Proxy + * @return String - Country + */ + public String getCountry() { + return this.country; + } + + + /** + * Sets the response time of the proxy + * @param response_time - String response time (milliseconds) + * @return Proxy - current Proxy object + */ + public Proxy setResponseTime(String response_time) { + this.response_time = response_time; + return this; + } + + /** + * Gets the response time of the proxy + * @return String - Response Time + */ + public String getResponseTime() { + return this.response_time; + } + + /** + * Set the type of the Proxy + * @param type - java.net.Proxy.Type either HTTP or SOCKS + * @return Proxy - current Proxy object + */ + public Proxy setProxyType(Type type) { + this.type = type; + return this; + } + + /** + * Gets the type of the Proxy + * @return java.net.Proxy.Type + */ + public Type getProxyType() { + return this.type; + } + + /** + * Sets the status of the Proxy + * @param status - ProxyStatus either ALIVE or DEAD + * @return Proxy - current Proxy object + */ + public Proxy setProxyStatus(ProxyStatus status) { + this.status = status; + return this; + } + + /** + * Gets the status of the Proxy + * @return ProxyStatus - Either ALIVE or DEAD + */ + public ProxyStatus getProxyStatus() { + return this.status; + } + + /** + * Sets the Proxy anonymity + * @param level - ProxyAnonymity either ELITE ANONYMOUS or TRANSPARENT + * @return Proxy - current Proxy object + */ + public Proxy setProxyAnonymity(ProxyAnonymity level) { + this.level = level; + return this; + } + + /** + * Gets the Proxy anonymity + * @return ProxyAnonymity - Either ELITE ANONYMOUS or TRANSPARENT + */ + public ProxyAnonymity getProxyAnonymity() { + return this.level; + } + +} diff --git a/src/co/proxychecker/ProxyChecker/components/entities/ProxyAnonymity.java b/src/co/proxychecker/ProxyChecker/components/entities/ProxyAnonymity.java new file mode 100644 index 0000000..d46d0fa --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/components/entities/ProxyAnonymity.java @@ -0,0 +1,5 @@ +package co.proxychecker.ProxyChecker.components.entities; + +public enum ProxyAnonymity { + TRANSPARENT, ANONYMOUS, ELITE +} diff --git a/src/co/proxychecker/ProxyChecker/components/entities/ProxyStatus.java b/src/co/proxychecker/ProxyChecker/components/entities/ProxyStatus.java new file mode 100644 index 0000000..52784e5 --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/components/entities/ProxyStatus.java @@ -0,0 +1,5 @@ +package co.proxychecker.ProxyChecker.components.entities; + +public enum ProxyStatus { + ALIVE, DEAD +} diff --git a/src/co/proxychecker/ProxyChecker/gui/About.fxml b/src/co/proxychecker/ProxyChecker/gui/About.fxml new file mode 100644 index 0000000..5f305eb --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/gui/About.fxml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/co/proxychecker/ProxyChecker/gui/AlertBox.java b/src/co/proxychecker/ProxyChecker/gui/AlertBox.java new file mode 100644 index 0000000..4eebda9 --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/gui/AlertBox.java @@ -0,0 +1,31 @@ +package co.proxychecker.ProxyChecker.gui; + +import javafx.stage.Stage; +import javafx.scene.image.Image; +import javafx.scene.control.Alert; +import javafx.scene.control.ButtonType; + +import co.proxychecker.ProxyChecker.components.Settings; + +/** + * Creates an AlertBox + */ +public class AlertBox { + + /** + * Displays an AlertBox + * @param alertType - javafx.scene.control.Alert.AlertType + * @param header - Heading of the Alert + * @param content - Content of the Alert + */ + public static void show(Alert.AlertType alertType, String header, String content) { + Alert alert = new Alert(alertType, content, ButtonType.OK); + Stage dialogStage = (Stage) alert.getDialogPane().getScene().getWindow(); + dialogStage.getIcons().add( + new Image(AlertBox.class.getResourceAsStream("/co/proxychecker/ProxyChecker/assets/icon.png")) + ); + alert.setHeaderText(header); + alert.setTitle(Settings.getApplicationName()); + alert.show(); + } +} diff --git a/src/co/proxychecker/ProxyChecker/gui/ProxyChecker.fxml b/src/co/proxychecker/ProxyChecker/gui/ProxyChecker.fxml new file mode 100644 index 0000000..66831a2 --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/gui/ProxyChecker.fxml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/co/proxychecker/ProxyChecker/gui/Settings.fxml b/src/co/proxychecker/ProxyChecker/gui/Settings.fxml new file mode 100644 index 0000000..1eff525 --- /dev/null +++ b/src/co/proxychecker/ProxyChecker/gui/Settings.fxml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +