diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/org/proxy/Main.java b/src/org/proxy/Main.java
index d52c7e6..3da679e 100644
--- a/src/org/proxy/Main.java
+++ b/src/org/proxy/Main.java
@@ -8,10 +8,12 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.*;
+import java.util.List;
import java.util.Locale;
import static javax.swing.JOptionPane.showMessageDialog;
import static org.dhaverdLogs.DhaverdLogs.*;
+import static org.proxy.loadConfig.getProxyList;
import static org.proxy.loadConfig.getSocketPort;
public class Main {
@@ -53,7 +55,7 @@ public class Main {
setLog(context, "Local Socket Address: "+serverSocket.getLocalSocketAddress(), true, false);
}
- public static void systemTray() throws IOException {
+ public static void systemTray() throws IOException, ParseException {
String context = "SystemTray";
if(! SystemTray.isSupported() ) {
setLog(context,"System tray is unsupported!", true, false);
@@ -65,6 +67,17 @@ public class Main {
} else {
trayFont = new Font("Arial", Font.PLAIN, 12);
}
+ List proxyList = getProxyList();
+ int counter = 1;
+ PopupMenu trayMenu = new PopupMenu();
+ for (String prox : proxyList){
+ MenuItem proxy = new MenuItem(prox);
+ counter++;
+ proxy.setFont(trayFont);
+ proxy.addActionListener(proxyListener(prox));
+ trayMenu.add(proxy);
+ }
+ /*
PopupMenu trayMenu = new PopupMenu();
MenuItem proxyOn = new MenuItem("Proxy On");
proxyOn.setFont(trayFont);
@@ -72,11 +85,14 @@ public class Main {
MenuItem proxyOff = new MenuItem("Proxy Off");
proxyOff.setFont(trayFont);
proxyOff.addActionListener(proxyOffListener());
+ */
MenuItem trayExit = new MenuItem("Exit");
trayExit.setFont(trayFont);
trayExit.addActionListener(trayExitListener());
+ /*
trayMenu.add(proxyOn);
trayMenu.add(proxyOff);
+ */
trayMenu.add(trayExit);
Image icon;
if (isLinux){
@@ -130,6 +146,20 @@ public class Main {
return listener;
}
+ public static ActionListener proxyListener(String proxyStr) {
+ ActionListener listener = new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ try {
+ setProxy(proxyStr);
+ } catch (IOException | InterruptedException ex) {
+ exeptionActions("ProxyOn", ex);
+ }
+ }
+ };
+ return listener;
+ }
+
public static ActionListener proxyOffListener() {
ActionListener listener = new ActionListener() {
@Override
@@ -144,6 +174,11 @@ public class Main {
return listener;
}
+ public static void setProxy(String proxyStr) throws IOException, InterruptedException {
+ execute("reg delete \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\" /v AutoConfigURL /f");
+ execute("reg add \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\" /v AutoConfigURL /t REG_SZ /d \"" + proxyStr + "\"");
+ }
+
public static void setProxyOn() throws IOException, InterruptedException {
execute("reg delete \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\" /v AutoConfigURL /f");
execute("reg add \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\" /v AutoConfigURL /t REG_SZ /d \"http://proxy.mcs.br:8080/array.dll?Get.Routing.Script\"");
diff --git a/src/org/proxy/loadConfig.java b/src/org/proxy/loadConfig.java
index c108ba4..a26cf55 100644
--- a/src/org/proxy/loadConfig.java
+++ b/src/org/proxy/loadConfig.java
@@ -8,6 +8,7 @@ import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+import java.util.List;
import static org.dhaverdLogs.DhaverdLogs.setLog;
@@ -53,4 +54,14 @@ public class loadConfig {
return Integer.parseInt(result);
}
+ public static List getProxyList() throws IOException, ParseException {
+ JSONObject jo = getJsonObjConfig();
+ List result = (List) jo.get("proxyList");
+ setLog("Config Loading", "Proxy list loaded. Items count: " + result.size(), true, false);
+ for (String line : result) {
+ setLog("Config Loading", "Proxy list item: " + line, false, true);
+ }
+ return result;
+ }
+
}