mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-09-27 05:06:02 +08:00
config: add RPC command to reload config
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
28
cmd/cunicu/reload.go
Normal file
28
cmd/cunicu/reload.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/stv0g/cunicu/pkg/proto"
|
||||
)
|
||||
|
||||
var reloadCmd = &cobra.Command{
|
||||
Use: "reload",
|
||||
Short: "Reload the configuration of the cunīcu daemon",
|
||||
RunE: reload,
|
||||
Args: cobra.NoArgs,
|
||||
}
|
||||
|
||||
func init() {
|
||||
addClientCommand(rootCmd, reloadCmd)
|
||||
}
|
||||
|
||||
func reload(cmd *cobra.Command, args []string) error {
|
||||
if _, err := rpcClient.ReloadConfig(context.Background(), &proto.Empty{}); err != nil {
|
||||
return fmt.Errorf("failed RPC request: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
49
docs/usage/man/cunicu-reload.1
Normal file
49
docs/usage/man/cunicu-reload.1
Normal file
@@ -0,0 +1,49 @@
|
||||
.nh
|
||||
.TH "cunīcu" "1" "Sep 2022" "https://github.com/stv0g/cunicu" ""
|
||||
|
||||
.SH NAME
|
||||
.PP
|
||||
cunicu-reload - Reload the configuration of the cunīcu daemon
|
||||
|
||||
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\fBcunicu reload [flags]\fP
|
||||
|
||||
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
Reload the configuration of the cunīcu daemon
|
||||
|
||||
|
||||
.SH OPTIONS
|
||||
.PP
|
||||
\fB-h\fP, \fB--help\fP[=false]
|
||||
help for reload
|
||||
|
||||
.PP
|
||||
\fB-s\fP, \fB--rpc-socket\fP="/var/run/cunicu.sock"
|
||||
Unix control and monitoring socket
|
||||
|
||||
|
||||
.SH OPTIONS INHERITED FROM PARENT COMMANDS
|
||||
.PP
|
||||
\fB-C\fP, \fB--color\fP="auto"
|
||||
Enable colorization of output (one of: auto, always, never)
|
||||
|
||||
.PP
|
||||
\fB-l\fP, \fB--log-file\fP=""
|
||||
path of a file to write logs to
|
||||
|
||||
.PP
|
||||
\fB-d\fP, \fB--log-level\fP="info"
|
||||
log level (one of: debug, info, warn, error, dpanic, panic, and fatal)
|
||||
|
||||
.PP
|
||||
\fB-v\fP, \fB--verbose\fP=0
|
||||
verbosity level
|
||||
|
||||
|
||||
.SH SEE ALSO
|
||||
.PP
|
||||
\fBcunicu(1)\fP
|
@@ -40,4 +40,4 @@ It relies on the awesome pion/ice package for the interactive connectivity estab
|
||||
|
||||
.SH SEE ALSO
|
||||
.PP
|
||||
\fBcunicu-addresses(1)\fP, \fBcunicu-completion(1)\fP, \fBcunicu-config(1)\fP, \fBcunicu-daemon(1)\fP, \fBcunicu-monitor(1)\fP, \fBcunicu-relay(1)\fP, \fBcunicu-restart(1)\fP, \fBcunicu-selfupdate(1)\fP, \fBcunicu-signal(1)\fP, \fBcunicu-status(1)\fP, \fBcunicu-stop(1)\fP, \fBcunicu-sync(1)\fP, \fBcunicu-version(1)\fP, \fBcunicu-wg(1)\fP
|
||||
\fBcunicu-addresses(1)\fP, \fBcunicu-completion(1)\fP, \fBcunicu-config(1)\fP, \fBcunicu-daemon(1)\fP, \fBcunicu-monitor(1)\fP, \fBcunicu-relay(1)\fP, \fBcunicu-reload(1)\fP, \fBcunicu-restart(1)\fP, \fBcunicu-selfupdate(1)\fP, \fBcunicu-signal(1)\fP, \fBcunicu-status(1)\fP, \fBcunicu-stop(1)\fP, \fBcunicu-sync(1)\fP, \fBcunicu-version(1)\fP, \fBcunicu-wg(1)\fP
|
||||
|
@@ -33,6 +33,7 @@ It relies on the awesome pion/ice package for the interactive connectivity estab
|
||||
* [cunicu daemon](cunicu_daemon.md) - Start the daemon
|
||||
* [cunicu monitor](cunicu_monitor.md) - Monitor the cunīcu daemon for events
|
||||
* [cunicu relay](cunicu_relay.md) - Start relay API server
|
||||
* [cunicu reload](cunicu_reload.md) - Reload the configuration of the cunīcu daemon
|
||||
* [cunicu restart](cunicu_restart.md) - Restart the cunīcu daemon
|
||||
* [cunicu selfupdate](cunicu_selfupdate.md) - Update the cunīcu binary
|
||||
* [cunicu signal](cunicu_signal.md) - Start gRPC signaling server
|
||||
|
38
docs/usage/md/cunicu_reload.md
Normal file
38
docs/usage/md/cunicu_reload.md
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: cunicu reload
|
||||
sidebar_label: reload
|
||||
sidebar_class_name: command-name
|
||||
slug: /usage/man/reload
|
||||
hide_title: true
|
||||
keywords:
|
||||
- manpage
|
||||
---
|
||||
|
||||
## cunicu reload
|
||||
|
||||
Reload the configuration of the cunīcu daemon
|
||||
|
||||
```
|
||||
cunicu reload [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for reload
|
||||
-s, --rpc-socket string Unix control and monitoring socket (default "/var/run/cunicu.sock")
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
-C, --color string Enable colorization of output (one of: auto, always, never) (default "auto")
|
||||
-l, --log-file string path of a file to write logs to
|
||||
-d, --log-level string log level (one of: debug, info, warn, error, dpanic, panic, and fatal) (default "info")
|
||||
-v, --verbose int verbosity level
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [cunicu](cunicu.md) - cunīcu is a user-space daemon managing WireGuard® interfaces to establish peer-to-peer connections in harsh network environments.
|
||||
|
@@ -227,3 +227,11 @@ func (s *DaemonServer) GetConfig(ctx context.Context, p *rpcproto.GetConfigParam
|
||||
Settings: settings,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *DaemonServer) ReloadConfig(ctx context.Context, params *proto.Empty) (*proto.Empty, error) {
|
||||
if err := s.Config.Reload(); err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "failed to reload configuration: %s", err)
|
||||
}
|
||||
|
||||
return &proto.Empty{}, nil
|
||||
}
|
||||
|
@@ -38,4 +38,5 @@ service Daemon {
|
||||
rpc GetStatus(StatusParams) returns (StatusResp) {}
|
||||
rpc SetConfig(SetConfigParams) returns (Empty) {}
|
||||
rpc GetConfig(GetConfigParams) returns (GetConfigResp) {}
|
||||
rpc ReloadConfig(Empty) returns (Empty) {}
|
||||
}
|
Reference in New Issue
Block a user