| 24 | public class ProxyFactory { |
| 25 | |
| 26 | public static Proxy create(ListenPort listen_info) throws Exception { |
| 27 | Proxy proxy = null; |
| 28 | if (listen_info.getType() == ListenPort.TYPE.HTTP_PROXY) { |
| 29 | |
| 30 | ServerSocket listen_socket = new ServerSocket(listen_info.getPort()); |
| 31 | proxy = new ProxyHttp(listen_socket, listen_info); |
| 32 | |
| 33 | } else if (listen_info.getType() == ListenPort.TYPE.SSL_FORWARDER) { |
| 34 | |
| 35 | log("type is SSL_FORWARDER"); |
| 36 | ServerSocket listen_socket = new ServerSocket(listen_info.getPort()); |
| 37 | proxy = new ProxySSLForward(listen_socket, listen_info); |
| 38 | |
| 39 | } else if (listen_info.getType() == ListenPort.TYPE.HTTP_TRANSPARENT_PROXY) { |
| 40 | |
| 41 | log("type is HTTP_TRANSPARENT_PROXY"); |
| 42 | ServerSocket listen_socket = new ServerSocket(listen_info.getPort()); |
| 43 | proxy = new ProxyHttpTransparent(listen_socket, listen_info); |
| 44 | |
| 45 | } else if (listen_info.getType() == ListenPort.TYPE.SSL_TRANSPARENT_PROXY) { |
| 46 | |
| 47 | log("type is SSL_TRANSPARENT_PROXY"); |
| 48 | ServerSocket listen_socket = new ServerSocket(listen_info.getPort()); |
| 49 | proxy = new ProxySSLTransparent(listen_socket, listen_info); |
| 50 | |
| 51 | } else if (listen_info.getType() == ListenPort.TYPE.UDP_FORWARDER) { |
| 52 | |
| 53 | proxy = new ProxyUDPForward(listen_info); |
| 54 | |
| 55 | } else if (listen_info.getType() == ListenPort.TYPE.QUIC_FORWARDER) { |
| 56 | |
| 57 | proxy = new ProxyQuicForward(listen_info); |
| 58 | |
| 59 | } else if (listen_info.getType() == ListenPort.TYPE.QUIC_TRANSPARENT_PROXY) { |
| 60 | |
| 61 | proxy = new ProxyQuicTransparent(listen_info); |
| 62 | |
| 63 | } else if (listen_info.getType() == ListenPort.TYPE.XMPP_SSL_FORWARDER) { |
| 64 | |
| 65 | log("type is XMPP_SSL_FORWARDER"); |
| 66 | ServerSocket listen_socket = new ServerSocket(listen_info.getPort()); |
| 67 | listen_socket.setReuseAddress(true); |
| 68 | proxy = new ProxyXmppSSLForward(listen_socket, listen_info); |
| 69 | |
| 70 | } else { /* FORWARDER */ |
| 71 | |
| 72 | ServerSocket listen_socket = new ServerSocket(listen_info.getPort()); |
| 73 | listen_socket.setReuseAddress(true); |
| 74 | proxy = new ProxyForward(listen_socket, listen_info); |
| 75 | } |
| 76 | log(I18nString.get("Start listening port %d.", listen_info.getPort())); |
| 77 | return proxy; |
| 78 | } |
| 79 | } |