V2: print also a nice string if direction is not set
V3: really include V2 changes
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1517392380-21597-1-git-send-email-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16415.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
... | ... |
@@ -1545,11 +1545,18 @@ ascii2keydirection(int msglevel, const char *str) |
1545 | 1545 |
} |
1546 | 1546 |
|
1547 | 1547 |
const char * |
1548 |
-keydirection2ascii(int kd, bool remote) |
|
1548 |
+keydirection2ascii(int kd, bool remote, bool humanreadable) |
|
1549 | 1549 |
{ |
1550 | 1550 |
if (kd == KEY_DIRECTION_BIDIRECTIONAL) |
1551 | 1551 |
{ |
1552 |
- return NULL; |
|
1552 |
+ if (humanreadable) |
|
1553 |
+ { |
|
1554 |
+ return "not set"; |
|
1555 |
+ } |
|
1556 |
+ else |
|
1557 |
+ { |
|
1558 |
+ return NULL; |
|
1559 |
+ } |
|
1553 | 1560 |
} |
1554 | 1561 |
else if (kd == KEY_DIRECTION_NORMAL) |
1555 | 1562 |
{ |
... | ... |
@@ -470,7 +470,7 @@ void must_have_n_keys(const char *filename, const char *option, const struct key |
470 | 470 |
|
471 | 471 |
int ascii2keydirection(int msglevel, const char *str); |
472 | 472 |
|
473 |
-const char *keydirection2ascii(int kd, bool remote); |
|
473 |
+const char *keydirection2ascii(int kd, bool remote, bool humanreadable); |
|
474 | 474 |
|
475 | 475 |
/* print keys */ |
476 | 476 |
void key2_print(const struct key2 *k, |
... | ... |
@@ -1704,7 +1704,7 @@ show_settings(const struct options *o) |
1704 | 1704 |
#endif |
1705 | 1705 |
|
1706 | 1706 |
SHOW_STR(shared_secret_file); |
1707 |
- SHOW_INT(key_direction); |
|
1707 |
+ SHOW_PARM(key_direction, keydirection2ascii(o->key_direction, false, true), "%s"); |
|
1708 | 1708 |
SHOW_STR(ciphername); |
1709 | 1709 |
SHOW_BOOL(ncp_enabled); |
1710 | 1710 |
SHOW_STR(ncp_ciphers); |
... | ... |
@@ -3577,7 +3577,7 @@ options_string(const struct options *o, |
3577 | 3577 |
* Key direction |
3578 | 3578 |
*/ |
3579 | 3579 |
{ |
3580 |
- const char *kd = keydirection2ascii(o->key_direction, remote); |
|
3580 |
+ const char *kd = keydirection2ascii(o->key_direction, remote, false); |
|
3581 | 3581 |
if (kd) |
3582 | 3582 |
{ |
3583 | 3583 |
buf_printf(&out, ",keydir %s", kd); |