]> nmode's Git Repositories - signal-cli/commitdiff
Update man page
authorAsamK <asamk@gmx.de>
Wed, 2 Nov 2022 16:46:20 +0000 (17:46 +0100)
committerAsamK <asamk@gmx.de>
Wed, 2 Nov 2022 16:46:20 +0000 (17:46 +0100)
man/signal-cli-dbus.5.adoc
man/signal-cli-jsonrpc.5.adoc
man/signal-cli.1.adoc
src/main/java/org/asamk/signal/commands/DaemonCommand.java
src/main/java/org/asamk/signal/http/HttpServerHandler.java

index bc3ad40de1ee1b6435d72242877bb6c716a79ead..1d78f7f645b38a1de9ac952881dd74c2611a1ec2 100644 (file)
@@ -5,6 +5,7 @@ vim:set ts=4 sw=4 tw=82 noet:
 :quotes.~:
 
 = signal-cli-dbus (5)
+:doctype: manpage
 
 == Name
 
index f0b62ca95b96a26ff55076e0e7155d80df5a7d2a..ff709f3146d71547b02cb2428ce97dc1fb7b4669 100644 (file)
@@ -5,6 +5,7 @@ vim:set ts=4 sw=4 tw=82 noet:
 :quotes.~:
 
 = signal-cli-jsonrpc (5)
+:doctype: manpage
 
 == Name
 
index d55d8ec7a3bdf17d86bf9d46d6eaba3e93e16415..ad510dfe994eaff53cc5b80917fb8adb7cb61a17 100644 (file)
@@ -5,6 +5,7 @@ vim:set ts=4 sw=4 tw=82 noet:
 :quotes.~:
 
 = signal-cli (1)
+:doctype: manpage
 
 == Name
 
@@ -601,7 +602,7 @@ The primary device will respond with synchronization messages with full contact
 
 === uploadStickerPack
 
-Upload a new sticker pack, consisting of a manifest file and the sticker images.
+Upload a new sticker pack, consisting of a manifest file and the sticker images. +
 Images must conform to the following specification: (see https://support.signal.org/hc/en-us/articles/360031836512-Stickers#sticker_reqs )
 
 - Static stickers in PNG or WebP format
@@ -657,20 +658,25 @@ signal-cli can run in daemon mode and provides an experimental dbus or JSON-RPC
 If no `-a` account is given, all local accounts will be exported as separate dbus objects under the same bus name.
 
 *--dbus*::
-Export DBus interface on user bus.
-See signal-cli-dbus (5) for info on the dbus interface.
+Export DBus interface on user bus. +
+See **signal-cli-dbus**(5) for info on the dbus interface.
 
 *--dbus-system*::
-Export DBus interface on system bus.
-See signal-cli-dbus (5) for info on the dbus interface.
+Export DBus interface on system bus. +
+See **signal-cli-dbus**(5) for info on the dbus interface.
 
 *--socket [SOCKET]*::
-Export a JSON-RPC interface on a UNIX socket (default $XDG_RUNTIME_DIR/signal-cli/socket).
-See signal-cli-jsonrpc (5) for info on the JSON-RPC interface.
+Export a JSON-RPC interface on a UNIX socket (default $XDG_RUNTIME_DIR/signal-cli/socket). +
+See **signal-cli-jsonrpc**(5) for info on the JSON-RPC interface.
 
 *--tcp [HOST:PORT]*::
-Export a JSON-RPC interface on a TCP socket (default localhost:7583).
-See signal-cli-jsonrpc (5) for info on the JSON-RPC interface.
+Export a JSON-RPC interface on a TCP socket (default localhost:7583). +
+See **signal-cli-jsonrpc**(5) for info on the JSON-RPC interface.
+
+*--http [HOST:PORT]*::
+Expose a JSON-RPC interface as http endpoint (default localhost:8080).
+The JSON-RPC endpoint is `/api/v1/rpc`. +
+See **signal-cli-jsonrpc**(5) for info on the JSON-RPC interface.
 
 *--ignore-attachments*::
 Don’t download attachments of received messages.
index bd6b9386779e15e06bec0557fd24e12f1c8d7374..0cdf9cc9ba4ed0eec2362534ebc9e76c599fc7f7 100644 (file)
@@ -73,7 +73,7 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
         subparser.addArgument("--http")
                 .nargs("?")
                 .setConst("localhost:8080")
-                .help("Expose a JSON-RPC interface as http endpoint.");
+                .help("Expose a JSON-RPC interface as http endpoint (default localhost:8080).");
         subparser.addArgument("--no-receive-stdout")
                 .help("Don’t print received messages to stdout.")
                 .action(Arguments.storeTrue());
index b2544b25c799ea6d488d84940bb31a0b7b6ef655..9fb33a34e327547d90480227c1a5049253fa2f59 100644 (file)
@@ -41,54 +41,56 @@ public class HttpServerHandler {
 
     public void init() throws IOException {
 
-            logger.info("Starting server on " + address.toString());
+        logger.info("Starting server on " + address.toString());
 
-            final var server = HttpServer.create(address, 0);
-            server.setExecutor(Executors.newFixedThreadPool(10));
+        final var server = HttpServer.create(address, 0);
+        server.setExecutor(Executors.newFixedThreadPool(10));
 
-            server.createContext("/api/v1/rpc", httpExchange -> {
+        server.createContext("/api/v1/rpc", httpExchange -> {
 
-                if (!"POST".equals(httpExchange.getRequestMethod())) {
-                    sendResponse(405, null, httpExchange);
-                    return;
-                }
-
-                if (!"application/json".equals(httpExchange.getRequestHeaders().getFirst("Content-Type"))) {
-                    sendResponse(415, null, httpExchange);
-                    return;
-                }
+            if (!"POST".equals(httpExchange.getRequestMethod())) {
+                sendResponse(405, null, httpExchange);
+                return;
+            }
 
-                try {
+            if (!"application/json".equals(httpExchange.getRequestHeaders().getFirst("Content-Type"))) {
+                sendResponse(415, null, httpExchange);
+                return;
+            }
 
-                    final Object[] result = {null};
-                    final var jsonRpcSender = new JsonRpcSender(s -> {
-                        if (result[0] != null) {
-                            throw new AssertionError("There should only be a single JSON-RPC response");
-                        }
+            try {
 
-                        result[0] = s;
-                    });
+                final Object[] result = {null};
+                final var jsonRpcSender = new JsonRpcSender(s -> {
+                    if (result[0] != null) {
+                        throw new AssertionError("There should only be a single JSON-RPC response");
+                    }
 
-                    final var jsonRpcReader = new JsonRpcReader(jsonRpcSender, httpExchange.getRequestBody());
-                    jsonRpcReader.readMessages((method, params) -> commandHandler.handleRequest(objectMapper, method, params),
-                            response -> logger.debug("Received unexpected response for id {}", response.getId()));
+                    result[0] = s;
+                });
 
-                    if (result[0] !=null) {
-                        sendResponse(200, result[0], httpExchange);
-                    } else {
-                        sendResponse(201, null, httpExchange);
-                    }
+                final var jsonRpcReader = new JsonRpcReader(jsonRpcSender, httpExchange.getRequestBody());
+                jsonRpcReader.readMessages((method, params) -> commandHandler.handleRequest(objectMapper,
+                        method,
+                        params), response -> logger.debug("Received unexpected response for id {}", response.getId()));
 
+                if (result[0] != null) {
+                    sendResponse(200, result[0], httpExchange);
+                } else {
+                    sendResponse(201, null, httpExchange);
                 }
-                catch (Throwable aEx) {
-                    logger.error("Failed to process request.", aEx);
-                    sendResponse(200, JsonRpcResponse.forError(
-                            new JsonRpcResponse.Error(JsonRpcResponse.Error.INTERNAL_ERROR,
-                            "An internal server error has occurred.", null), null), httpExchange);
-                }
-            });
 
-            server.start();
+            } catch (Throwable aEx) {
+                logger.error("Failed to process request.", aEx);
+                sendResponse(200,
+                        JsonRpcResponse.forError(new JsonRpcResponse.Error(JsonRpcResponse.Error.INTERNAL_ERROR,
+                                "An internal server error has occurred.",
+                                null), null),
+                        httpExchange);
+            }
+        });
+
+        server.start();
 
     }