При указании в аргументах запуска адреса прокси в кавычках, программа сама применит прокси и будет его применять
This commit is contained in:
parent
6c31ac0e89
commit
e34d242688
Binary file not shown.
|
@ -0,0 +1,4 @@
|
||||||
|
@echo off
|
||||||
|
cls
|
||||||
|
start /B javaw -jar proxy.jar "http://proxy.mcs.br:8080/array.dll?Get.Routing.Script"
|
||||||
|
exit
|
Binary file not shown.
Binary file not shown.
|
@ -11,8 +11,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import static java.awt.Component.LEFT_ALIGNMENT;
|
|
||||||
import static javax.swing.JOptionPane.showMessageDialog;
|
import static javax.swing.JOptionPane.showMessageDialog;
|
||||||
import static org.dhaverdLogs.DhaverdLogs.*;
|
import static org.dhaverdLogs.DhaverdLogs.*;
|
||||||
import static org.proxy.loadConfig.*;
|
import static org.proxy.loadConfig.*;
|
||||||
|
@ -57,6 +55,30 @@ public class Main {
|
||||||
currentProxyPub = getCurrentProxy();
|
currentProxyPub = getCurrentProxy();
|
||||||
setLog("Proxy Checker", "Current proxy: " + currentProxyPub, true, false);
|
setLog("Proxy Checker", "Current proxy: " + currentProxyPub, true, false);
|
||||||
systemTray();
|
systemTray();
|
||||||
|
if (args.length != 0){
|
||||||
|
setProxyOnLaunch(args[0]);
|
||||||
|
updateIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setProxyOnLaunch(String proxyStr) throws IOException, InterruptedException {
|
||||||
|
setLog("Setting proxy on launch", "Proxy will be set on: " + proxyStr, true, false);
|
||||||
|
closeThread();
|
||||||
|
currentThread = new Thread(() -> {
|
||||||
|
while(true){
|
||||||
|
try {
|
||||||
|
currentProxyPub = getCurrentProxy();
|
||||||
|
if (!currentProxyPub.equals(proxyStr)) setProxy(proxyStr);
|
||||||
|
Image icon = Toolkit.getDefaultToolkit().getImage("res" + osSeparator + "icon on blue.png");
|
||||||
|
trayIcon.setImage(icon);
|
||||||
|
updateIcon();
|
||||||
|
Thread.sleep(repeatTime);
|
||||||
|
} catch (InterruptedException | IOException ex) {
|
||||||
|
exeptionActions( "Set proxy: " + proxyStr, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
currentThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCurrentProxy() throws InterruptedException, IOException {
|
public static String getCurrentProxy() throws InterruptedException, IOException {
|
||||||
|
@ -136,12 +158,6 @@ public class Main {
|
||||||
newProps.add("\t\t\"" + proxy + "\",");
|
newProps.add("\t\t\"" + proxy + "\",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
setLog("Add new proxy function", "New proxy list:", true, false);
|
|
||||||
for (String prop : newProps) {
|
|
||||||
setLog("Add new proxy function", prop, false, true);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
FileWriter writer = new FileWriter(config, false);
|
FileWriter writer = new FileWriter(config, false);
|
||||||
for (String prop : newProps) {
|
for (String prop : newProps) {
|
||||||
writer.write(prop + "\n");
|
writer.write(prop + "\n");
|
||||||
|
@ -250,9 +266,7 @@ public class Main {
|
||||||
|
|
||||||
//close button
|
//close button
|
||||||
JButton closeButton = new JButton("Close");
|
JButton closeButton = new JButton("Close");
|
||||||
closeButton.addActionListener(al -> {
|
closeButton.addActionListener(al -> frame.dispose());
|
||||||
frame.dispose();
|
|
||||||
});
|
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc.gridx = 2;
|
gbc.gridx = 2;
|
||||||
gbc.gridy = 1;
|
gbc.gridy = 1;
|
||||||
|
@ -316,9 +330,7 @@ public class Main {
|
||||||
mainPanel.add(deleteButton, gbc);
|
mainPanel.add(deleteButton, gbc);
|
||||||
JButton closeButton = new JButton("Close");
|
JButton closeButton = new JButton("Close");
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
closeButton.addActionListener(al -> {
|
closeButton.addActionListener(al -> frame.dispose());
|
||||||
frame.dispose();
|
|
||||||
});
|
|
||||||
mainPanel.add(closeButton, gbc);
|
mainPanel.add(closeButton, gbc);
|
||||||
frame.getContentPane().add(mainPanel);
|
frame.getContentPane().add(mainPanel);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
|
@ -355,12 +367,6 @@ public class Main {
|
||||||
newProps.add(prop);
|
newProps.add(prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
setLog("Add new proxy function", "New proxy list:", true, false);
|
|
||||||
for (String prop : newProps) {
|
|
||||||
setLog("Add new proxy function", prop, false, true);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
FileWriter writer = new FileWriter(config, false);
|
FileWriter writer = new FileWriter(config, false);
|
||||||
for (String prop : newProps) {
|
for (String prop : newProps) {
|
||||||
writer.write(prop + "\n");
|
writer.write(prop + "\n");
|
||||||
|
@ -381,8 +387,7 @@ public class Main {
|
||||||
currentThread = new Thread(() -> {
|
currentThread = new Thread(() -> {
|
||||||
while(true){
|
while(true){
|
||||||
try {
|
try {
|
||||||
currentProxyPub = getCurrentProxy();
|
updateIcon();
|
||||||
trayIcon.setToolTip("Current proxy: " + currentProxyPub);
|
|
||||||
Thread.sleep(repeatTime);
|
Thread.sleep(repeatTime);
|
||||||
} catch (InterruptedException | IOException ex) {
|
} catch (InterruptedException | IOException ex) {
|
||||||
exeptionActions("Stop Listener", ex);
|
exeptionActions("Stop Listener", ex);
|
||||||
|
@ -392,6 +397,12 @@ public class Main {
|
||||||
currentThread.start();
|
currentThread.start();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void updateIcon() throws IOException, InterruptedException {
|
||||||
|
currentProxyPub = getCurrentProxy();
|
||||||
|
trayIcon.setToolTip("Current proxy: " + currentProxyPub);
|
||||||
|
}
|
||||||
|
|
||||||
public static void closeThread(){
|
public static void closeThread(){
|
||||||
if (currentThread != null){
|
if (currentThread != null){
|
||||||
currentThread.stop();
|
currentThread.stop();
|
||||||
|
@ -409,8 +420,7 @@ public class Main {
|
||||||
if (!currentProxyPub.equals(proxyStr)) setProxy(proxyStr);
|
if (!currentProxyPub.equals(proxyStr)) setProxy(proxyStr);
|
||||||
Image icon = Toolkit.getDefaultToolkit().getImage("res" + osSeparator + "icon on blue.png");
|
Image icon = Toolkit.getDefaultToolkit().getImage("res" + osSeparator + "icon on blue.png");
|
||||||
trayIcon.setImage(icon);
|
trayIcon.setImage(icon);
|
||||||
currentProxyPub = getCurrentProxy();
|
updateIcon();
|
||||||
trayIcon.setToolTip("Current proxy: " + currentProxyPub);
|
|
||||||
Thread.sleep(repeatTime);
|
Thread.sleep(repeatTime);
|
||||||
} catch (InterruptedException | IOException ex) {
|
} catch (InterruptedException | IOException ex) {
|
||||||
exeptionActions( "Set proxy: " + proxyStr, ex);
|
exeptionActions( "Set proxy: " + proxyStr, ex);
|
||||||
|
|
Loading…
Reference in New Issue