2 * Copyright (c) 2019-2020. Developed by Hedgecode.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.hedgecode.chess.scanner.proxy;
19 import org.hedgecode.chess.scanner.proxy.client.HttpRequestClient;
20 import org.hedgecode.chess.scanner.proxy.client.SocksRequestClient;
21 import org.hedgecode.chess.scanner.proxy.system.SystemProxy;
22 import org.hedgecode.chess.scanner.request.PlainRequestClient;
23 import org.hedgecode.chess.scanner.request.RequestClient;
26 * Proxy settings main class.
28 * @author Dmitry Samoshin aka gotty
30 public final class Proxy {
32 private static Proxy proxy;
34 private RequestClient requestClient;
37 requestClient = new PlainRequestClient();
40 public static void setProxy(ProxyParams proxyParams) {
41 getProxy().set(proxyParams);
44 public static RequestClient getRequestClient() {
45 return getProxy().client();
48 private void set(ProxyParams proxyParams) {
49 if (proxyParams.isSystem()) {
50 SystemProxy.setProxy(proxyParams);
51 requestClient = new PlainRequestClient();
53 switch (proxyParams.getType()) {
55 requestClient = new HttpRequestClient(proxyParams);
58 requestClient = new SocksRequestClient(proxyParams);
61 requestClient = new PlainRequestClient();
66 private RequestClient client() {
70 private static Proxy getProxy() {