summaryrefslogtreecommitdiffstats
path: root/src/dabInputZmq.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-04-17 22:17:38 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-04-17 22:19:02 +0200
commit9829cd690856e987704996efb52be3c8e1b840cf (patch)
tree2cb8ffa4ff87256de66e30380b95d45dbd2e4284 /src/dabInputZmq.cpp
parent3f35a946ca00996b354a73831ef51aa269e8e623 (diff)
downloaddabmux-9829cd690856e987704996efb52be3c8e1b840cf.tar.gz
dabmux-9829cd690856e987704996efb52be3c8e1b840cf.tar.bz2
dabmux-9829cd690856e987704996efb52be3c8e1b840cf.zip
Add zmq encryption parameters to remotecontrol
Diffstat (limited to 'src/dabInputZmq.cpp')
-rw-r--r--src/dabInputZmq.cpp47
1 files changed, 46 insertions, 1 deletions
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();