|
41 | 41 | #include "manage.h" |
42 | 42 | #include "openvpn.h" |
43 | 43 | #include "dco.h" |
| 44 | +#include "push.h" |
44 | 45 | #include "multi.h" |
45 | 46 |
|
46 | 47 | #include "memdbg.h" |
@@ -132,8 +133,10 @@ man_help(void) |
132 | 133 | msg(M_CLIENT, "test n : Produce n lines of output for testing/debugging."); |
133 | 134 | msg(M_CLIENT, "username type u : Enter username u for a queried OpenVPN username."); |
134 | 135 | msg(M_CLIENT, "verb [n] : Set log verbosity level to n, or show if n is absent."); |
135 | | - msg(M_CLIENT, |
136 | | - "version [n] : Set client's version to n or show current version of daemon."); |
| 136 | + msg(M_CLIENT, "version [n] : Set client's version to n or show current version of daemon."); |
| 137 | + msg(M_CLIENT, "push-update-broad options : Broadcast a message to update the specified options."); |
| 138 | + msg(M_CLIENT, " Ex. push-update-broad \"route something, -dns\""); |
| 139 | + msg(M_CLIENT, "push-update-cid CID options : Send an update message to the client identified by CID."); |
137 | 140 | msg(M_CLIENT, "END"); |
138 | 141 | } |
139 | 142 |
|
@@ -1332,6 +1335,48 @@ set_client_version(struct management *man, const char *version) |
1332 | 1335 | } |
1333 | 1336 | } |
1334 | 1337 |
|
| 1338 | +static void |
| 1339 | +man_push_update(struct management *man, const char **p, const push_update_type type) |
| 1340 | +{ |
| 1341 | + bool status = false; |
| 1342 | + |
| 1343 | + if (type == UPT_BROADCAST) |
| 1344 | + { |
| 1345 | + if (!man->persist.callback.push_update_broadcast) |
| 1346 | + { |
| 1347 | + man_command_unsupported("push-update-broad"); |
| 1348 | + return; |
| 1349 | + } |
| 1350 | + |
| 1351 | + status = (*man->persist.callback.push_update_broadcast)(man->persist.callback.arg, p[1]); |
| 1352 | + } |
| 1353 | + else if (type == UPT_BY_CID) |
| 1354 | + { |
| 1355 | + if (!man->persist.callback.push_update_by_cid) |
| 1356 | + { |
| 1357 | + man_command_unsupported("push-update-cid"); |
| 1358 | + return; |
| 1359 | + } |
| 1360 | + |
| 1361 | + unsigned long cid = 0; |
| 1362 | + |
| 1363 | + if (!parse_cid(p[1], &cid)) |
| 1364 | + { |
| 1365 | + msg(M_CLIENT, "ERROR: push-update-cid fail during cid parsing"); |
| 1366 | + return; |
| 1367 | + } |
| 1368 | + |
| 1369 | + status = (*man->persist.callback.push_update_by_cid)(man->persist.callback.arg, cid, p[2]); |
| 1370 | + } |
| 1371 | + |
| 1372 | + if (status) |
| 1373 | + { |
| 1374 | + msg(M_CLIENT, "SUCCESS: push-update command succeeded"); |
| 1375 | + return; |
| 1376 | + } |
| 1377 | + msg(M_CLIENT, "ERROR: push-update command failed"); |
| 1378 | +} |
| 1379 | + |
1335 | 1380 | static void |
1336 | 1381 | man_dispatch_command(struct management *man, struct status_output *so, const char **p, |
1337 | 1382 | const int nparms) |
@@ -1655,6 +1700,20 @@ man_dispatch_command(struct management *man, struct status_output *so, const cha |
1655 | 1700 | man_remote(man, p); |
1656 | 1701 | } |
1657 | 1702 | } |
| 1703 | + else if (streq(p[0], "push-update-broad")) |
| 1704 | + { |
| 1705 | + if (man_need(man, p, 1, 0)) |
| 1706 | + { |
| 1707 | + man_push_update(man, p, UPT_BROADCAST); |
| 1708 | + } |
| 1709 | + } |
| 1710 | + else if (streq(p[0], "push-update-cid")) |
| 1711 | + { |
| 1712 | + if (man_need(man, p, 2, 0)) |
| 1713 | + { |
| 1714 | + man_push_update(man, p, UPT_BY_CID); |
| 1715 | + } |
| 1716 | + } |
1658 | 1717 | #if 1 |
1659 | 1718 | else if (streq(p[0], "test")) |
1660 | 1719 | { |
|
0 commit comments