From 9829cd690856e987704996efb52be3c8e1b840cf Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Thu, 17 Apr 2014 22:17:38 +0200 Subject: Add zmq encryption parameters to remotecontrol --- README.md | 2 +- src/dabInputZmq.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++++- src/dabInputZmq.h | 13 +++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8a2deef..e3586c5 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ In addition to the features of CRC-DabMux, this fork contains: - timestamping support required for SFN - a ZeroMQ ETI output that can be used with ODR-DabMod - a ZeroMQ dabplus input that can be used with fdk-aac-dabplus - and toolame-dab + and toolame-dab, and support ZMQ-CURVE authentication - supports logging to syslog - supports ZMQ input monitoring with munin tool - includes a Telnet Remote Control for setting/getting parameters diff --git a/src/dabInputZmq.cpp b/src/dabInputZmq.cpp index ee38440..956481c 100644 --- a/src/dabInputZmq.cpp +++ b/src/dabInputZmq.cpp @@ -145,7 +145,7 @@ void DabInputZmqBase::rebind() KEY_VALID(m_curve_secret_key) && KEY_VALID(m_curve_encoder_key) ) ) ) { throw std::runtime_error("When enabling encryption, all three " - "keyfiles must be set!"); + "keyfiles must be valid!"); } if (m_config.enable_encryption) { @@ -495,6 +495,36 @@ void DabInputZmqBase::set_parameter(const string& parameter, throw ParameterError("Value not understood, specify 0 or 1."); } } + else if (parameter == "encryption") { + if (value == "1") { + m_config.enable_encryption = true; + } + else if (value == "0") { + m_config.enable_encryption = false; + } + else { + throw ParameterError("Value not understood, specify 0 or 1."); + } + + try { + rebind(); + } + catch (std::runtime_error &e) { + stringstream ss; + ss << "Could not bind socket again with new keys." << + e.what(); + throw ParameterError(ss.str()); + } + } + else if (parameter == "secretkey") { + m_config.curve_secret_keyfile = value; + } + else if (parameter == "publickey") { + m_config.curve_public_keyfile = value; + } + else if (parameter == "encoderkey") { + m_config.curve_encoder_keyfile = value; + } else { stringstream ss; ss << "Parameter '" << parameter << @@ -518,6 +548,21 @@ const string DabInputZmqBase::get_parameter(const string& parameter) const else ss << "false"; } + else if (parameter == "encryption") { + if (m_config.enable_encryption) + ss << "true"; + else + ss << "false"; + } + else if (parameter == "secretkey") { + ss << m_config.curve_secret_keyfile; + } + else if (parameter == "publickey") { + ss << m_config.curve_public_keyfile; + } + else if (parameter == "encoderkey") { + ss << m_config.curve_encoder_keyfile; + } else { ss << "Parameter '" << parameter << "' is not exported by controllable " << get_rc_name(); diff --git a/src/dabInputZmq.h b/src/dabInputZmq.h index 871676e..b74b1e8 100644 --- a/src/dabInputZmq.h +++ b/src/dabInputZmq.h @@ -142,6 +142,19 @@ class DabInputZmqBase : public DabInputBase, public RemoteControllable { RC_ADD_PARAMETER(enable, "If the input is enabled. Set to zero to empty the buffer."); + RC_ADD_PARAMETER(encryption, + "If encryption is enabled or disabled [1 or 0]." + " If 1 is written, the keys are reloaded."); + + RC_ADD_PARAMETER(publickey, + "The multiplexer's public key file."); + + RC_ADD_PARAMETER(secretkey, + "The multiplexer's secret key file."); + + RC_ADD_PARAMETER(encoderkey, + "The encoder's public key file."); + /* Set all keys to zero */ INVALIDATE_KEY(m_curve_public_key); INVALIDATE_KEY(m_curve_secret_key); -- cgit v1.2.3