mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 16:49:10 +00:00
Fixed a few small mistakes from last commit, added new proxy type "NONE"
This commit is contained in:
@@ -24,7 +24,7 @@ public class ProxySocket extends Socket {
|
|||||||
|
|
||||||
private static List<ProxySocket> connections = new ArrayList<ProxySocket>();
|
private static List<ProxySocket> connections = new ArrayList<ProxySocket>();
|
||||||
|
|
||||||
private static ProxyType proxyType = ProxyType.HTTP;
|
private static ProxyType proxyType = ProxyType.NONE;
|
||||||
|
|
||||||
private static int proxyPort = 0;
|
private static int proxyPort = 0;
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ public class ProxySocket extends Socket {
|
|||||||
this.addr = InetAddress.getByName(isa.getHostString());
|
this.addr = InetAddress.getByName(isa.getHostString());
|
||||||
this.port = isa.getPort();
|
this.port = isa.getPort();
|
||||||
}
|
}
|
||||||
if (proxyInetAddress != null && proxyPort > 0) {
|
if (proxyType != ProxyType.NONE) {
|
||||||
try {
|
try {
|
||||||
super.connect(cachedAddr = new InetSocketAddress(
|
super.connect(cachedAddr = new InetSocketAddress(
|
||||||
proxyInetAddress, proxyPort));
|
proxyInetAddress, proxyPort));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package org.parabot.core.network.proxy;
|
package org.parabot.core.network.proxy;
|
||||||
|
|
||||||
public enum ProxyType {
|
public enum ProxyType {
|
||||||
SOCKS5, SOCKS4, HTTP
|
NONE,SOCKS5, SOCKS4, HTTP
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ import javax.swing.JComboBox;
|
|||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JPasswordField;
|
import javax.swing.JPasswordField;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
@@ -66,6 +67,7 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
proxyHost.setText(ProxySocket.getProxyAddress().getHostName());
|
proxyHost.setText(ProxySocket.getProxyAddress().getHostName());
|
||||||
proxyPort.setText("" + ProxySocket.getProxyPort());
|
proxyPort.setText("" + ProxySocket.getProxyPort());
|
||||||
proxyType.setSelectedItem(ProxySocket.getProxyType());
|
proxyType.setSelectedItem(ProxySocket.getProxyType());
|
||||||
|
authCheckBox.setSelected(ProxySocket.auth);
|
||||||
setLocationRelativeTo(BotUI.getInstance());
|
setLocationRelativeTo(BotUI.getInstance());
|
||||||
super.setVisible(b);
|
super.setVisible(b);
|
||||||
}
|
}
|
||||||
@@ -224,12 +226,15 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
boolean b = false;
|
boolean b = false;
|
||||||
|
|
||||||
if (arg0.getSource() == proxyType) {
|
if (arg0.getSource() == proxyType) {
|
||||||
authCheckBox.setEnabled(proxyType.getSelectedItem() == ProxyType.SOCKS5);
|
Object o = proxyType.getSelectedItem();
|
||||||
|
authCheckBox.setEnabled(o == ProxyType.SOCKS5);
|
||||||
|
proxyHost.setEnabled(o != ProxyType.NONE);
|
||||||
|
proxyPort.setEnabled(o != ProxyType.NONE);
|
||||||
b = true;
|
b = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b || arg0.getSource() == authCheckBox) {
|
if (b || arg0.getSource() == authCheckBox) {
|
||||||
b = authCheckBox.isSelected() && authCheckBox.isEnabled();
|
b = authCheckBox.isSelected() && authCheckBox.isEnabled();
|
||||||
ProxySocket.auth = b;
|
ProxySocket.auth = b;
|
||||||
@@ -237,8 +242,18 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
authPassword.setEnabled(b);
|
authPassword.setEnabled(b);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxySocket.setLogin(authUsername.getText(), authPassword.getPassword());
|
if (proxyType.getSelectedItem() != ProxyType.NONE) {
|
||||||
|
if (proxyPort.getText().equals("")
|
||||||
|
|| proxyHost.getText().equals("")) {
|
||||||
|
UILog.log("Error", "Please supply proxy information!",
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProxySocket
|
||||||
|
.setLogin(authUsername.getText(), authPassword.getPassword());
|
||||||
|
|
||||||
byte[] mac = new byte[macList.length];
|
byte[] mac = new byte[macList.length];
|
||||||
for (int i = 0; i < mac.length; i++)
|
for (int i = 0; i < mac.length; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user