Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.genuinevm.src;
- import java.net.InetAddress;
- import java.net.URL;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Comparator;
- import java.util.List;
- import java.util.SortedMap;
- import java.util.TreeMap;
- // Run this from home or any other computer with no dns restriction.
- // The output is suitable for a Host file, this overrides the dns lookup.
- // This will hopefully unblock the websites that are blocked by most content blockers.
- public class Main {
- public static Comparator<? super String> comparator = (k1, k2) -> {
- String[] str1 = k1.split("\\.");
- String[] str2 = k2.split("\\.");
- int[] is1 = new int[] {
- Integer.parseInt(str1[0], 10),
- Integer.parseInt(str1[1], 10),
- Integer.parseInt(str1[2], 10),
- Integer.parseInt(str1[3], 10)
- };
- int[] is2 = new int[] {
- Integer.parseInt(str2[0], 10),
- Integer.parseInt(str2[1], 10),
- Integer.parseInt(str2[2], 10),
- Integer.parseInt(str2[3], 10)
- };
- for (int i = 0; i < 4; i++) {
- int i1 = is1[i];
- int i2 = is2[i];
- if (i1 == i2)
- continue;
- if (i1 < i2)
- return -1;
- else
- return 1;
- }
- return 0;
- };
- public static List<String> urlList = new ArrayList<>();
- public static SortedMap<String, List<String>> map =
- Collections.synchronizedSortedMap(new TreeMap<String, List<String>>(comparator));
- // This example comes with most of the steam dns look-ups. You can
- public static void main(String[] args) {
- // Add your websites here. You can delete these examples if you want.
- urlList.add("steampowered.com");
- urlList.add("valvesoftware.com");
- urlList.add("store.steampowered.com");
- urlList.add("cdn.store.steampowered.com");
- urlList.add("media.steampowered.com");
- urlList.add("storefront.steampowered.com");
- urlList.add("cdn.steamcommunity.com");
- urlList.add("support.steampowered.com");
- urlList.add("translation.steampowered.com");
- urlList.add("store.valvesoftware.com");
- urlList.add("source.valvesoftware.com");
- urlList.add("steamcommunity.com");
- urlList.add("api.steampowered.com");
- urlList.add("cafe.steampowered.com");
- urlList.add("client-download.steampowered.com");
- for (int i = 0; i < 100; i++) {
- urlList.add("media" + i + ".steampowered.com");
- urlList.add("cdn" + i + ".store.steampowered.com");
- urlList.add("cdn" + i + ".steamcommunity.com");
- urlList.add("cloud-" + i + ".steampowered.com");
- urlList.add("content" + i + ".steampowered.com");
- }
- for (int i = 0; i < 500; i++) {
- urlList.add("valve" + Integer.toString(i, 10) + ".cs.steampowered.com");
- }
- // Do not edit below this line. Unless you really want to.
- urlList.stream().parallel().forEach(Main::getIP);
- map.forEach(Main::output);
- }
- public static void getIP(String s) {
- try {
- InetAddress address = InetAddress.getByName(new URL("http://" + s).getHost());
- String key = address.getHostAddress();
- synchronized (map) {
- map.putIfAbsent(key, new ArrayList<>());
- map.get(key).add(s);
- if (s.replaceAll("[^.]", "").length() <= 1)
- map.get(key).add("www." + s);
- }
- }
- catch (Exception e) {}
- }
- public static void output(String k, List<String> v) {
- Collections.sort(v, (s1, s2) -> s1.compareToIgnoreCase(s2));
- String line = "";
- for (int i = 0; i < v.size(); i++) {
- String tmp = v.get(i);
- line = line + buffer(tmp, " ", ((i * 36) - line.length() + tmp.length()), true);
- }
- System.out.println(buffer(k, " ", 18, false) + line);
- }
- public static String buffer(String input, String buffer, int max, boolean leading) {
- while (input.length() < max) {
- if (input.length() >= max)
- break;
- if (leading)
- input = buffer + input;
- else
- input = input + buffer;
- }
- return input;
- }
- }
Advertisement