diff options
author | Scott Murray <scott.murray@konsulko.com> | 2024-02-21 10:22:25 -0500 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2024-02-21 15:28:20 +0000 |
commit | 8cccb6e90a4438d24b62c3e3fedf63ca8f68c31e (patch) | |
tree | 4ff54224cf4e5e5d41fdc00f93d80e9497f02e36 /src/main-grpc.cc | |
parent | 878498360f623dbe00b9f8a17374857db0659834 (diff) |
Allow specifying bind addressquillback_17.1.2quillback_17.1.1quillback_17.1.0quillback_17.0.2quillback_17.0.1quillback/17.1.2quillback/17.1.1quillback/17.1.0quillback/17.0.2quillback/17.0.117.1.217.1.117.1.017.0.217.0.1quillback
Add support for specifying the bind address via the optional
configuration file. This is required for the KVM demo usecase
where the service runs on the host and the homescreen in the
guest needs to connect to it.
Bug-AGL: SPEC-5082
Change-Id: I0af843f1ef55ef1d857730fbdec17163c6d88b4b
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
(cherry picked from commit 14068fefb5e5f43fc0bfd3d99aa30fa13faf2146)
Diffstat (limited to 'src/main-grpc.cc')
-rw-r--r-- | src/main-grpc.cc | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/main-grpc.cc b/src/main-grpc.cc index 29e01f1..9b29adb 100644 --- a/src/main-grpc.cc +++ b/src/main-grpc.cc @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 /* - * Copyright (C) 2023 Konsulko Group + * Copyright (C) 2023,2024 Konsulko Group */ #include <thread> @@ -40,8 +40,30 @@ int main(int argc, char *argv[]) grpc::reflection::InitProtoReflectionServerBuilderPlugin(); ServerBuilder builder; + // Load settings from configuration file if it exists + std::string bind_address = "localhost"; + GKeyFile *conf_file = g_key_file_new(); + if(conf_file && + g_key_file_load_from_dirs(conf_file, + "AGL.conf", + (const gchar**) g_get_system_config_dirs(), + NULL, + G_KEY_FILE_KEEP_COMMENTS, + NULL) == TRUE) { + + // Set band plan if it is specified + gchar *value_str = g_key_file_get_string(conf_file, + "radio", + "bind", + NULL); + if(value_str) { + bind_address = value_str; + } + } + g_key_file_free(conf_file); + // Listen on the given address without any authentication mechanism (for now) - std::string server_address("localhost:50053"); + std::string server_address(bind_address + ":50053"); builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); // Register "service" as the instance through which we'll communicate with |