При указании в аргументах запуска адреса прокси в кавычках, программа сама применит прокси и будет его применять
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.Locale; | ||||
| import java.util.Scanner; | ||||
| 
 | ||||
| import static java.awt.Component.LEFT_ALIGNMENT; | ||||
| import static javax.swing.JOptionPane.showMessageDialog; | ||||
| import static org.dhaverdLogs.DhaverdLogs.*; | ||||
| import static org.proxy.loadConfig.*; | ||||
|  | @ -57,6 +55,30 @@ public class Main { | |||
|         currentProxyPub = getCurrentProxy(); | ||||
|         setLog("Proxy Checker", "Current proxy: " + currentProxyPub, true, false); | ||||
|         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 { | ||||
|  | @ -136,12 +158,6 @@ public class Main { | |||
|                 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); | ||||
|         for (String prop : newProps) { | ||||
|             writer.write(prop + "\n"); | ||||
|  | @ -250,9 +266,7 @@ public class Main { | |||
| 
 | ||||
|             //close button | ||||
|             JButton closeButton = new JButton("Close"); | ||||
|             closeButton.addActionListener(al -> { | ||||
|                 frame.dispose(); | ||||
|             }); | ||||
|             closeButton.addActionListener(al -> frame.dispose()); | ||||
|             gbc.fill = GridBagConstraints.HORIZONTAL; | ||||
|             gbc.gridx = 2; | ||||
|             gbc.gridy = 1; | ||||
|  | @ -316,9 +330,7 @@ public class Main { | |||
|                 mainPanel.add(deleteButton, gbc); | ||||
|                 JButton closeButton = new JButton("Close"); | ||||
|                 gbc.gridx = 1; | ||||
|                 closeButton.addActionListener(al -> { | ||||
|                     frame.dispose(); | ||||
|                 }); | ||||
|                 closeButton.addActionListener(al -> frame.dispose()); | ||||
|                 mainPanel.add(closeButton, gbc); | ||||
|                 frame.getContentPane().add(mainPanel); | ||||
|                 frame.pack(); | ||||
|  | @ -355,12 +367,6 @@ public class Main { | |||
|                 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); | ||||
|         for (String prop : newProps) { | ||||
|             writer.write(prop + "\n"); | ||||
|  | @ -381,8 +387,7 @@ public class Main { | |||
|             currentThread  = new Thread(() -> { | ||||
|                 while(true){ | ||||
|                     try { | ||||
|                         currentProxyPub = getCurrentProxy(); | ||||
|                         trayIcon.setToolTip("Current proxy: " + currentProxyPub); | ||||
|                         updateIcon(); | ||||
|                         Thread.sleep(repeatTime); | ||||
|                     } catch (InterruptedException | IOException ex) { | ||||
|                         exeptionActions("Stop Listener", ex); | ||||
|  | @ -392,6 +397,12 @@ public class Main { | |||
|             currentThread.start(); | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     public static void updateIcon() throws IOException, InterruptedException { | ||||
|         currentProxyPub = getCurrentProxy(); | ||||
|         trayIcon.setToolTip("Current proxy: " + currentProxyPub); | ||||
|     } | ||||
| 
 | ||||
|     public static void closeThread(){ | ||||
|         if (currentThread != null){ | ||||
|             currentThread.stop(); | ||||
|  | @ -409,8 +420,7 @@ public class Main { | |||
|                         if (!currentProxyPub.equals(proxyStr)) setProxy(proxyStr); | ||||
|                         Image icon = Toolkit.getDefaultToolkit().getImage("res" + osSeparator + "icon on blue.png"); | ||||
|                         trayIcon.setImage(icon); | ||||
|                         currentProxyPub = getCurrentProxy(); | ||||
|                         trayIcon.setToolTip("Current proxy: " + currentProxyPub); | ||||
|                         updateIcon(); | ||||
|                         Thread.sleep(repeatTime); | ||||
|                     } catch (InterruptedException | IOException ex) { | ||||
|                         exeptionActions( "Set proxy: " + proxyStr, ex); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue