Added public testing server registry ip.
This commit is contained in:
		
							parent
							
								
									532aacdd11
								
							
						
					
					
						commit
						b99047d696
					
				|  | @ -28,6 +28,8 @@ import java.util.concurrent.TimeUnit; | |||
| import java.util.function.Consumer; | ||||
| 
 | ||||
| public class PublicServerListModel extends AbstractListModel<PublicServerInfo> { | ||||
| 	public static final String REGISTRY_URL = "http://37.97.207.39:25566/serverInfo"; | ||||
| 
 | ||||
| 	private final List<PublicServerInfo> currentPageItems; | ||||
| 	private boolean firstPage; | ||||
| 	private boolean lastPage; | ||||
|  | @ -77,11 +79,10 @@ public class PublicServerListModel extends AbstractListModel<PublicServerInfo> { | |||
| 	} | ||||
| 
 | ||||
| 	public void fetchPage(int page, String query, String order, String orderDir) { | ||||
| 		System.out.println("Fetching..."); | ||||
| 		if (this.pageFetchFuture != null && !this.pageFetchFuture.isDone()) { | ||||
| 			this.pageFetchFuture.cancel(false); | ||||
| 		} | ||||
| 		String uri = "http://localhost:8567/serverInfo?page=" + page + "&size=" + this.pageSize; | ||||
| 		String uri = REGISTRY_URL + "?page=" + page + "&size=" + this.pageSize; | ||||
| 		if (query != null && !query.isBlank()) { | ||||
| 			uri += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8); | ||||
| 		} | ||||
|  | @ -91,6 +92,7 @@ public class PublicServerListModel extends AbstractListModel<PublicServerInfo> { | |||
| 		if (orderDir != null && !orderDir.isBlank()) { | ||||
| 			uri += "&dir=" + URLEncoder.encode(orderDir, StandardCharsets.UTF_8); | ||||
| 		} | ||||
| 		System.out.println("Fetching from " + uri); | ||||
| 		HttpRequest request; | ||||
| 		try { | ||||
| 			request = HttpRequest.newBuilder().GET().uri(new URI(uri)).header("Accept", "application/json").build(); | ||||
|  |  | |||
|  | @ -23,15 +23,7 @@ public class ServerRegistry { | |||
| 	public static final ObjectMapper mapper = new ObjectMapper(); | ||||
| 
 | ||||
| 	public static void main(String[] args) throws ServletException, IOException { | ||||
| 		Properties props = new Properties(); | ||||
| 		props.load(ServerRegistry.class.getResourceAsStream("/nl/andrewlalis/aos_server_registry/defaults.properties")); | ||||
| 		Path settingsPath = Path.of(SETTINGS_FILE); | ||||
| 		if (Files.exists(settingsPath)) { | ||||
| 			props.load(Files.newBufferedReader(settingsPath)); | ||||
| 		} else { | ||||
| 			System.out.println("Using built-in default settings. Create a settings.properties file to configure."); | ||||
| 		} | ||||
| 
 | ||||
| 		var props = loadProperties(); | ||||
| 		startServer(Integer.parseInt(props.getProperty("port"))); | ||||
| 
 | ||||
| 		// Every few minutes, prune all stale servers from the registry. | ||||
|  | @ -48,6 +40,7 @@ public class ServerRegistry { | |||
| 	 * @throws ServletException If the server could not be started. | ||||
| 	 */ | ||||
| 	private static void startServer(int port) throws ServletException { | ||||
| 		System.out.println("Starting server on port " + port + "."); | ||||
| 		DeploymentInfo servletBuilder = Servlets.deployment() | ||||
| 			.setClassLoader(ServerRegistry.class.getClassLoader()) | ||||
| 			.setContextPath("/") | ||||
|  | @ -60,9 +53,26 @@ public class ServerRegistry { | |||
| 		manager.deploy(); | ||||
| 		HttpHandler servletHandler = manager.start(); | ||||
| 		Undertow server = Undertow.builder() | ||||
| 			.addHttpListener(port, "localhost") | ||||
| 			.addHttpListener(port, "0.0.0.0") | ||||
| 			.setHandler(servletHandler) | ||||
| 			.build(); | ||||
| 		server.start(); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Loads properties from all necessary locations. | ||||
| 	 * @return The properties that were loaded. | ||||
| 	 * @throws IOException If an error occurs while reading properties. | ||||
| 	 */ | ||||
| 	private static Properties loadProperties() throws IOException { | ||||
| 		Properties props = new Properties(); | ||||
| 		props.load(ServerRegistry.class.getResourceAsStream("/nl/andrewlalis/aos_server_registry/defaults.properties")); | ||||
| 		Path settingsPath = Path.of(SETTINGS_FILE); | ||||
| 		if (Files.exists(settingsPath)) { | ||||
| 			props.load(Files.newBufferedReader(settingsPath)); | ||||
| 		} else { | ||||
| 			System.out.println("Using built-in default settings. Create a settings.properties file to configure."); | ||||
| 		} | ||||
| 		return props; | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| # Default properties for the AOS Server Registry | ||||
| 
 | ||||
| port=8567 | ||||
| port=25566 | ||||
| prune-delay=60 | ||||
| prune-threshold-minutes=5 | ||||
|  |  | |||
|  | @ -17,7 +17,7 @@ registry-settings: | |||
|   # Set this to true to allow other players to see this server and join it. | ||||
|   discoverable: false | ||||
|   # The URI which points to the registry server. This is only used if discoverable is true. | ||||
|   registry-uri: "http://localhost:8567" | ||||
|   registry-uri: "http://37.97.207.39:25566" | ||||
|   # How often to send status updates to the registry server, in seconds. | ||||
|   update-interval: 30 | ||||
|   # The name of this server. | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue