📄 connectionserver.java
字号:
/*This file is part of Socks via HTTP.This package is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.Socks via HTTP is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with Socks via HTTP; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/// Title : ConnectionServer.java// Version : 0.40// Copyright : Copyright (c) 2001// Author : Florent CUETO (fcueto@wanadoo.fr)// Description : Socks Server (Client part of socks via HTTP)package socks4;import java.net.*;import java.io.*;public class ConnectionServer extends Thread{ public static final int LISTEN_TIMEOUT = 2000; private static final String LOCALHOST_IP = "127.0.0.1"; private boolean m_onlyConnectFromLocalhost = true; private int m_port = -1; private ServerSocket m_serversocket = null; private String m_viaUrl = null; public boolean listening = true; private String m_proxyUser = null; private String m_proxyPassword = null; private String m_httpServerUser = null; private String m_httpServerPassword = null; public ConnectionServer(int port, String viaUrl, String proxyUser, String proxyPassword, boolean onlyConnectFromLocalhost, String httpServerUser, String httpServerPassword) { m_port = port; m_viaUrl = viaUrl; m_proxyUser = proxyUser; m_proxyPassword = proxyPassword; m_onlyConnectFromLocalhost = onlyConnectFromLocalhost; m_httpServerUser = httpServerUser; m_httpServerPassword = httpServerPassword; } public void run() { // Get the server version // TO DO // Let's start try { m_serversocket = new ServerSocket(m_port); m_serversocket.setSoTimeout(LISTEN_TIMEOUT); } catch (IOException e){} while(listening) { try { Socket s = m_serversocket.accept(); if ((!s.getInetAddress().getHostAddress().equals(LOCALHOST_IP)) && m_onlyConnectFromLocalhost) { // Log Log.printLog("Socks connection refused from IP " + s.getInetAddress().getHostAddress() + "..."); // Close the socket s.close(); } else { Log.printLog("Socks connection accepted from IP " + s.getInetAddress().getHostAddress() + "..."); Connection conn = new Connection(s); ThreadCommunication tc = new ThreadCommunication(conn, m_viaUrl, m_proxyUser, m_proxyPassword, m_httpServerUser, m_httpServerPassword); tc.start(); } } catch (Exception e){} } try { // Close the ServerSocket m_serversocket.close(); } catch (IOException e){} }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -