Skip to content

Commit 486c4eb

Browse files
authored
Make server bind address configurable (#20)
1 parent 147c740 commit 486c4eb

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/main/java/me/lucko/luckperms/extension/rest/RestExtension.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ public RestExtension(LuckPerms luckPerms) {
4343
@Override
4444
public void load() {
4545
int port = RestConfig.getInteger("http.port", 8080);
46+
String address = RestConfig.getString("http.address", "localhost");
4647

4748
Thread thread = Thread.currentThread();
4849
ClassLoader previousCtxClassLoader = thread.getContextClassLoader();
4950
thread.setContextClassLoader(RestExtension.class.getClassLoader());
5051
try {
51-
this.server = new RestServer(this.luckPerms, port);
52+
this.server = new RestServer(this.luckPerms, address, port);
5253
} finally {
5354
thread.setContextClassLoader(previousCtxClassLoader);
5455
}

src/main/java/me/lucko/luckperms/extension/rest/RestServer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ public class RestServer implements AutoCloseable {
7272
private final Javalin app;
7373
private final AutoCloseable routesClosable;
7474

75-
public RestServer(LuckPerms luckPerms, int port) {
75+
public RestServer(LuckPerms luckPerms, String address, int port) {
7676
LOGGER.info("[REST] Starting server...");
7777

7878
this.objectMapper = new CustomObjectMapper();
7979

8080
this.app = Javalin.create(this::configure)
81-
.start(port);
81+
.start(address, port);
8282

8383
this.setupLogging(this.app);
8484
this.setupErrorHandlers(this.app);
8585
this.routesClosable = this.setupRoutes(this.app, luckPerms);
8686

87-
LOGGER.info("[REST] Startup complete! Listening on http://localhost:" + port);
87+
LOGGER.info(String.format("[REST] Startup complete! Listening on http://%s:%d", address, port));
8888
}
8989

9090
@Override

0 commit comments

Comments
 (0)