[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [nyx/master] Issue a RESETCONF when a blank value is entered



commit 55e71164b9b6b630d5fbda27079ced229a029887
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Jan 8 09:45:40 2019 -0800

    Issue a RESETCONF when a blank value is entered
    
    We lacked a mechanism for resetting values to their initial value. For
    instance, take the following scenario...
    
      * Our ExcludeNodes torrc is unset. The config panel shows it as '<none>'.
      * We change the value to 'stuff'.
      * We want to change it back to '<none>'.
    
    There wasn't a way of doing so. If we cleared the value and hit enter we'd
    change it to an empty string. I can't think of any scenarios where users would
    *want* to set things to blank strings (and in those edge cases they can always
    do so via the torrc).
    
    Now if a user deletes a config value and hits enter we'll reset it, in the
    above scenario changing the config option back to '<none>'.
---
 nyx/panel/config.py      | 10 ++++++++--
 web/changelog/index.html |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/nyx/panel/config.py b/nyx/panel/config.py
index e1eb19c..40d318c 100644
--- a/nyx/panel/config.py
+++ b/nyx/panel/config.py
@@ -240,7 +240,9 @@ class ConfigPanel(nyx.panel.Panel):
 
       if new_value is not None and new_value != initial_value:
         try:
-          if selected.value_type == 'Boolean':
+          if new_value == '':
+            new_value = None  # unset the value
+          elif selected.value_type == 'Boolean':
             # if the value's a boolean then allow for 'true' and 'false' inputs
 
             if new_value.lower() == 'true':
@@ -250,7 +252,11 @@ class ConfigPanel(nyx.panel.Panel):
           elif selected.value_type == 'LineList':
             new_value = new_value.split(',')  # set_conf accepts list inputs
 
-          tor_controller().set_conf(selected.name, new_value)
+          if new_value is None:
+            tor_controller().reset_conf(selected.name)
+          else:
+            tor_controller().set_conf(selected.name, new_value)
+
           self.redraw()
         except Exception as exc:
           show_message('%s (press any key)' % exc, HIGHLIGHT, max_wait = 30)
diff --git a/web/changelog/index.html b/web/changelog/index.html
index 241f788..0ba98c2 100644
--- a/web/changelog/index.html
+++ b/web/changelog/index.html
@@ -111,6 +111,7 @@
             <li>New tor configuration options crashed nyx when shown (<b><a href="https://trac.torproject.org/projects/tor/ticket/24401";>ticket</a></b>)</li>
             <li>Errors when saving the configuration could result in a stacktrace (<b><a href="https://trac.torproject.org/projects/tor/ticket/24409";>ticket</a></b>)</li>
             <li>Pressing 'esc' when editing values changed their value to 'none' (<b><a href="https://trac.torproject.org/projects/tor/ticket/28334";>ticket</a></b>)</li>
+            <li>Reset configuration option if set to an empty value</li>
           </ul>
         </li>
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits