Add port and hostname config options
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -165,7 +165,7 @@ Kirigami.ApplicationWindow {
|
||||
text: i18n("Firewall may not allow port 9757")
|
||||
type: Kirigami.MessageType.Warning
|
||||
showCloseButton: true
|
||||
visible: DashboardSettings.show_system_checks && Firewall.needSetup
|
||||
visible: DashboardSettings.show_system_checks && Firewall.needSetup && Settings.port == Settings.default_port
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
text: i18n("Fix it")
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "escape_string.h"
|
||||
#include "gui_config.h"
|
||||
#include "utils/flatpak.h"
|
||||
#include "wivrn_config.h"
|
||||
#include "wivrn_server.h"
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
@@ -121,6 +122,8 @@ void Settings::emitAllChanged()
|
||||
debugGuiChanged();
|
||||
steamVrLhChanged();
|
||||
hidForwardingChanged();
|
||||
portChanged();
|
||||
hostnameChanged();
|
||||
}
|
||||
|
||||
void Settings::load(const wivrn_server * server)
|
||||
@@ -429,6 +432,40 @@ void Settings::set_tcpOnly(const bool & value)
|
||||
tcpOnlyChanged();
|
||||
}
|
||||
|
||||
int Settings::port() const
|
||||
{
|
||||
auto it = m_jsonSettings.find("port");
|
||||
if (it != m_jsonSettings.end() and it->is_number_integer())
|
||||
return *it;
|
||||
return wivrn::default_port;
|
||||
}
|
||||
|
||||
void Settings::set_port(const int & value)
|
||||
{
|
||||
auto old = port();
|
||||
m_jsonSettings["port"] = value;
|
||||
if (old != value)
|
||||
portChanged();
|
||||
}
|
||||
|
||||
QString Settings::hostname() const
|
||||
{
|
||||
if (auto it = m_jsonSettings.find("hostname"); it != m_jsonSettings.end() and it->is_string())
|
||||
return QString::fromStdString(*it);
|
||||
return "";
|
||||
}
|
||||
|
||||
void Settings::set_hostname(const QString & value)
|
||||
{
|
||||
auto old = hostname();
|
||||
if (value == "")
|
||||
m_jsonSettings.erase("hostname");
|
||||
else
|
||||
m_jsonSettings["hostname"] = value.toStdString();
|
||||
if (old != value)
|
||||
hostnameChanged();
|
||||
}
|
||||
|
||||
QString Settings::openvr() const
|
||||
{
|
||||
// OpenVR compat library
|
||||
@@ -504,6 +541,8 @@ void Settings::restore_defaults()
|
||||
m_jsonSettings.erase("use-steamvr-lh");
|
||||
m_jsonSettings.erase("tcp-only");
|
||||
m_jsonSettings.erase("application");
|
||||
m_jsonSettings.erase("port");
|
||||
m_jsonSettings.erase("hostname");
|
||||
emitAllChanged();
|
||||
}
|
||||
|
||||
@@ -512,6 +551,11 @@ bool Settings::flatpak() const
|
||||
return wivrn::is_flatpak();
|
||||
}
|
||||
|
||||
int Settings::default_port() const
|
||||
{
|
||||
return wivrn::default_port;
|
||||
}
|
||||
|
||||
bool Settings::debug_gui() const
|
||||
{
|
||||
#if WIVRN_FEATURE_DEBUG_GUI
|
||||
|
||||
@@ -68,6 +68,8 @@ public:
|
||||
Q_PROPERTY(bool tenbit READ tenbit WRITE set_tenbit NOTIFY tenbitChanged)
|
||||
|
||||
Q_PROPERTY(bool tcpOnly READ tcpOnly WRITE set_tcpOnly NOTIFY tcpOnlyChanged)
|
||||
Q_PROPERTY(int port READ port WRITE set_port NOTIFY portChanged)
|
||||
Q_PROPERTY(QString hostname READ hostname WRITE set_hostname NOTIFY hostnameChanged)
|
||||
Q_PROPERTY(QString application READ application WRITE set_application NOTIFY applicationChanged)
|
||||
Q_PROPERTY(QString openvr READ openvr WRITE set_openvr NOTIFY openvrChanged)
|
||||
|
||||
@@ -76,6 +78,7 @@ public:
|
||||
Q_PROPERTY(bool steamVrLh READ steamVrLh WRITE set_steamVrLh NOTIFY steamVrLhChanged)
|
||||
|
||||
Q_PROPERTY(bool flatpak READ flatpak CONSTANT)
|
||||
Q_PROPERTY(int default_port READ default_port CONSTANT)
|
||||
Q_PROPERTY(bool hid_forwarding_supported READ hid_forwarding CONSTANT)
|
||||
Q_PROPERTY(bool debug_gui_supported READ debug_gui CONSTANT)
|
||||
Q_PROPERTY(bool steamvr_lh_supported READ steamvr_lh CONSTANT)
|
||||
@@ -89,6 +92,8 @@ public:
|
||||
SETTER_GETTER_NOTIFY(bool, debugGui)
|
||||
SETTER_GETTER_NOTIFY(bool, steamVrLh)
|
||||
SETTER_GETTER_NOTIFY(bool, tcpOnly)
|
||||
SETTER_GETTER_NOTIFY(int, port)
|
||||
SETTER_GETTER_NOTIFY(QString, hostname)
|
||||
SETTER_GETTER_NOTIFY(QString, openvr)
|
||||
private:
|
||||
nlohmann::json m_jsonSettings = nlohmann::json::object();
|
||||
@@ -107,6 +112,7 @@ public:
|
||||
bool can10bit() const;
|
||||
|
||||
bool flatpak() const;
|
||||
int default_port() const;
|
||||
bool debug_gui() const;
|
||||
bool steamvr_lh() const;
|
||||
bool hid_forwarding() const;
|
||||
|
||||
@@ -158,3 +158,13 @@ Default value: `false`
|
||||
Only available when built with `WIVRN_FEATURE_STEAMVR_LIGHTHOUSE`
|
||||
|
||||
Enables the driver to load SteamVR Lighthouse devices.
|
||||
|
||||
## `port`
|
||||
Default value: `9757`
|
||||
|
||||
Change the TCP/UDP port used for the connection.
|
||||
|
||||
## `hostname`
|
||||
Default value: unset
|
||||
|
||||
If set, overrides the name displayed in the server list.
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#include "util/u_logging.h"
|
||||
#include "utils/overloaded.h"
|
||||
|
||||
#include "driver/configuration.h"
|
||||
#include "driver/wivrn_session.h"
|
||||
#include "wivrn_config.h"
|
||||
#include "wivrn_ipc.h"
|
||||
#include "wivrn_sockets.h"
|
||||
|
||||
@@ -33,7 +33,7 @@ std::unique_ptr<wivrn::TCP> wivrn::accept_connection(wivrn_session & cnx, std::s
|
||||
{
|
||||
wivrn_ipc_socket_monado->send(from_monado::headset_disconnected{});
|
||||
|
||||
wivrn::TCPListener listener(wivrn::default_port);
|
||||
wivrn::TCPListener listener(configuration().port);
|
||||
|
||||
pollfd fds[2]{
|
||||
{.fd = listener.get_fd(), .events = POLLIN},
|
||||
|
||||
@@ -204,6 +204,12 @@ configuration::configuration()
|
||||
if (auto it = json.find("tcp-only"); it != json.end())
|
||||
tcp_only = *it;
|
||||
|
||||
if (auto it = json.find("port"); it != json.end())
|
||||
port = *it;
|
||||
|
||||
if (auto it = json.find("hostname"); it != json.end())
|
||||
hostname = *it;
|
||||
|
||||
if (auto it = json.find("publish-service"); it != json.end())
|
||||
{
|
||||
publication = *it;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hostname.h"
|
||||
#include "wivrn_config.h"
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
@@ -57,6 +59,8 @@ struct configuration
|
||||
bool use_steamvr_lh = false;
|
||||
bool hid_forwarding = false;
|
||||
bool tcp_only = false;
|
||||
int port = wivrn::default_port;
|
||||
std::string hostname = wivrn::hostname();
|
||||
service_publication publication = service_publication::avahi;
|
||||
|
||||
// monostate: default value, string: user defined, nullptr: disabled
|
||||
|
||||
+3
-3
@@ -15,7 +15,6 @@
|
||||
#include "driver/configuration.h"
|
||||
#include "driver/wivrn_connection.h"
|
||||
#include "exit_codes.h"
|
||||
#include "hostname.h"
|
||||
#include "ipc_server_cb.h"
|
||||
#include "protocol_version.h"
|
||||
#include "start_application.h"
|
||||
@@ -315,7 +314,7 @@ void start_listening()
|
||||
|
||||
assert(listener_watch == 0);
|
||||
|
||||
listener = std::make_unique<TCPListener>(wivrn::default_port);
|
||||
listener = std::make_unique<TCPListener>(configuration().port);
|
||||
auto source_listener = g_unix_fd_source_new(listener->get_fd(), GIOCondition::G_IO_IN);
|
||||
g_source_set_callback(source_listener, G_SOURCE_FUNC(&headset_connected), nullptr, nullptr);
|
||||
listener_watch = g_source_attach(source_listener, nullptr);
|
||||
@@ -352,7 +351,8 @@ void start_publishing()
|
||||
{"version", wivrn::display_version()},
|
||||
{"cookie", server_cookie()},
|
||||
};
|
||||
publisher.emplace(poll_api, hostname(), "_wivrn._tcp", wivrn::default_port, TXT);
|
||||
auto configuration = wivrn::configuration();
|
||||
publisher.emplace(poll_api, configuration.hostname, "_wivrn._tcp", configuration.port, TXT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user