mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-05 01:25:06 -05:00
cmdmon: add onoffline command
The onoffline command tells chronyd to switch all sources to the online or offline status according to the current network configuration. A source is considered online if it is possible to send requests to it, i.e. a route to the network is present.
This commit is contained in:
17
cmdmon.c
17
cmdmon.c
@@ -139,6 +139,7 @@ static const char permissions[] = {
|
||||
PERMIT_AUTH, /* ADD_SERVER3 */
|
||||
PERMIT_AUTH, /* ADD_PEER3 */
|
||||
PERMIT_AUTH, /* SHUTDOWN */
|
||||
PERMIT_AUTH, /* ONOFFLINE */
|
||||
};
|
||||
|
||||
/* ================================================== */
|
||||
@@ -443,6 +444,18 @@ handle_offline(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static void
|
||||
handle_onoffline(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
{
|
||||
IPAddr address, mask;
|
||||
|
||||
address.family = mask.family = IPADDR_UNSPEC;
|
||||
if (!NSR_SetConnectivity(&mask, &address, SRC_MAYBE_ONLINE))
|
||||
;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static void
|
||||
handle_burst(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
{
|
||||
@@ -1637,6 +1650,10 @@ read_from_cmd_socket(int sock_fd, int event, void *anything)
|
||||
handle_shutdown(&rx_message, &tx_message);
|
||||
break;
|
||||
|
||||
case REQ_ONOFFLINE:
|
||||
handle_onoffline(&rx_message, &tx_message);
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG_LOG("Unhandled command %d", rx_command);
|
||||
tx_message.status = htons(STT_FAILED);
|
||||
|
||||
Reference in New Issue
Block a user