03-09-2014, 01:47 AM
Code:
package zamprox;
import java.io.BufferedOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Date;
class ProxyConnection extends Thread
{
Socket fromClient;
String host;
int port;
long timeout;
public static final int DEFAULT_TIMEOUT = 20000;
private int socketTimeout = 20000;
String FQ = "";
String MQ = "";
String BQ = "";
String CmT = "";
String PT = "";
public ProxyConnection(Socket s, String host, int port, long tout) {
this.fromClient = s;
this.host = host;
this.port = port;
this.timeout = tout;
}
public ProxyConnection(Socket s, String host, int port, long tout, String FQue, String MQue, String BQue, String CmTyp, String PTyp) {
this.fromClient = s;
this.host = host;
this.port = port;
this.timeout = tout;
this.FQ = FQue;
this.MQ = MQue;
this.BQ = BQue;
this.CmT = CmTyp;
this.PT = PTyp;
}
public void setTimeout(int timeout)
{
this.socketTimeout = (timeout * 1000);
}
public StringBuffer modifHeader(StringBuffer data)
{
int fq1 = -1;
int fq1s = -1;
int fq2 = -1;
int fq2s = -1;
int fq3 = -1;
int ptx = -1;
String fqs1 = "";
String fqs2 = "";
String fqs3 = "";
String ptxs = "";
StringBuffer hasil = new StringBuffer("");
String que1 = "";
String que2 = "";
StringBuffer gabung = new StringBuffer("");
StringBuffer hosts = new StringBuffer("");
if (data.toString().toLowerCase().indexOf("\r\n\r\n") >= 0) {
String[] arrHead = data.toString().split("\r\n");
for (int i = 0; i < arrHead.length; i++) {
fq1 = arrHead[i].toLowerCase().indexOf("get http://");
fq2 = arrHead[i].toLowerCase().indexOf("post http://");
fq3 = arrHead[i].toLowerCase().indexOf("connect ");
ptx = arrHead[i].toLowerCase().indexOf("host:");
if (fq1 >= 0) {
fqs1 = arrHead[i].substring(fq1 + 11).trim();
que1 = fqs1.substring(0, fqs1.toLowerCase().indexOf("/"));
que2 = fqs1.substring(fqs1.toLowerCase().indexOf("/"), fqs1.toLowerCase().indexOf(" http/1."));
arrHead[i] = arrHead[i].replace(que1, this.FQ + que1 + this.MQ);
arrHead[i] = arrHead[i].replace(que2, que2 + this.BQ);
} else if (fq2 >= 0) {
fqs2 = arrHead[i].substring(fq2 + 12).trim();
que1 = fqs2.substring(0, fqs2.toLowerCase().indexOf("/"));
que2 = fqs2.substring(fqs2.toLowerCase().indexOf("/"), fqs2.toLowerCase().indexOf(" http/"));
arrHead[i] = arrHead[i].replace(que1, this.FQ + que1 + this.MQ);
arrHead[i] = arrHead[i].replace(que2, que2 + this.BQ);
} else if (fq3 >= 0) {
fqs3 = arrHead[i].substring(fq3 + 8).trim();
arrHead[i] = arrHead[i].replace(fqs3, this.FQ + fqs3);
} else if (ptx >= 0) {
if (this.CmT.equalsIgnoreCase("host")) {
gabung.append("X-Online-Host: ").append(this.PT).append("\r\n");
} else if (this.CmT.equalsIgnoreCase("http")) {
hosts.setLength(0);
hosts.append(data.substring(ptx + 5).trim());
arrHead[i] = arrHead[i].replace(hosts.toString(), this.PT);
}
}
gabung.append(arrHead[i]);
gabung.append("\r\n");
}
gabung.append("\r\n");
hasil = gabung;
}
else
{
hasil = data;
}
return hasil;
}
public void run()
{
InputStream clientIn = null;
OutputStream clientOut = null;
InputStream serverIn = null;
OutputStream serverOut = null;
Socket toServer = null;
int r0 = -1; int r1 = -1; int ch = -1; int i = -1;
long time0 = new Date().getTime();
long time1 = new Date().getTime();
try {
toServer = new Socket(this.host, this.port);
zamprox.display("open connection to:" + toServer + "(timeout=" + this.timeout + " ms)");
clientIn = this.fromClient.getInputStream();
clientOut = new BufferedOutputStream(this.fromClient.getOutputStream());
serverIn = toServer.getInputStream();
serverOut = new BufferedOutputStream(toServer.getOutputStream());
while ((r0 != 0) || (r1 != 0) || (time1 - time0 <= this.timeout)) {
while ((r0 = clientIn.available()) > 0)
{
StringBuffer dat = new StringBuffer("");
for (i = 0; i < r0; i++) {
ch = clientIn.read();
if (ch != -1) {
dat.append((char)ch);
}
else
{
zamprox.display("client stream closed");
}
}
StringBuffer zamodif = modifHeader(dat);
serverOut.write(zamodif.toString().getBytes(), 0, zamodif.length());
time0 = new Date().getTime();
serverOut.flush();
}
while ((r1 = serverIn.available()) > 0)
{
for (i = 0; i < r1; i++) {
ch = serverIn.read();
if (ch != -1) {
clientOut.write(ch);
}
else {
zamprox.display("server stream closed");
}
}
time0 = new Date().getTime();
clientOut.flush();
}
if ((r0 == 0) && (r1 == 0)) {
time1 = new Date().getTime();
Thread.sleep(100L);
}
}
}
catch (Throwable t) {
zamprox.display("i=" + i + " ch=" + ch);
t.printStackTrace(System.err);
} finally {
try {
clientIn.close();
clientOut.close();
serverIn.close();
serverOut.close();
this.fromClient.close();
toServer.close();
zamprox.quit(time1 - time0);
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
}
}
[hr]
package zamprox;
import java.awt.Color;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Writer;
import java.util.Properties;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.LineBorder;
public class zFrame extends JFrame
{
private JComboBox CmbProxType;
private JLabel Hj8asjH8_;
private JButton bExit;
private JButton bStart;
private JLabel jLabel1;
private JLabel jLabel2;
private JLabel jLabel3;
private JLabel jLabel4;
private JLabel jLabel5;
private JLabel jLabel6;
private JPanel jPanel1;
private JPanel jPanel2;
private JPanel jPanel3;
private JPanel jPanel4;
private JButton jbLoad;
private JButton jbSave;
private JTextField txtBQ;
private JTextField txtFQ;
private JTextField txtListen;
private JTextField txtMQ;
private JTextField txtPort;
private JTextField txtProxType;
private JTextField txtProxy;
public zFrame()
{
initComponents();
}
private void initComponents()
{
this.jPanel4 = new JPanel();
this.jPanel2 = new JPanel();
this.txtProxy = new JTextField();
this.txtPort = new JTextField();
this.jLabel1 = new JLabel();
this.jLabel2 = new JLabel();
this.jbSave = new JButton();
this.jbLoad = new JButton();
this.jPanel1 = new JPanel();
this.txtListen = new JTextField();
this.txtFQ = new JTextField();
this.txtMQ = new JTextField();
this.txtBQ = new JTextField();
this.jLabel3 = new JLabel();
this.jLabel4 = new JLabel();
this.jLabel5 = new JLabel();
this.jLabel6 = new JLabel();
this.jPanel3 = new JPanel();
this.CmbProxType = new JComboBox();
this.txtProxType = new JTextField();
this.Hj8asjH8_ = new JLabel();
this.bExit = new JButton();
this.bStart = new JButton();
setDefaultCloseOperation(3);
setTitle("zamProx");
setBackground(new Color(0, 0, 0));
setBounds(new Rectangle(50, 50, 0, 0));
setCursor(new Cursor(0));
setFont(new Font("Courier New", 1, 12));
setForeground(Color.blue);
setResizable(false);
addWindowListener(new WindowAdapter() {
public void windowOpened(WindowEvent evt) {
zFrame.this.formWindowOpened(evt);
}
});
this.jPanel4.setBackground(new Color(0, 0, 0));
this.jPanel4.setBorder(new LineBorder(new Color(255, 51, 51), 1, true));
this.jPanel4.setForeground(new Color(51, 255, 51));
this.jPanel2.setBackground(new Color(0, 0, 0));
this.jPanel2.setBorder(BorderFactory.createTitledBorder(null, "Proxy", 0, 0, new Font("Courier New", 1, 12), new Color(102, 255, 51)));
this.txtProxy.setBackground(new Color(0, 0, 0));
this.txtProxy.setFont(new Font("Courier New", 1, 12));
this.txtProxy.setForeground(new Color(255, 51, 51));
this.txtPort.setBackground(new Color(0, 0, 0));
this.txtPort.setFont(new Font("Courier New", 1, 12));
this.txtPort.setForeground(new Color(255, 51, 51));
this.jLabel1.setBackground(new Color(0, 0, 0));
this.jLabel1.setForeground(new Color(255, 51, 51));
this.jLabel1.setText("Proxy Server");
this.jLabel2.setBackground(new Color(0, 0, 0));
this.jLabel2.setFont(new Font("Courier New", 1, 12));
this.jLabel2.setForeground(new Color(255, 51, 51));
this.jLabel2.setText("Port");
this.jbSave.setBackground(new Color(255, 255, 51));
this.jbSave.setFont(new Font("Courier New", 1, 12));
this.jbSave.setForeground(new Color(255, 51, 51));
this.jbSave.setText("Save");
this.jbSave.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
zFrame.this.jbSaveActionPerformed(evt);
}
});
this.jbLoad.setBackground(new Color(255, 255, 51));
this.jbLoad.setFont(new Font("Courier New", 1, 12));
this.jbLoad.setForeground(new Color(255, 51, 51));
this.jbLoad.setText("Load");
this.jbLoad.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
zFrame.this.jbLoadActionPerformed(evt);
}
});
GroupLayout jPanel2Layout = new GroupLayout(this.jPanel2);
this.jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(this.jLabel2).addComponent(this.jLabel1)).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.txtProxy, -1, 197, 32767).addGroup(jPanel2Layout.createSequentialGroup().addComponent(this.txtPort, -2, 61, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jbLoad).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, -1, 32767).addComponent(this.jbSave))).addContainerGap()));
jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel1).addComponent(this.txtProxy, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.txtPort, -1, 19, 32767).addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel2).addComponent(this.jbSave, -2, 23, 32767).addComponent(this.jbLoad))).addContainerGap()));
this.jPanel1.setBackground(new Color(0, 0, 0));
this.jPanel1.setBorder(BorderFactory.createTitledBorder(null, "Query Editor", 0, 0, new Font("Courier New", 1, 12), new Color(51, 255, 51)));
this.jPanel1.setForeground(new Color(51, 255, 51));
this.jPanel1.setFont(new Font("Courier New", 1, 12));
this.txtListen.setBackground(new Color(0, 0, 0));
this.txtListen.setFont(new Font("Courier New", 1, 12));
this.txtListen.setForeground(new Color(255, 51, 51));
this.txtListen.setText("8080");
this.txtFQ.setBackground(new Color(0, 0, 0));
this.txtFQ.setFont(new Font("Courier New", 1, 12));
this.txtFQ.setForeground(new Color(255, 51, 51));
this.txtMQ.setBackground(new Color(0, 0, 0));
this.txtMQ.setFont(new Font("Courier New", 1, 12));
this.txtMQ.setForeground(new Color(255, 51, 51));
this.txtBQ.setBackground(new Color(0, 0, 0));
this.txtBQ.setFont(new Font("Courier New", 1, 12));
this.txtBQ.setForeground(new Color(255, 51, 51));
this.jLabel3.setFont(new Font("Courier New", 1, 12));
this.jLabel3.setForeground(new Color(255, 51, 51));
this.jLabel3.setText("Listen Port");
this.jLabel4.setFont(new Font("Courier New", 1, 12));
this.jLabel4.setForeground(new Color(255, 51, 51));
this.jLabel4.setText("Front Query");
this.jLabel5.setFont(new Font("Courier New", 1, 12));
this.jLabel5.setForeground(new Color(255, 51, 51));
this.jLabel5.setText("Middle Query");
this.jLabel6.setFont(new Font("Courier New", 1, 12));
this.jLabel6.setForeground(new Color(255, 51, 51));
this.jLabel6.setText("Back Query");
this.jPanel3.setBackground(new Color(0, 0, 0));
this.jPanel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Proxy Type"), "Proxy Type", 0, 0, new Font("Courier New", 1, 12), new Color(102, 255, 51)));
this.jPanel3.setForeground(new Color(0, 255, 0));
this.CmbProxType.setBackground(new Color(153, 153, 0));
this.CmbProxType.setFont(new Font("Courier New", 1, 12));
this.CmbProxType.setForeground(new Color(255, 51, 51));
this.CmbProxType.setModel(new DefaultComboBoxModel(new String[] { "None", "Host", "Http" }));
this.CmbProxType.setAlignmentX(2.0F);
this.CmbProxType.setAlignmentY(2.0F);
this.CmbProxType.setCursor(new Cursor(0));
this.txtProxType.setBackground(new Color(0, 0, 0));
this.txtProxType.setFont(new Font("Courier New", 1, 12));
this.txtProxType.setForeground(new Color(255, 51, 51));
GroupLayout jPanel3Layout = new GroupLayout(this.jPanel3);
this.jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup().addComponent(this.CmbProxType, 0, 97, 32767).addGap(18, 18, 18).addComponent(this.txtProxType, -2, 157, -2).addContainerGap()));
jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel3Layout.createSequentialGroup().addGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.CmbProxType, -2, -1, -2).addComponent(this.txtProxType, -2, -1, -2)).addContainerGap()));
this.Hj8asjH8_.setFont(new Font("Courier New", 1, 12));
this.Hj8asjH8_.setForeground(new Color(255, 255, 51));
this.Hj8asjH8_.setText("[email protected]");
GroupLayout jPanel1Layout = new GroupLayout(this.jPanel1);
this.jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(this.jPanel3, GroupLayout.Alignment.LEADING, -1, -1, 32767).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(this.jLabel4).addComponent(this.jLabel3).addComponent(this.jLabel5).addComponent(this.jLabel6)).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.txtBQ, -1, 188, 32767).addComponent(this.txtMQ, -1, 188, 32767).addComponent(this.txtFQ, -1, 188, 32767).addGroup(jPanel1Layout.createSequentialGroup().addComponent(this.txtListen, -2, 60, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 23, 32767).addComponent(this.Hj8asjH8_))))).addContainerGap()));
jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.txtListen, -2, -1, -2).addComponent(this.jLabel3).addComponent(this.Hj8asjH8_)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.txtFQ, -2, -1, -2).addComponent(this.jLabel4)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.txtMQ, -2, -1, -2).addComponent(this.jLabel5)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.txtBQ, -2, -1, -2).addComponent(this.jLabel6)).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.jPanel3, -2, -1, -2).addContainerGap()));
this.bExit.setBackground(new Color(255, 255, 102));
this.bExit.setFont(new Font("Courier New", 1, 12));
this.bExit.setForeground(new Color(255, 51, 102));
this.bExit.setText("Exit");
this.bExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
zFrame.this.bExitActionPerformed(evt);
}
});
this.bStart.setBackground(new Color(255, 255, 102));
this.bStart.setFont(new Font("Courier New", 1, 12));
this.bStart.setForeground(new Color(255, 51, 102));
this.bStart.setText("Start");
this.bStart.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
zFrame.this.bStartActionPerformed(evt);
}
});
GroupLayout jPanel4Layout = new GroupLayout(this.jPanel4);
this.jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addGroup(jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.jPanel2, GroupLayout.Alignment.TRAILING, -1, -1, 32767).addGroup(jPanel4Layout.createSequentialGroup().addComponent(this.bStart, -2, 158, -2).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.bExit, -1, 155, 32767)).addComponent(this.jPanel1, GroupLayout.Alignment.TRAILING, -2, -1, -2)).addContainerGap()));
jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup().addContainerGap().addComponent(this.jPanel1, -2, -1, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jPanel2, -2, -1, -2).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addGroup(jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel4Layout.createSequentialGroup().addComponent(this.bStart, -1, -1, 32767).addGap(24, 24, 24)).addGroup(jPanel4Layout.createSequentialGroup().addComponent(this.bExit).addContainerGap()))));
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.jPanel4, -1, -1, 32767));
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.jPanel4, -1, -1, 32767));
pack();
}
private void bExitActionPerformed(ActionEvent evt)
{
System.exit(0);
}
private void bStartActionPerformed(ActionEvent evt)
{
jalankan();
pateni();
}
private void formWindowOpened(WindowEvent evt)
{
setFormData();
}
private void jbSaveActionPerformed(ActionEvent evt)
{
saveOn();
}
private void jbLoadActionPerformed(ActionEvent evt)
{
setFormData();
}
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
new zFrame().setVisible(true);
}
});
}
public void setFormData() {
Properties setkan = new Properties();
File save = new File("zamprox.cfg");
try {
if (save.exists()) {
setkan.load(new FileInputStream("zamprox.cfg"));
this.txtListen.setText(setkan.getProperty("Listen"));
this.txtProxy.setText(setkan.getProperty("Proxy"));
this.txtPort.setText(setkan.getProperty("Port"));
this.txtFQ.setText(setkan.getProperty("FQ"));
this.txtMQ.setText(setkan.getProperty("MQ"));
this.txtBQ.setText(setkan.getProperty("BQ"));
this.txtProxType.setText(setkan.getProperty("ProxType"));
this.CmbProxType.setSelectedItem(setkan.getProperty("CmbProxType"));
}
}
catch (IOException e) {
}
}
public void saveOn() {
Writer out = null;
File save = new File("zamprox.cfg");
try {
if (save.exists()) {
save.delete();
}
out = new BufferedWriter(new FileWriter(save));
out.write("Listen = " + this.txtListen.getText() + "\n");
out.write("Proxy = " + this.txtProxy.getText() + "\n");
out.write("Port = " + this.txtPort.getText() + "\n");
out.write("FQ = " + this.txtFQ.getText() + "\n");
out.write("MQ = " + this.txtMQ.getText() + "\n");
out.write("BQ = " + this.txtBQ.getText() + "\n");
out.write("ProxType = " + this.txtProxType.getText() + "\n");
out.write("CmbProxType = " + this.CmbProxType.getSelectedItem().toString() + "\n");
out.write(">>>Woyow Man<<<<");
out.close();
}
catch (Exception e)
{
}
}
public void pateni()
{
this.txtListen.setEnabled(false);
this.txtProxy.setEnabled(false);
this.txtPort.setEnabled(false);
this.txtFQ.setEnabled(false);
this.txtMQ.setEnabled(false);
this.txtBQ.setEnabled(false);
this.txtProxType.setEnabled(false);
this.CmbProxType.setEnabled(false);
this.bStart.setEnabled(false);
}
public void jalankan()
{
variabel var = new variabel();
int port = 0;
String fwdProxyServer = "";
int fwdProxyPort = 0;
zamprox Galz = new zamprox();
if (!var.Galzer.equals("[email protected]")) {
System.exit(0);
}
if (!var.Listen.equalsIgnoreCase("")) {
port = Integer.parseInt(var.Listen);
}
if ((!var.Proxy.equalsIgnoreCase("")) && (!var.Port.equalsIgnoreCase(""))) {
fwdProxyServer = var.Proxy;
fwdProxyPort = Integer.parseInt(var.Port);
}
Galz = new zamprox(port, fwdProxyServer, fwdProxyPort, 0, var.FQ, var.MQ, var.BQ, var.CMBType, var.PType);
System.err.println(" ** Starting zamprox on port " + port + ". Press CTRL-C to end. **\n");
Galz.start();
}
public class variabel
{
public String Galzer = zFrame.this.Hj8asjH8_.getText();
public String Listen = zFrame.this.txtListen.getText();
public String Proxy = zFrame.this.txtProxy.getText();
public String Port = zFrame.this.txtPort.getText();
public String FQ = zFrame.this.txtFQ.getText();
public String MQ = zFrame.this.txtMQ.getText();
public String BQ = zFrame.this.txtBQ.getText();
public String PType = zFrame.this.txtProxType.getText();
public String CMBType = zFrame.this.CmbProxType.getSelectedItem().toString();
public variabel()
{
}
}
}
[hr]
package zamprox;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
public class zamprox extends Thread
{
public volatile boolean stop = false;
public static final int DEFAULT_PORT = 8080;
private ServerSocket server = null;
private int thisPort = 8080;
private String fwdServer = "";
private int fwdPort = 0;
private int ptTimeout = 20000;
private int debugLevel = 0;
private PrintStream debugOut = System.out;
static int clientCount;
String FQ = "";
String MQ = "";
String BQ = "";
String CmT = "";
String PT = "";
public zamprox()
{
}
public zamprox(int port)
{
this.thisPort = port;
}
public zamprox(int port, String proxyServer, int proxyPort) {
this.thisPort = port;
this.fwdServer = proxyServer;
this.fwdPort = proxyPort;
}
public zamprox(int port, String proxyServer, int proxyPort, int timeout) {
this.thisPort = port;
this.fwdServer = proxyServer;
this.fwdPort = proxyPort;
this.ptTimeout = timeout;
}
public zamprox(int port, String proxyServer, int proxyPort, int timeout, String FQue, String MQue, String BQue, String CmTyp, String PTyp)
{
this.thisPort = port;
this.fwdServer = proxyServer;
this.fwdPort = proxyPort;
this.ptTimeout = timeout;
this.FQ = FQue;
this.MQ = MQue;
this.BQ = BQue;
this.CmT = CmTyp;
this.PT = PTyp;
}
public static synchronized void print(int i) {
System.out.print((char)i);
}
public static synchronized void println(String s) {
System.out.println(s);
}
public static synchronized void display(String s) {
System.err.println(s);
}
public static synchronized void quit(long t) {
display("...quit after waiting " + t + " ms");
clientCount -= 1;
}
public void setDebug(int level, PrintStream out)
{
this.debugLevel = level;
this.debugOut = out;
}
public int getPort()
{
return this.thisPort;
}
public boolean isRunning()
{
if (this.server == null) {
return false;
}
return true;
}
public void closeSocket()
{
try
{
this.server.close();
}
catch (Exception e)
{
if (this.debugLevel > 0) {
this.debugOut.println(e);
}
}
this.server = null;
}
public void requestStop() {
this.stop = true;
}
public void run()
{
try
{
this.server = new ServerSocket(this.thisPort);
if (this.debugLevel > 0) {
this.debugOut.println("Started zamprox on port " + this.thisPort);
}
while (!this.stop) {
Socket client = this.server.accept();
ProxyConnection t = new ProxyConnection(client, this.fwdServer, this.fwdPort, 65000L, this.FQ, this.MQ, this.BQ, this.CmT, this.PT);
t.start();
}
} catch (Exception e) {
if (this.debugLevel > 0) {
this.debugOut.println("zamprox Thread error: " + e);
}
}
closeSocket();
}
}
tinggal di uwik2 aje bro
monggo