mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 04:20:38 +00:00
Pass full InetSocketAddress
This commit is contained in:
parent
60c40e7490
commit
0ce9ddb220
2 changed files with 10 additions and 9 deletions
|
@ -136,7 +136,7 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
final var httpAddress = ns.getString("http");
|
||||
if (httpAddress != null) {
|
||||
final var address = IOUtils.parseInetSocketAddress(httpAddress);
|
||||
final var handler = new HttpServerHandler(address.getPort(), m);
|
||||
final var handler = new HttpServerHandler(address, m);
|
||||
handler.init();
|
||||
}
|
||||
final var isDbusSystem = Boolean.TRUE.equals(ns.getBoolean("dbus-system"));
|
||||
|
@ -213,7 +213,7 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
final var httpAddress = ns.getString("http");
|
||||
if (httpAddress != null) {
|
||||
final var address = IOUtils.parseInetSocketAddress(httpAddress);
|
||||
final var handler = new HttpServerHandler(address.getPort(), c);
|
||||
final var handler = new HttpServerHandler(address, c);
|
||||
handler.init();
|
||||
}
|
||||
final var isDbusSystem = Boolean.TRUE.equals(ns.getBoolean("dbus-system"));
|
||||
|
|
|
@ -25,20 +25,20 @@ public class HttpServerHandler {
|
|||
|
||||
private final ObjectMapper objectMapper = Util.createJsonObjectMapper();
|
||||
|
||||
private final int port;
|
||||
private final InetSocketAddress address;
|
||||
|
||||
private final Manager m;
|
||||
|
||||
private final MultiAccountManager c;
|
||||
|
||||
public HttpServerHandler(final int port, final Manager m) {
|
||||
this.port = port;
|
||||
public HttpServerHandler(final InetSocketAddress address, final Manager m) {
|
||||
this.address = address;
|
||||
this.m = m;
|
||||
this.c = null;
|
||||
}
|
||||
|
||||
public HttpServerHandler(final int port, final MultiAccountManager c) {
|
||||
this.port = port;
|
||||
public HttpServerHandler(final InetSocketAddress address, final MultiAccountManager c) {
|
||||
this.address = address;
|
||||
this.m = null;
|
||||
this.c = c;
|
||||
}
|
||||
|
@ -47,15 +47,16 @@ public class HttpServerHandler {
|
|||
|
||||
try {
|
||||
|
||||
logger.info("Starting server on port " + port);
|
||||
logger.info("Starting server on port " + address.toString());
|
||||
|
||||
final var server = HttpServer.create(new InetSocketAddress(port), 0);
|
||||
final var server = HttpServer.create(new InetSocketAddress(address.getPort()), 0);
|
||||
server.setExecutor(Executors.newFixedThreadPool(10));
|
||||
|
||||
server.createContext("/api/v1/rpc", httpExchange -> {
|
||||
|
||||
if (!"POST".equals(httpExchange.getRequestMethod())) {
|
||||
sendResponse(405, null, httpExchange);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue