mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Server: Add --websocket_ipv4_only switch
Socket listening default changed to IPv4 and IPv6, overridable to IPv4 only by using the command line switch.
This commit is contained in:
parent
9f68e0166b
commit
3a5f0d89b9
@ -18,7 +18,7 @@ Binaries for Windows, MacOS, and Linux are available in the [Releases](https://g
|
|||||||
|
|
||||||
It is **highly recommended** to protect obs-websocket with a password against unauthorized control. To do this, open the "Websocket server settings" dialog under OBS' "Tools" menu. In the settings dialogs, you can enable or disable authentication and set a password for it.
|
It is **highly recommended** to protect obs-websocket with a password against unauthorized control. To do this, open the "Websocket server settings" dialog under OBS' "Tools" menu. In the settings dialogs, you can enable or disable authentication and set a password for it.
|
||||||
|
|
||||||
(Psst. You can use `--websocket_port`(value), `--websocket_password`(value), and `--websocket_debug`(flag) on the command line to override the configured values.)
|
(Psst. You can use `--websocket_port`(value), `--websocket_password`(value), `--websocket_debug`(flag) and `--websocket_ipv4_only`(flag) on the command line to override the configured values.)
|
||||||
|
|
||||||
### Possible use cases
|
### Possible use cases
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
|||||||
#define PARAM_PASSWORD "ServerPassword"
|
#define PARAM_PASSWORD "ServerPassword"
|
||||||
|
|
||||||
#define CMDLINE_WEBSOCKET_PORT "websocket_port"
|
#define CMDLINE_WEBSOCKET_PORT "websocket_port"
|
||||||
|
#define CMDLINE_WEBSOCKET_IPV4_ONLY "websocket_ipv4_only"
|
||||||
#define CMDLINE_WEBSOCKET_PASSWORD "websocket_password"
|
#define CMDLINE_WEBSOCKET_PASSWORD "websocket_password"
|
||||||
#define CMDLINE_WEBSOCKET_DEBUG "websocket_debug"
|
#define CMDLINE_WEBSOCKET_DEBUG "websocket_debug"
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ Config::Config() :
|
|||||||
FirstLoad(true),
|
FirstLoad(true),
|
||||||
ServerEnabled(true),
|
ServerEnabled(true),
|
||||||
ServerPort(4455),
|
ServerPort(4455),
|
||||||
|
Ipv4Only(false),
|
||||||
DebugEnabled(false),
|
DebugEnabled(false),
|
||||||
AlertsEnabled(false),
|
AlertsEnabled(false),
|
||||||
AuthRequired(true),
|
AuthRequired(true),
|
||||||
@ -93,6 +95,12 @@ void Config::Load()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process `--websocket_ipv4_only` override
|
||||||
|
if (Utils::Platform::GetCommandLineFlagSet(CMDLINE_WEBSOCKET_IPV4_ONLY)) {
|
||||||
|
blog(LOG_INFO, "[Config::Load] --websocket_ipv4_only passed. Binding only to IPv4 interfaces.");
|
||||||
|
Ipv4Only = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Process `--websocket_password` override
|
// Process `--websocket_password` override
|
||||||
QString passwordArgument = Utils::Platform::GetCommandLineArgument(CMDLINE_WEBSOCKET_PASSWORD);
|
QString passwordArgument = Utils::Platform::GetCommandLineArgument(CMDLINE_WEBSOCKET_PASSWORD);
|
||||||
if (passwordArgument != "") {
|
if (passwordArgument != "") {
|
||||||
|
@ -38,6 +38,7 @@ struct Config {
|
|||||||
std::atomic<bool> FirstLoad;
|
std::atomic<bool> FirstLoad;
|
||||||
std::atomic<bool> ServerEnabled;
|
std::atomic<bool> ServerEnabled;
|
||||||
std::atomic<uint16_t> ServerPort;
|
std::atomic<uint16_t> ServerPort;
|
||||||
|
std::atomic<bool> Ipv4Only;
|
||||||
std::atomic<bool> DebugEnabled;
|
std::atomic<bool> DebugEnabled;
|
||||||
std::atomic<bool> AlertsEnabled;
|
std::atomic<bool> AlertsEnabled;
|
||||||
std::atomic<bool> AuthRequired;
|
std::atomic<bool> AuthRequired;
|
||||||
|
@ -129,7 +129,13 @@ void WebSocketServer::Start()
|
|||||||
_server.reset();
|
_server.reset();
|
||||||
|
|
||||||
websocketpp::lib::error_code errorCode;
|
websocketpp::lib::error_code errorCode;
|
||||||
_server.listen(websocketpp::lib::asio::ip::tcp::v4(), conf->ServerPort, errorCode);
|
if (conf->Ipv4Only) {
|
||||||
|
blog(LOG_INFO, "[WebSocketServer::Start] Locked to IPv4 bindings");
|
||||||
|
_server.listen(websocketpp::lib::asio::ip::tcp::v4(), conf->ServerPort, errorCode);
|
||||||
|
} else {
|
||||||
|
blog(LOG_INFO, "[WebSocketServer::Start] Not locked to IPv4 bindings");
|
||||||
|
_server.listen(conf->ServerPort, errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
if (errorCode) {
|
if (errorCode) {
|
||||||
std::string errorCodeMessage = errorCode.message();
|
std::string errorCodeMessage = errorCode.message();
|
||||||
|
Loading…
Reference in New Issue
Block a user