Skip to content

Commit

Permalink
Create Main.java
Browse files Browse the repository at this point in the history
  • Loading branch information
chebuya authored Dec 12, 2024
1 parent cd05b5c commit e2be2fd
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions server/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.chebuya.minegriefserver;

import com.chebuya.minegriefserver.admin.AdminService;
import com.chebuya.minegriefserver.controller.ControllerService;
import com.chebuya.minegriefserver.transport.ServerTransport;
import com.chebuya.minegriefserver.transport.TCPSTransport;
import com.chebuya.minegriefserver.transport.TCPTransport;

import java.util.ArrayList;
import java.util.Arrays;

import static com.chebuya.minegriefserver.util.Logging.LOGGER;
import static com.chebuya.minegriefserver.util.Logging.configureLogging;

public class Main {
private static final boolean DO_LOGGING = true;

private static final String TRANSPORT_TYPE = "TCPS";
private static final String controllerBindAddr = "0.0.0.0";
private static final int controllerBindPort = 1337;
private static final String adminBindAddr = "127.0.0.1";
private static final int adminBindPort = 1338;

// See https://github.com/chebuya/minegrief/blob/main/top-asn.csv for choosing CIDRs to scan
private static final String[] cidrs = {"164.153.186.0/24", "46.105.199.0/24", "141.227.164.0/24", "209.71.36.0/24", "164.132.0.0/16", "149.202.0.0/16", "66.179.22.0/24", "217.177.35.0/24", "92.246.224.0/19", "185.45.160.0/22", "185.155.218.0/24", "139.99.0.0/17", "147.79.31.0/24", "91.246.38.0/24", "37.60.48.0/21", "8.29.224.0/24", "51.161.128.0/17", "8.33.128.0/21", "207.166.205.0/24", "8.30.208.0/21", "144.172.73.0/24", "91.224.117.0/24", "109.110.184.0/24", "185.228.207.0/24", "194.164.230.0/24", "45.9.120.0/24", "95.214.173.0/24", "198.27.92.0/24", "116.206.98.0/24", "172.83.201.0/24", "104.225.253.0/24", "82.153.205.0/24", "8.18.172.0/24", "199.48.178.0/24", "213.145.89.0/24", "213.218.238.0/24", "144.217.0.0/16", "209.151.124.0/24", "51.79.0.0/17", "217.180.19.0/24", "193.43.104.0/24", "62.72.191.0/24", "217.180.61.0/24", "51.81.128.0/17", "46.37.99.0/24", "216.183.120.0/24", "141.11.40.0/24", "185.33.26.0/24", "167.253.62.0/24", "86.110.56.0/24", "81.21.6.0/24", "46.105.198.0/24", "23.151.184.0/24", "163.5.149.0/24", "51.161.0.0/17", "46.28.236.0/24", "147.78.102.0/24", "141.227.140.0/24", "51.91.0.0/16", "43.226.0.0/23", "46.105.201.0/24", "85.208.10.0/24", "51.68.0.0/16", "195.66.31.0/24", "167.234.38.0/24", "37.230.60.0/24", "54.36.0.0/16", "185.223.80.0/24", "209.112.80.0/22", "46.105.206.0/24", "45.92.60.0/22", "185.162.176.0/24", "198.244.128.0/17", "54.39.0.0/16", "37.139.130.0/24", "91.199.163.0/24", "31.57.199.0/24", "31.24.253.0/24", "57.128.0.0/17", "192.70.246.0/23", "51.83.0.0/16", "77.81.138.0/24", "185.14.236.0/24", "217.182.0.0/16", "141.95.0.0/17", "2.57.242.0/24", "79.137.0.0/17", "135.148.0.0/17", "198.50.128.0/17", "45.95.83.0/24", "46.105.204.0/24", "66.179.218.0/23", "83.136.214.0/23", "108.165.220.0/24", "57.128.192.0/18", "137.74.0.0/16", "195.62.72.0/23", "185.75.178.0/24", "144.2.32.0/19", "45.112.195.0/24", "203.5.184.0/24", "206.168.174.0/23", "162.19.128.0/17", "45.149.243.0/24", "145.239.0.0/16", "123.100.227.0/24", "8.7.244.0/24", "79.110.61.0/24", "51.178.0.0/16", "176.31.0.0/16", "45.95.80.0/24", "8.24.8.0/21", "194.147.159.0/24", "142.44.128.0/17", "8.33.137.0/24", "163.5.144.0/24", "213.32.0.0/17", "192.99.65.0/24", "185.129.220.0/24", "188.68.164.0/22", "8.21.41.0/24", "148.113.0.0/18", "40.160.232.0/24", "163.5.62.0/24", "86.110.46.0/24", "158.69.0.0/16", "23.156.25.0/24", "167.114.192.0/19", "63.251.117.0/24", "198.27.64.0/18", "23.156.24.0/24", "141.227.138.0/24", "217.180.18.0/24", "40.160.224.0/24", "109.176.244.0/24", "207.166.206.0/24", "192.228.116.0/24", "185.157.51.0/24", "5.178.106.0/24", "213.251.128.0/18", "135.125.128.0/17", "15.235.128.0/17", "167.114.0.0/17", "103.5.12.0/22", "193.17.91.0/24", "37.202.194.0/24", "51.195.0.0/16", "37.35.76.0/24", "46.105.202.0/24", "103.102.231.0/24", "40.160.236.0/24", "88.209.211.0/24", "103.141.69.0/24", "192.124.170.0/24", "202.2.60.0/22", "40.160.0.0/17", "199.195.140.0/23", "188.164.156.0/24", "185.226.181.0/24", "198.100.144.0/20", "57.128.128.0/18", "217.180.17.0/24", "167.114.224.0/19", "107.189.64.0/18", "46.105.200.0/24", "139.99.128.0/17", "51.75.0.0/16", "66.70.128.0/17", "82.117.230.0/23", "69.72.31.0/24", "185.23.237.0/24", "8.33.96.0/21", "37.187.0.0/16", "142.44.140.0/24", "45.66.83.0/24", "15.204.128.0/17", "168.245.185.0/24", "191.96.153.0/24", "193.57.33.0/24", "23.92.224.0/19", "217.180.12.0/24", "194.59.183.0/24", "185.167.234.0/24", "40.160.234.0/24", "212.87.200.0/24", "95.128.156.0/24", "141.11.74.0/23", "141.227.130.0/24", "51.210.0.0/16", "178.215.227.0/24", "146.59.0.0/17", "151.80.0.0/16", "146.59.0.0/16", "157.254.30.0/24", "5.135.0.0/16", "15.204.0.0/17", "194.76.36.0/23", "185.135.188.0/24", "192.95.0.0/18", "148.135.154.0/24", "194.36.33.0/24", "46.8.201.0/24", "89.213.50.0/24", "88.218.34.0/24", "206.206.126.0/24", "185.5.39.0/24", "117.18.104.0/24", "8.26.94.0/24", "212.115.41.0/24", "82.152.98.0/24", "84.32.9.0/24", "93.114.69.0/24", "57.129.0.0/17", "46.105.207.0/24", "54.37.0.0/16", "194.169.48.0/24", "137.83.50.0/24", "87.98.128.0/17", "51.89.0.0/16", "114.129.44.0/24", "45.149.63.0/24", "141.227.134.0/24", "104.234.50.0/24", "80.71.226.0/24", "147.135.128.0/17", "141.95.128.0/17", "45.81.112.0/24", "185.12.32.0/23", "57.129.128.0/17", "141.227.142.0/24", "194.87.205.0/24", "146.103.49.0/24", "193.243.147.0/24", "195.206.242.0/24", "192.240.152.0/21", "46.105.203.0/24", "213.186.32.0/19", "192.31.246.0/24", "216.247.96.0/24", "46.105.0.0/16", "185.250.26.0/24", "40.160.226.0/24", "94.23.0.0/16", "194.76.173.0/24", "149.56.0.0/16", "135.148.128.0/17", "217.145.68.0/24", "83.143.16.0/21", "198.245.48.0/20", "148.222.40.0/22", "203.27.201.0/24", "62.122.126.0/24", "91.121.0.0/16", "91.199.32.0/24", "45.94.49.0/24", "199.249.223.0/24", "141.227.136.0/24", "64.225.244.0/23", "89.39.120.0/24", "184.174.97.0/24", "185.25.93.0/24", "193.70.0.0/17", "152.228.128.0/17", "217.11.174.0/24", "91.198.19.0/24", "51.77.0.0/16", "192.99.0.0/16", "31.56.52.0/22", "31.41.37.0/24", "37.60.56.0/21", "193.149.28.0/22", "184.174.96.0/24", "57.130.0.0/16", "213.218.234.0/24", "40.160.230.0/24", "141.227.128.0/24", "64.95.150.0/23", "5.144.182.0/24", "45.155.254.0/24", "185.216.126.0/24", "91.134.0.0/16", "46.8.200.0/24", "142.4.192.0/19", "8.33.136.0/24", "209.126.71.0/24", "40.160.228.0/24", "195.66.30.0/24", "8.18.128.0/24", "37.202.202.0/24", "163.5.173.0/24", "5.196.0.0/16", "185.255.28.0/24", "15.235.0.0/17", "46.244.32.0/20", "95.131.32.0/24", "178.32.0.0/15", "51.222.0.0/16", "64.94.92.0/23", "37.59.0.0/16", "147.135.0.0/17", "185.241.51.0/24", "198.49.103.0/24", "157.254.155.0/24", "86.38.156.0/24", "141.94.0.0/16", "91.90.88.0/21", "185.101.104.0/24", "199.193.138.0/24", "191.101.177.0/24", "194.36.32.0/24", "85.217.144.0/23", "167.114.128.0/18", "103.199.80.0/24", "135.125.0.0/17", "88.209.194.0/24", "5.144.181.0/24", "77.246.211.0/24", "212.81.45.0/24", "188.165.0.0/16", "54.38.0.0/16", "92.222.0.0/16", "162.19.0.0/17", "141.227.132.0/24", "31.6.62.0/24", "192.124.180.0/24", "104.167.16.0/24", "185.210.233.0/24", "51.254.0.0/15", "80.87.206.0/24", "185.127.28.0/24", "23.137.200.0/24", "198.101.27.0/24", "185.68.137.0/24", "8.20.110.0/24", "51.79.128.0/17", "5.83.153.0/24", "89.19.44.0/24", "192.152.126.0/24", "216.203.15.0/24", "72.251.0.0/17", "185.225.74.0/23", "5.39.0.0/17", "217.180.16.0/24", "51.38.0.0/16", "146.19.9.0/24", "148.113.128.0/17", "89.251.22.0/24", "180.131.145.0/24", "95.169.162.0/24", "40.160.238.0/24", "51.81.0.0/17"};

// Change these
private static final ArrayList<String> clientAuthTokens = new ArrayList<>(Arrays.asList("dpxpwDcLFkPZx9S6JYjb"));
private static final ArrayList<String> adminAuthTokens = new ArrayList<>(Arrays.asList("h4i5gdVuvxR5Y5oL5lxi"));

public static void main(String[] args) {
configureLogging(DO_LOGGING);

LOGGER.info("(main) configuring transport");
ServerTransport clientTransport = null;
switch (TRANSPORT_TYPE) {
case "TCPS":
try {
clientTransport = new TCPSTransport();
} catch(Exception e) {
LOGGER.warning("(main) error creating client transport: " + e.getMessage());
}
break;
default:
try {
clientTransport = new TCPTransport();
} catch(Exception e) {
LOGGER.warning("(main) error creating client transport: " + e.getMessage());
}
}

LOGGER.info("(client_controller) starting service");
ControllerService clientService = new ControllerService(clientTransport, controllerBindAddr, controllerBindPort, cidrs, clientAuthTokens);
clientService.Start();

ServerTransport adminTransport = null;
try {
adminTransport = new TCPTransport();
} catch(Exception e) {
LOGGER.warning("(main) error creating transport: " + e.getMessage());
}
LOGGER.info("(admin_controller) starting service");
AdminService adminService = new AdminService(adminTransport, adminBindAddr, adminBindPort, adminAuthTokens);
adminService.Start();
}
}

0 comments on commit e2be2fd

Please sign in to comment.