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.client;
19 import java.net.InetAddress;
20 import java.net.UnknownHostException;
21 import java.util.HashMap;
24 import org.apache.http.conn.DnsResolver;
29 * @author Dmitry Samoshin aka gotty
31 public class LocalDnsResolver implements DnsResolver {
33 private static final String LOCALHOST = "localhost";
34 private static final byte[] IP_ADDRESS = { 127, 0, 0, 1 };
36 private final Map<String, byte[]> resolvers = new HashMap<String, byte[]>() {
38 put( LOCALHOST, IP_ADDRESS );
43 public InetAddress[] resolve(String host) throws UnknownHostException {
44 return new InetAddress[] {
45 InetAddress.getByAddress(
46 LOCALHOST, resolvers.get(LOCALHOST)