⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newsslproxydialog.java

📁 java实现的代理程序 socket 编程实现的http 和socket 代理程序
💻 JAVA
字号:
/* * Created on 01-mar-2004 *  * To change the template for this generated file go to Window - Preferences - * Java - Code Generation - Code and Comments */package javatunnel.gui;import javatunnel.Configuration;import javax.swing.*;import java.awt.*;import java.awt.event.*;/** * @author utopio *  * To change the template for this generated type comment go to Window - * Preferences - Java - Code Generation - Code and Comments */public class NewSSLProxyDialog extends NewConnectionDialog {	JDialog dialog;	JTextField sourcePort;	JTextField destinationPort;	JTextField destinationIP;	JTextField proxyPort;	JTextField proxyIP;	JCheckBox manageHosts;	public NewSSLProxyDialog(JFrame parent) {		dialog = new JDialog(parent, "Creating new redirect connection", true);		dialog.setSize(300, 240);		Container contentPane = dialog.getContentPane();		contentPane.setLayout(new GridLayout(7,2));			JPanel p1=new JPanel();		FlowLayout flow1=new FlowLayout();		flow1.setAlignment(FlowLayout.LEFT);		p1.setLayout(flow1);		p1.add(new JLabel("Source port"));		contentPane.add(p1);				sourcePort = new JTextField(6);		JPanel p2=new JPanel();		FlowLayout flow2=new FlowLayout();		flow2.setAlignment(FlowLayout.LEFT);		p2.setLayout(flow2);		p2.add(sourcePort);		contentPane.add(p2);			JPanel p3=new JPanel();		FlowLayout flow3=new FlowLayout();		flow3.setAlignment(FlowLayout.LEFT);		p3.setLayout(flow3);		p3.add(new JLabel("Destination port"));		contentPane.add(p3);						destinationPort = new JTextField(6);		JPanel p4=new JPanel();		FlowLayout flow4=new FlowLayout();		flow4.setAlignment(FlowLayout.LEFT);		p4.setLayout(flow4);		p4.add(destinationPort);		contentPane.add(p4);					JPanel p5=new JPanel();		FlowLayout flow5=new FlowLayout();		flow5.setAlignment(FlowLayout.LEFT);		p5.setLayout(flow5);		p5.add(new JLabel("Destination address"));		contentPane.add(p5);				destinationIP = new JTextField(16);		JPanel p6=new JPanel();		FlowLayout flow6=new FlowLayout();		flow6.setAlignment(FlowLayout.LEFT);		p6.setLayout(flow6);		p6.add(destinationIP);		contentPane.add(p6);				JPanel p7=new JPanel();		FlowLayout flow7=new FlowLayout();		flow7.setAlignment(FlowLayout.LEFT);		p7.setLayout(flow7);		p7.add(new JLabel("Proxy port"));		contentPane.add(p7);				proxyPort = new JTextField(6);		JPanel p8=new JPanel();		FlowLayout flow8=new FlowLayout();		flow8.setAlignment(FlowLayout.LEFT);		p8.setLayout(flow8);		p8.add(proxyPort);		contentPane.add(p8);				JPanel p9=new JPanel();		FlowLayout flow9=new FlowLayout();		flow9.setAlignment(FlowLayout.LEFT);		p9.setLayout(flow9);		p9.add(new JLabel("Proxy address"));		contentPane.add(p9);				proxyIP = new JTextField(16);		JPanel p10=new JPanel();		FlowLayout flow10=new FlowLayout();		flow10.setAlignment(FlowLayout.LEFT);		p10.setLayout(flow10);		p10.add(proxyIP);		contentPane.add(p10);				JPanel p11=new JPanel();		FlowLayout flow11=new FlowLayout();		flow11.setAlignment(FlowLayout.LEFT);		p11.setLayout(flow11);		manageHosts=new JCheckBox("Manage hosts file");		manageHosts.setSelected(false);		p11.add(manageHosts);		contentPane.add(p11);				contentPane.add(new JLabel());			JButton accept = new JButton("Accept");		accept.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent action) {				getConfiguration();					}		});		JPanel p12=new JPanel();		p12.add(accept);		contentPane.add(p12);		JButton cancel = new JButton("Cancel");		cancel.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent action) {				dialog.hide();							dialog.dispose();			}		});		JPanel p13=new JPanel();		p13.add(cancel);		contentPane.add(p13);				dialog.show();	}	private void getConfiguration() {		String sourcePortText = sourcePort.getText();		String destinationPortText = destinationPort.getText();		String destinationIPText = destinationIP.getText();		String proxyPortText = proxyPort.getText();		String proxyIPText = proxyIP.getText();		int sourcePortInt;		int destinationPortInt;		int proxyPortInt;		try {			sourcePortInt = Integer.parseInt(sourcePortText);		} catch (NumberFormatException nfe) {			JOptionPane.showMessageDialog(				dialog,				"Source port value must be a number",				"Format Error",				JOptionPane.WARNING_MESSAGE);			return;		}		try {			 destinationPortInt = Integer.parseInt(destinationPortText);		} catch (NumberFormatException nfe) {			JOptionPane.showMessageDialog(				dialog,				"Destiantion port value must be a number",				"Format Error",				JOptionPane.WARNING_MESSAGE);			return;		}	 if(destinationIPText.length()==0){	 	JOptionPane.showMessageDialog(	 			dialog,				"Destination address is mandatory",				"Format Error",				JOptionPane.WARNING_MESSAGE);	 	return;	 }	 try {	 	proxyPortInt = Integer.parseInt(proxyPortText);	 } catch (NumberFormatException nfe) {	 	JOptionPane.showMessageDialog(	 			dialog,				"Proxy port value must be a number",				"Format Error",				JOptionPane.WARNING_MESSAGE);	 	return;	 }	 if(proxyIPText.length()==0){	 	JOptionPane.showMessageDialog(	 			dialog,				"Proxy address is mandatory",				"Format Error",				JOptionPane.WARNING_MESSAGE);	 	return;	 }	 	 		configuration = new Configuration();		configuration.setMode(Configuration.MODE_SSL);		configuration.setLocalPort(sourcePortInt);		configuration.setDestinationPort(destinationPortInt);		configuration.setDestinationAddress(destinationIPText);		configuration.setProxyPort(proxyPortInt);		configuration.setProxyAddress(proxyIPText);		configuration.setManageHostsFile(manageHosts.isSelected());		create();		dialog.hide();					dialog.dispose();	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -