From 92a7ad2f7f26a0783c45d6dd16e173f060a140e4 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 30 Sep 2022 08:32:26 +0200 Subject: [PATCH] daemon: use per-interface features Signed-off-by: Steffen Vogel --- cmd/cunicu/cmd.go | 11 + cmd/cunicu/daemon.go | 24 +- cmd/cunicu/selfupdate.go | 10 +- docs/usage/man/cunicu-config-reload.1 | 49 ++ docs/usage/man/cunicu-config.1 | 2 +- docs/usage/man/cunicu-daemon.1 | 26 +- docs/usage/man/cunicu.1 | 2 +- docs/usage/md/cunicu.md | 1 - docs/usage/md/cunicu_config.md | 1 + docs/usage/md/cunicu_config_reload.md | 38 ++ docs/usage/md/cunicu_daemon.md | 13 +- etc/cunicu.yaml | 184 ++++--- pkg/config/file.go | 2 + pkg/core/handlers.go | 8 + pkg/core/interface.go | 51 +- pkg/core/peer.go | 23 +- pkg/{ => daemon}/daemon.go | 163 ++++-- pkg/daemon/feature.go | 43 ++ pkg/daemon/feature/autocfg/autocfg.go | 161 ++++++ pkg/daemon/feature/autocfg/handlers.go | 64 +++ pkg/daemon/feature/cfgsync/cfgsync.go | 128 +++++ pkg/daemon/feature/cfgsync/handlers.go | 9 + pkg/daemon/feature/epdisc/epdisc.go | 262 +++++++++ pkg/daemon/feature/epdisc/handlers.go | 88 +++ pkg/{feat => daemon/feature}/epdisc/peer.go | 39 +- .../feature}/epdisc/peer_handlers.go | 4 +- .../feature}/epdisc/proxy/mux.go | 0 .../feature}/epdisc/proxy/nat_linux.go | 0 .../feature}/epdisc/proxy/nat_others.go | 0 .../feature}/epdisc/proxy/proxy.go | 2 +- .../feature}/epdisc/proxy/proxy_kernel.go | 2 +- .../feature}/epdisc/proxy/proxy_user.go | 2 +- pkg/{feat => daemon/feature}/hooks/exec.go | 25 +- pkg/daemon/feature/hooks/hooks.go | 67 +++ pkg/{feat => daemon/feature}/hooks/marshal.go | 0 pkg/{feat => daemon/feature}/hooks/web.go | 19 +- pkg/daemon/feature/hsync/handlers.go | 32 ++ pkg/{feat => daemon/feature}/hsync/host.go | 0 pkg/{feat => daemon/feature}/hsync/hsync.go | 90 ++-- pkg/{feat => daemon/feature}/hsync/util.go | 0 pkg/daemon/feature/pdisc/handlers.go | 126 +++++ pkg/daemon/feature/pdisc/pdisc.go | 163 ++++++ .../feature/rtsync/handlers.go} | 54 +- pkg/daemon/feature/rtsync/rtsync.go | 68 +++ .../feature}/rtsync/sync_linux.go | 26 +- .../feature}/rtsync/sync_others.go | 6 +- pkg/daemon/interface.go | 69 +++ pkg/device/device_linux_test.go | 6 +- pkg/feat/autocfg/autocfg.go | 218 -------- pkg/feat/cfgsync/cfgsync.go | 175 ------ pkg/feat/epdisc/epdisc.go | 171 ------ pkg/feat/epdisc/handlers.go | 11 - pkg/feat/epdisc/interface.go | 143 ----- pkg/feat/feat.go | 62 --- pkg/feat/hooks/hooks.go | 75 --- pkg/feat/pdisc/pdisc.go | 297 ---------- pkg/proto/core/interface.go | 2 +- pkg/proto/core/interface.pb.go | 76 +-- pkg/proto/core/peer.go | 2 +- pkg/proto/core/peer.pb.go | 87 +-- pkg/proto/{feat => feature}/epdisc/epdisc.go | 56 +- .../{feat => feature}/epdisc/epdisc.pb.go | 272 +++++----- .../epdisc/epdisc_candidate.go | 2 +- .../epdisc/epdisc_candidate.pb.go | 507 +++++++++--------- pkg/proto/{feat => feature}/hooks/hooks.pb.go | 96 ++-- pkg/proto/{feat => feature}/pdisc/pdisc.go | 0 pkg/proto/{feat => feature}/pdisc/pdisc.pb.go | 120 ++--- pkg/proto/{feat => feature}/pske/pske.pb.go | 78 +-- pkg/proto/proto.go | 4 +- pkg/proto/rpc/daemon.pb.go | 426 ++++++++++----- pkg/proto/rpc/daemon_grpc.pb.go | 86 ++- pkg/proto/rpc/event.pb.go | 146 ++--- pkg/proto/rpc/invitation.pb.go | 156 ++++++ pkg/proto/rpc/rpc.go | 2 +- pkg/proto/signaling/signaling.pb.go | 117 ++-- pkg/proto/signaling/signaling_test.go | 2 +- pkg/rpc/server.go | 31 +- pkg/rpc/server_daemon.go | 147 ++++- pkg/rpc/server_epdisc.go | 127 +++++ pkg/rpc/server_epice.go | 117 ---- pkg/signaling/grpc/backend_test.go | 2 +- pkg/signaling/grpc/server_relay_test.go | 9 + pkg/signaling/subscriptions.go | 2 +- pkg/watcher/register.go | 12 +- pkg/watcher/watcher.go | 15 +- pkg/wg/device.go | 6 +- pkg/wg/device_config.go | 36 +- pkg/wg/wg.go | 2 + proto/core/interface.proto | 2 +- proto/core/peer.proto | 2 +- proto/{feat => feature}/epdisc.proto | 4 +- .../{feat => feature}/epdisc_candidate.proto | 2 +- proto/{feat => feature}/hooks.proto | 2 +- proto/{feat => feature}/pdisc.proto | 2 +- proto/{feat => feature}/pske.proto | 2 +- proto/rpc/daemon.proto | 14 + proto/rpc/event.proto | 2 +- proto/rpc/invitation.proto | 11 + proto/signaling/signaling.proto | 8 +- 99 files changed, 3510 insertions(+), 2599 deletions(-) create mode 100644 docs/usage/man/cunicu-config-reload.1 create mode 100644 docs/usage/md/cunicu_config_reload.md rename pkg/{ => daemon}/daemon.go (53%) create mode 100644 pkg/daemon/feature.go create mode 100644 pkg/daemon/feature/autocfg/autocfg.go create mode 100644 pkg/daemon/feature/autocfg/handlers.go create mode 100644 pkg/daemon/feature/cfgsync/cfgsync.go create mode 100644 pkg/daemon/feature/cfgsync/handlers.go create mode 100644 pkg/daemon/feature/epdisc/epdisc.go create mode 100644 pkg/daemon/feature/epdisc/handlers.go rename pkg/{feat => daemon/feature}/epdisc/peer.go (91%) rename pkg/{feat => daemon/feature}/epdisc/peer_handlers.go (97%) rename pkg/{feat => daemon/feature}/epdisc/proxy/mux.go (100%) rename pkg/{feat => daemon/feature}/epdisc/proxy/nat_linux.go (100%) rename pkg/{feat => daemon/feature}/epdisc/proxy/nat_others.go (100%) rename pkg/{feat => daemon/feature}/epdisc/proxy/proxy.go (84%) rename pkg/{feat => daemon/feature}/epdisc/proxy/proxy_kernel.go (98%) rename pkg/{feat => daemon/feature}/epdisc/proxy/proxy_user.go (95%) rename pkg/{feat => daemon/feature}/hooks/exec.go (92%) create mode 100644 pkg/daemon/feature/hooks/hooks.go rename pkg/{feat => daemon/feature}/hooks/marshal.go (100%) rename pkg/{feat => daemon/feature}/hooks/web.go (87%) create mode 100644 pkg/daemon/feature/hsync/handlers.go rename pkg/{feat => daemon/feature}/hsync/host.go (100%) rename pkg/{feat => daemon/feature}/hsync/hsync.go (57%) rename pkg/{feat => daemon/feature}/hsync/util.go (100%) create mode 100644 pkg/daemon/feature/pdisc/handlers.go create mode 100644 pkg/daemon/feature/pdisc/pdisc.go rename pkg/{feat/rtsync/rtsync.go => daemon/feature/rtsync/handlers.go} (57%) create mode 100644 pkg/daemon/feature/rtsync/rtsync.go rename pkg/{feat => daemon/feature}/rtsync/sync_linux.go (85%) rename pkg/{feat => daemon/feature}/rtsync/sync_others.go (58%) create mode 100644 pkg/daemon/interface.go delete mode 100644 pkg/feat/autocfg/autocfg.go delete mode 100644 pkg/feat/cfgsync/cfgsync.go delete mode 100644 pkg/feat/epdisc/epdisc.go delete mode 100644 pkg/feat/epdisc/handlers.go delete mode 100644 pkg/feat/epdisc/interface.go delete mode 100644 pkg/feat/feat.go delete mode 100644 pkg/feat/hooks/hooks.go delete mode 100644 pkg/feat/pdisc/pdisc.go rename pkg/proto/{feat => feature}/epdisc/epdisc.go (75%) rename pkg/proto/{feat => feature}/epdisc/epdisc.pb.go (58%) rename pkg/proto/{feat => feature}/epdisc/epdisc_candidate.go (97%) rename pkg/proto/{feat => feature}/epdisc/epdisc_candidate.pb.go (61%) rename pkg/proto/{feat => feature}/hooks/hooks.pb.go (50%) rename pkg/proto/{feat => feature}/pdisc/pdisc.go (100%) rename pkg/proto/{feat => feature}/pdisc/pdisc.pb.go (55%) rename pkg/proto/{feat => feature}/pske/pske.pb.go (52%) create mode 100644 pkg/proto/rpc/invitation.pb.go create mode 100644 pkg/rpc/server_epdisc.go delete mode 100644 pkg/rpc/server_epice.go rename proto/{feat => feature}/epdisc.proto (95%) rename proto/{feat => feature}/epdisc_candidate.proto (99%) rename proto/{feat => feature}/hooks.proto (79%) rename proto/{feat => feature}/pdisc.proto (90%) rename proto/{feat => feature}/pske.proto (65%) create mode 100644 proto/rpc/invitation.proto diff --git a/cmd/cunicu/cmd.go b/cmd/cunicu/cmd.go index 6354af69..5a8495a0 100644 --- a/cmd/cunicu/cmd.go +++ b/cmd/cunicu/cmd.go @@ -1,9 +1,20 @@ package main import ( + // Signaling backends _ "github.com/stv0g/cunicu/pkg/signaling/grpc" _ "github.com/stv0g/cunicu/pkg/signaling/inprocess" _ "github.com/stv0g/cunicu/pkg/signaling/k8s" + + // Features + _ "github.com/stv0g/cunicu/pkg/daemon/feature/autocfg" + _ "github.com/stv0g/cunicu/pkg/daemon/feature/cfgsync" + _ "github.com/stv0g/cunicu/pkg/daemon/feature/epdisc" + _ "github.com/stv0g/cunicu/pkg/daemon/feature/hooks" + _ "github.com/stv0g/cunicu/pkg/daemon/feature/hsync" + _ "github.com/stv0g/cunicu/pkg/daemon/feature/pdisc" + _ "github.com/stv0g/cunicu/pkg/daemon/feature/rtsync" + "go.uber.org/zap" ) diff --git a/cmd/cunicu/daemon.go b/cmd/cunicu/daemon.go index 6d4fdcbd..f334f005 100644 --- a/cmd/cunicu/daemon.go +++ b/cmd/cunicu/daemon.go @@ -1,14 +1,18 @@ package main import ( + "io" + "os" + "github.com/spf13/cobra" "github.com/spf13/pflag" - cunicu "github.com/stv0g/cunicu/pkg" - "github.com/stv0g/cunicu/pkg/config" - "github.com/stv0g/cunicu/pkg/rpc" - "github.com/stv0g/cunicu/pkg/util/terminal" "go.uber.org/zap" "go.uber.org/zap/zapio" + + "github.com/stv0g/cunicu/pkg/config" + daem "github.com/stv0g/cunicu/pkg/daemon" + "github.com/stv0g/cunicu/pkg/rpc" + "github.com/stv0g/cunicu/pkg/util/terminal" ) var ( @@ -36,7 +40,7 @@ func init() { pf.VisitAll(func(f *pflag.Flag) { if f.Value.Type() == "bool" { - daemonCmd.RegisterFlagCompletionFunc(f.Name, config.BooleanCompletions) + daemonCmd.RegisterFlagCompletionFunc(f.Name, BooleanCompletions) } }) @@ -46,7 +50,7 @@ func init() { func daemon(cmd *cobra.Command, args []string) { io.WriteString(os.Stdout, Banner(color)) - if err := cfg.Load(); err != nil { + if err := cfg.Init(); err != nil { logger.Fatal("Failed to parse configuration", zap.Error(err)) } @@ -60,13 +64,13 @@ func daemon(cmd *cobra.Command, args []string) { } // Create daemon - daemon, err := cunicu.NewDaemon(cfg) + d, err := daem.New(cfg) if err != nil { logger.Fatal("Failed to create daemon", zap.Error(err)) } // Create control socket server to manage daemon - svr, err := rpc.NewServer(daemon, cfg.RPC.Socket) + svr, err := rpc.NewServer(d, cfg.RPC.Socket) if err != nil { logger.Fatal("Failed to initialize control socket", zap.Error(err)) } @@ -77,7 +81,7 @@ func daemon(cmd *cobra.Command, args []string) { } // Blocks until stopped - if err := daemon.Run(); err != nil { + if err := d.Run(); err != nil { logger.Fatal("Failed start daemon", zap.Error(err)) } @@ -85,7 +89,7 @@ func daemon(cmd *cobra.Command, args []string) { logger.Fatal("Failed to close server", zap.Error(err)) } - if err := daemon.Close(); err != nil { + if err := d.Close(); err != nil { logger.Fatal("Failed to stop daemon", zap.Error(err)) } } diff --git a/cmd/cunicu/selfupdate.go b/cmd/cunicu/selfupdate.go index f74e1f6b..f7acbcd6 100644 --- a/cmd/cunicu/selfupdate.go +++ b/cmd/cunicu/selfupdate.go @@ -4,6 +4,7 @@ package main import ( "os" + "path/filepath" "strings" "github.com/spf13/cobra" @@ -26,17 +27,18 @@ After download, the authenticity of the binary is verified using the GPG signatu func init() { rootCmd.AddCommand(selfUpdateCmd) - file, err := os.Executable() + selfPath, err := os.Executable() if err != nil { panic(err) } - if strings.Contains(file, "go-build") { - file = "cunicu" + self := filepath.Base(selfPath) + if strings.Contains(selfPath, "go-build") { + self = "cunicu" } flags := selfUpdateCmd.Flags() - flags.StringVarP(&output, "output", "o", file, "Save the downloaded file as `filename`") + flags.StringVarP(&output, "output", "o", self, "Save the downloaded file as `filename`") } func selfUpdate(cmd *cobra.Command, args []string) { diff --git a/docs/usage/man/cunicu-config-reload.1 b/docs/usage/man/cunicu-config-reload.1 new file mode 100644 index 00000000..7747b3d6 --- /dev/null +++ b/docs/usage/man/cunicu-config-reload.1 @@ -0,0 +1,49 @@ +.nh +.TH "cunīcu" "1" "Sep 2022" "https://github.com/stv0g/cunicu" "" + +.SH NAME +.PP +cunicu-config-reload - Reload the configuration of the cunīcu daemon + + +.SH SYNOPSIS +.PP +\fBcunicu config 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 + + +.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-s\fP, \fB--rpc-socket\fP="/var/run/cunicu.sock" + Unix control and monitoring socket + +.PP +\fB-v\fP, \fB--verbose\fP=0 + verbosity level + + +.SH SEE ALSO +.PP +\fBcunicu-config(1)\fP diff --git a/docs/usage/man/cunicu-config.1 b/docs/usage/man/cunicu-config.1 index 4353ee3b..9dfdfe79 100644 --- a/docs/usage/man/cunicu-config.1 +++ b/docs/usage/man/cunicu-config.1 @@ -43,4 +43,4 @@ cunicu-config - Manage configuration of a running cunīcu daemon. .SH SEE ALSO .PP -\fBcunicu(1)\fP, \fBcunicu-config-get(1)\fP, \fBcunicu-config-set(1)\fP +\fBcunicu(1)\fP, \fBcunicu-config-get(1)\fP, \fBcunicu-config-reload(1)\fP, \fBcunicu-config-set(1)\fP diff --git a/docs/usage/man/cunicu-daemon.1 b/docs/usage/man/cunicu-daemon.1 index 7c0b6e3b..b62bd2be 100644 --- a/docs/usage/man/cunicu-daemon.1 +++ b/docs/usage/man/cunicu-daemon.1 @@ -33,24 +33,16 @@ Start the daemon \fB-c\fP, \fB--config\fP=[] One or more \fB\fCfilename\fRs of configuration files -.PP -\fB-w\fP, \fB--config-path\fP="" - The \fB\fCdirectory\fR of WireGuard wg/wg-quick configuration files - .PP \fB-S\fP, \fB--config-sync\fP[=true] Enable synchronization of WireGuard configuration files -.PP -\fB-W\fP, \fB--config-watch\fP[=false] - Watch and synchronize changes to the WireGuard configuration files - .PP \fB-D\fP, \fB--domain\fP=[] A DNS \fB\fCdomain\fR name used for DNS auto-configuration .PP -\fB-I\fP, \fB--endpoint-disc\fP[=true] +\fB-E\fP, \fB--endpoint-disc\fP[=true] Enable ICE endpoint discovery .PP @@ -66,12 +58,12 @@ Start the daemon Usable \fB\fCnetwork-type\fRs (one of udp4, udp6, tcp4, tcp6) .PP -\fB-f\fP, \fB--interface-filter\fP="\fI" - A glob(7) \fB\fCpattern\fR for filtering WireGuard interfaces which this daemon will manage (e.g. "wg\fP") +\fB-p\fP, \fB--password\fP="" + The \fB\fCpassword\fR for STUN/TURN credentials .PP -\fB-P\fP, \fB--password\fP="" - The \fB\fCpassword\fR for STUN/TURN credentials +\fB-P\fP, \fB--peer-sync\fP[=true] + Enable peer discovery .PP \fB-R\fP, \fB--route-sync\fP[=true] @@ -94,15 +86,19 @@ Start the daemon One or more \fB\fCURL\fRs of STUN and/or TURN servers .PP -\fB-U\fP, \fB--username\fP="" +\fB-u\fP, \fB--username\fP="" The \fB\fCusername\fR for STUN/TURN credentials +.PP +\fB-w\fP, \fB--watch\fP[=false] + Watch configuration files for changes and apply changes at runtime. + .PP \fB-i\fP, \fB--watch-interval\fP=0s An interval at which we are periodically polling the kernel for updates on WireGuard interfaces .PP -\fB-u\fP, \fB--wg-userspace\fP[=false] +\fB-U\fP, \fB--wg-userspace\fP[=false] Use user-space WireGuard implementation for newly created interfaces .PP diff --git a/docs/usage/man/cunicu.1 b/docs/usage/man/cunicu.1 index 4286e5c2..63eda273 100644 --- a/docs/usage/man/cunicu.1 +++ b/docs/usage/man/cunicu.1 @@ -59,4 +59,4 @@ in which WireGuard kernel support has not landed yet. .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-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 +\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 diff --git a/docs/usage/md/cunicu.md b/docs/usage/md/cunicu.md index 432ec23e..7e83bfe0 100644 --- a/docs/usage/md/cunicu.md +++ b/docs/usage/md/cunicu.md @@ -45,7 +45,6 @@ in which WireGuard kernel support has not landed yet. * [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 diff --git a/docs/usage/md/cunicu_config.md b/docs/usage/md/cunicu_config.md index 709a23cb..46c45d24 100644 --- a/docs/usage/md/cunicu_config.md +++ b/docs/usage/md/cunicu_config.md @@ -37,5 +37,6 @@ Manage configuration of a running cunīcu daemon. * [cunicu](cunicu.md) - cunīcu is a user-space daemon managing WireGuard® interfaces to establish peer-to-peer connections in harsh network environments. * [cunicu config get](cunicu_config_get.md) - Get current value of a configuration setting +* [cunicu config reload](cunicu_config_reload.md) - Reload the configuration of the cunīcu daemon * [cunicu config set](cunicu_config_set.md) - Update the value of a configuration setting diff --git a/docs/usage/md/cunicu_config_reload.md b/docs/usage/md/cunicu_config_reload.md new file mode 100644 index 00000000..4cd74514 --- /dev/null +++ b/docs/usage/md/cunicu_config_reload.md @@ -0,0 +1,38 @@ +--- +title: cunicu config reload +sidebar_label: config reload +sidebar_class_name: command-name +slug: /usage/man/config/reload +hide_title: true +keywords: + - manpage +--- + +## cunicu config reload + +Reload the configuration of the cunīcu daemon + +``` +cunicu config reload [flags] +``` + +### Options + +``` + -h, --help help for reload +``` + +### 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") + -s, --rpc-socket string Unix control and monitoring socket (default "/var/run/cunicu.sock") + -v, --verbose int verbosity level +``` + +### SEE ALSO + +* [cunicu config](cunicu_config.md) - Manage configuration of a running cunīcu daemon. + diff --git a/docs/usage/md/cunicu_daemon.md b/docs/usage/md/cunicu_daemon.md index 49171742..c946d9e5 100644 --- a/docs/usage/md/cunicu_daemon.md +++ b/docs/usage/md/cunicu_daemon.md @@ -29,24 +29,23 @@ $ cunicu daemon -u -x mysecretpass wg0 -b, --backend URL One or more URLs to signaling backends -x, --community passphrase A passphrase shared with other peers in the same community -c, --config filename One or more filenames of configuration files - -w, --config-path directory The directory of WireGuard wg/wg-quick configuration files -S, --config-sync Enable synchronization of WireGuard configuration files (default true) - -W, --config-watch Watch and synchronize changes to the WireGuard configuration files -D, --domain domain A DNS domain name used for DNS auto-configuration - -I, --endpoint-disc Enable ICE endpoint discovery (default true) + -E, --endpoint-disc Enable ICE endpoint discovery (default true) -H, --host-sync Enable synchronization of /etc/hosts file (default true) --ice-candidate-type candidate-type Usable candidate-types (one of host, srflx, prflx, relay) --ice-network-type network-type Usable network-types (one of udp4, udp6, tcp4, tcp6) - -f, --interface-filter pattern A glob(7) pattern for filtering WireGuard interfaces which this daemon will manage (e.g. "wg*") (default "*") - -P, --password password The password for STUN/TURN credentials + -p, --password password The password for STUN/TURN credentials + -P, --peer-sync Enable peer discovery (default true) -R, --route-sync Enable synchronization of AllowedIPs and Kernel routing table (default true) -T, --route-table int Kernel routing table to use (default 254) -s, --rpc-socket path The path of the unix socket used by other cunicu commands --rpc-wait Wait until first client connected to control socket before continuing start -a, --url URL One or more URLs of STUN and/or TURN servers - -U, --username username The username for STUN/TURN credentials + -u, --username username The username for STUN/TURN credentials + -w, --watch Watch configuration files for changes and apply changes at runtime. -i, --watch-interval duration An interval at which we are periodically polling the kernel for updates on WireGuard interfaces - -u, --wg-userspace Use user-space WireGuard implementation for newly created interfaces + -U, --wg-userspace Use user-space WireGuard implementation for newly created interfaces -h, --help help for daemon ``` diff --git a/etc/cunicu.yaml b/etc/cunicu.yaml index cb95d56f..99716432 100644 --- a/etc/cunicu.yaml +++ b/etc/cunicu.yaml @@ -8,7 +8,7 @@ watch_interval: 1s # between the peers. # E.g. ICE candidates, Peer information backends: -- grpc://signal.cunicu.li +- grpc://signal.cunicu.li:443 # - grpc://localhost:8080?insecure=true&skip_verify=true # - k8s:///path/to/your/kubeconfig.yaml?namespace=default @@ -25,41 +25,6 @@ rpc: wait: false -## Hook callbacks -# -# Hook callback can be used to invoke subprocesses -# or web-hooks on certain events within cunīcu. -hooks: - -# An 'exec' hook spawn a subprocess for each event. -- type: exec - command: ../../scripts/hook.sh - - # Prepend additional arguments - args: [] - - # Pass JSON object via Stdin to command - stdin: true - - # Set environment variables for invocation - env: - COLOR: "1" - -# A 'web' hook performs HTTP requests for each event. -- type: web - - # URL of the webhook endpoint - url: https://my-webhook-endpoint.com/api/v1/webhook - - # HTTP method of the request - method: POST - - # Additional HTTP headers which are used for the requests - headers: - User-Agent: ahoi - Authorization: Bearer XXXXXX - - #### Interface settings start here # The following settings can be overwritten for each interface # using the 'interfaces' settings (see below). @@ -98,55 +63,61 @@ wireguard: # May be specified in hexadecimal by prepending "0x". Optional. fwmark: 0x1000 - # A list of peers. - peers: - - # A base64 public key calculated by wg pubkey from a private key, - # and usually transmitted out of band - # to the author of the configuration file. - public_key: FlKHqqQQx+bTAq7+YhwEECwWRg2Ih7NQ48F/SeOYRH8= + # The remote WireGuard peers provided as a dictionary + # The keys of this dictionary are used as names for the peers + peers: + test: + # A base64 public key calculated by wg pubkey from a private key, + # and usually transmitted out of band + # to the author of the configuration file. + public_key: FlKHqqQQx+bTAq7+YhwEECwWRg2Ih7NQ48F/SeOYRH8= - # A base64 pre-shared key generated by wg genpsk. - # Optional, and may be omitted. - # This option adds an additional layer of symmetric-key - # cryptography to be mixed into the already existing - # public-key cryptography, for post-quantum resistance. - preshared_key: zu86NBVsWOU3cx4UKOQ6MgNj3gv8GXsV9ATzSemdqlI= + # A base64 pre-shared key generated by wg genpsk. + # Optional, and may be omitted. + # This option adds an additional layer of symmetric-key + # cryptography to be mixed into the already existing + # public-key cryptography, for post-quantum resistance. + preshared_key: zu86NBVsWOU3cx4UKOQ6MgNj3gv8GXsV9ATzSemdqlI= - # A pre-shared passphrase which is used to derive a preshared key. - # cunīcu is using Argon2id as the key derivation function. - preshared_key_passphrase: some-shared-passphrase + # A pre-shared passphrase which is used to derive a preshared key. + # cunīcu is using Argon2id as the key derivation function. + preshared_key_passphrase: some-shared-passphrase - # An endpoint IP or hostname, followed by a colon, - # and then a port number. This endpoint will be updated - # automatically to the most recent source IP address and - # port of correctly authenticated packets from the peer. - # If provided, no endpoint discovery will be performed. - endpoint: vpn.example.com:51820 + # An endpoint IP or hostname, followed by a colon, + # and then a port number. This endpoint will be updated + # automatically to the most recent source IP address and + # port of correctly authenticated packets from the peer. + # If provided, no endpoint discovery will be performed. + endpoint: vpn.example.com:51820 - # A time duration, between 1 and 65535s inclusive, of how - # often to send an authenticated empty packet to the peer - # for the purpose of keeping a stateful firewall or NAT mapping - # valid persistently. For example, if the interface very rarely - # sends traffic, but it might at anytime receive traffic from a - # peer, and it is behind NAT, the interface might benefit from - # having a persistent keepalive interval of 25 seconds. - # If set to zero, this option is disabled. - # By default or when unspecified, this option is off. - # Most users will not need this. Optional. - persistent_keepalive: 120s + # A time duration, between 1 and 65535s inclusive, of how + # often to send an authenticated empty packet to the peer + # for the purpose of keeping a stateful firewall or NAT mapping + # valid persistently. For example, if the interface very rarely + # sends traffic, but it might at anytime receive traffic from a + # peer, and it is behind NAT, the interface might benefit from + # having a persistent keepalive interval of 25 seconds. + # If set to zero, this option is disabled. + # By default or when unspecified, this option is off. + # Most users will not need this. Optional. + persistent_keepalive: 120s + + # A comma-separated list of IP (v4 or v6) addresses with + # CIDR masks from which incoming traffic for this peer is + # allowed and to which outgoing traffic for this peer is directed. + # The catch-all 0.0.0.0/0 may be specified for matching + # all IPv4 addresses, and ::/0 may be specified for matching + # all IPv6 addresses. May be specified multiple times. + allowed_ips: + - 192.168.5.0/24 - # A comma-separated list of IP (v4 or v6) addresses with - # CIDR masks from which incoming traffic for this peer is - # allowed and to which outgoing traffic for this peer is directed. - # The catch-all 0.0.0.0/0 may be specified for matching - # all IPv4 addresses, and ::/0 may be specified for matching - # all IPv6 addresses. May be specified multiple times. - allowed_ips: - - 192.168.5.0/24 ## Auto configuration # autocfg: + # Enable auto-configuration + enabled: true + # The Maximum Transfer Unit of the WireGuard interface. # If not specified, the MTU is automatically determined from # the endpoint addresses or the system default route, @@ -175,16 +146,13 @@ autocfg: # Assign link-local addresses to the WireGuard interface. link_local: true -## Config file synchronization + +## Config synchronization # # Synchronize local WireGuard interface configuration with wg(8) config-files. cfgsync: + # Enable config synchronization enabled: false - - # Directory where Wireguard configuration files are located. - # We expect the same format as used by wg(8) and wg-quick(8). - # Filenames must match the interface name with a '.conf' suffix. - path: /etc/wireguard # Watch the configuration files via inotify(7) for changes and apply them accordingly. watch: false @@ -200,9 +168,12 @@ cfgsync: # In reverse, also networks listed in a peers AllowedIPs setting will be installed as a # kernel route with the peers link-local address as the routes next-hop. rtsync: + # Enable route synchronization enabled: true - table: 254 # See /etc/iproute2/rt_tables for table ids + # Kernel routing table which is used + # On Linux, see /etc/iproute2/rt_tables for table ids and names + table: 254 # Keep watching the for changes in the kernel routing table via netlink multicast group. watch: true @@ -212,6 +183,7 @@ rtsync: # # Synchronizes the local /etc/hosts file with host names and link-local IP addresses of connected peers. hsync: + # Enable hosts file synchronization enabled: true # The domain name which is appended to each of the peer host names @@ -222,11 +194,15 @@ hsync: # # Peer discovery finds new peers within the same community and adds them to the respective interface pdisc: + # Enable peer discovery enabled: true # The hostname which gets advertised to remote peers hostname: my-node + # A passphrase shared among all peers of the same community + community: "some-common-password" + # Networks which are reachable via this peer and get advertised to remote peers # These will be part of this interfaces AllowedIPs at the remote peers. networks: @@ -237,10 +213,10 @@ pdisc: # If not configured, all peers will be accepted. whitelist: - coNsGPwVPdpahc8U+dbbWGzTAdCd6+1BvPIYg10wDCI= - - AOZzBaNsoV7P8vo0D5UmuIJUQ7AjMbHbGt2EA8eAuEc= - # A passphrase shared among all peers of the same community - community: "some-common-password" + # A list if WireGuard public keys which are rejected as peers + blacklist: + - AOZzBaNsoV7P8vo0D5UmuIJUQ7AjMbHbGt2EA8eAuEc= ## Endpoint discovery @@ -249,6 +225,7 @@ pdisc: # gather a list of candidate endpoints and performs connectivity checks to find a suitable # endpoint address which can be used by WireGuard epdisc: + # Enable endpoint discovery enabled: true # Interactive Connectivity Establishment (ICE) parameters @@ -329,6 +306,41 @@ epdisc: keepalive_interval: 2s +## Hook callbacks +# +# Hook callback can be used to invoke subprocesses +# or web-hooks on certain events within cunīcu. +hooks: + + # An 'exec' hook spawn a subprocess for each event. + - type: exec + command: ../../scripts/hook.sh + + # Prepend additional arguments + args: [] + + # Pass JSON object via Stdin to command + stdin: true + + # Set environment variables for invocation + env: + COLOR: "1" + + # A 'web' hook performs HTTP requests for each event. + - type: web + + # URL of the webhook endpoint + url: https://my-webhook-endpoint.com/api/v1/webhook + + # HTTP method of the request + method: POST + + # Additional HTTP headers which are used for the requests + headers: + User-Agent: ahoi + Authorization: Bearer XXXXXX + + ## Interface specific settings / overwrites. # # Most of the top-level settings of this configuration file can be overwritten diff --git a/pkg/config/file.go b/pkg/config/file.go index 2cc5ec71..529e3f9f 100644 --- a/pkg/config/file.go +++ b/pkg/config/file.go @@ -86,6 +86,8 @@ func (p *remoteFileProvider) Order() []string { } func (p *remoteFileProvider) Version() any { + p.hasChanged() + if p.etag != "" { return p.etag } diff --git a/pkg/core/handlers.go b/pkg/core/handlers.go index 93ec6fd1..35776bcf 100644 --- a/pkg/core/handlers.go +++ b/pkg/core/handlers.go @@ -10,18 +10,26 @@ import ( type InterfaceHandler interface { OnInterfaceAdded(i *Interface) OnInterfaceRemoved(i *Interface) +} + +type InterfaceModifiedHandler interface { OnInterfaceModified(i *Interface, old *wg.Device, m InterfaceModifier) } type PeerHandler interface { OnPeerAdded(p *Peer) OnPeerRemoved(p *Peer) +} + +type PeerModifiedHandler interface { OnPeerModified(p *Peer, old *wgtypes.Peer, m PeerModifier, ipsAdded, ipsRemoved []net.IPNet) } type AllHandler interface { InterfaceHandler + InterfaceModifiedHandler PeerHandler + PeerModifiedHandler } type Event any diff --git a/pkg/core/interface.go b/pkg/core/interface.go index 199b5251..3cdce760 100644 --- a/pkg/core/interface.go +++ b/pkg/core/interface.go @@ -36,7 +36,7 @@ type Interface struct { client *wgctrl.Client - onModified []InterfaceHandler + onModified []InterfaceModifiedHandler onPeer []PeerHandler logger *zap.Logger @@ -46,7 +46,7 @@ func (i *Interface) String() string { return i.Device.Name } -func (i *Interface) OnModified(h InterfaceHandler) { +func (i *Interface) OnModified(h InterfaceModifiedHandler) { i.onModified = append(i.onModified, h) } @@ -141,7 +141,7 @@ func (i *Interface) Sync(new *wgtypes.Device) (InterfaceModifier, []wgtypes.Peer mod |= InterfaceModifiedListenPort } - peersAdded, peersRemoved, peersKept := util.DiffSliceFunc(old.Peers, new.Peers, wg.CmpPeers) + peersAdded, peersRemoved, peersKept := util.SliceDiffFunc(old.Peers, new.Peers, wg.CmpPeers) if len(peersAdded) > 0 || len(peersRemoved) > 0 { mod |= InterfaceModifiedPeers } @@ -222,7 +222,12 @@ func (i *Interface) SyncConfig(cfgFilename string) error { return fmt.Errorf("failed to open config file %s: %w", cfgFilename, err) } - cfg, err := wg.ParseConfig(cfgFile, i.Name()) + cfgContents, err := io.ReadAll(cfgFile) + if err != nil { + return fmt.Errorf("failed to read config file %s: %w", cfgFilename, err) + } + + cfg, err := wg.ParseConfig(cfgContents) if err != nil { return fmt.Errorf("failed to parse configuration: %s", err) } @@ -296,7 +301,7 @@ func NewInterface(wgDev *wgtypes.Device, client *wgctrl.Client) (*Interface, err client: client, Peers: map[crypto.Key]*Peer{}, - onModified: []InterfaceHandler{}, + onModified: []InterfaceModifiedHandler{}, onPeer: []PeerHandler{}, logger: zap.L().Named("intf").With( @@ -317,25 +322,33 @@ func NewInterface(wgDev *wgtypes.Device, client *wgctrl.Client) (*Interface, err return i, nil } +// DetectMTU find a suitable MTU for the tunnel interface. +// The algorithm is the same as used by wg-quick: +// +// The MTU is automatically determined from the endpoint addresses +// or the system default route, which is usually a sane choice. func (i *Interface) DetectMTU() (mtu int, err error) { - if len(i.Device.Peers) == 0 { - mtu, err = device.DetectDefaultMTU() - if err != nil { - return -1, err - } - } else { - mtu = math.MaxInt - for _, p := range i.Device.Peers { - if p.Endpoint != nil { - if pmtu, err := device.DetectMTU(p.Endpoint.IP); err != nil { - return -1, fmt.Errorf("failed to detect MTU: %w", err) - } else if pmtu < mtu { - mtu = pmtu - } + mtu = math.MaxInt + for _, p := range i.Peers { + if p.Endpoint != nil { + if pmtu, err := device.DetectMTU(p.Endpoint.IP); err != nil { + return -1, err + } else if pmtu < mtu { + mtu = pmtu } } } + if mtu == math.MaxInt { + if mtu, err = device.DetectDefaultMTU(); err != nil { + return -1, err + } + } + + if mtu-wg.TunnelOverhead < wg.MinimalMTU { + return -1, fmt.Errorf("MTU too small: %d", mtu) + } + return mtu - wg.TunnelOverhead, nil } diff --git a/pkg/core/peer.go b/pkg/core/peer.go index 91828628..0b675b73 100644 --- a/pkg/core/peer.go +++ b/pkg/core/peer.go @@ -29,7 +29,7 @@ type Peer struct { LastReceiveTime time.Time LastTransmitTime time.Time - onModified []PeerHandler + onModified []PeerModifiedHandler client *wgctrl.Client @@ -42,7 +42,7 @@ func NewPeer(wgp *wgtypes.Peer, i *Interface) (*Peer, error) { Interface: i, Peer: wgp, - onModified: []PeerHandler{}, + onModified: []PeerModifiedHandler{}, client: i.client, logger: zap.L().Named("peer").With( @@ -124,7 +124,7 @@ func (p *Peer) WireGuardConfig() *wgtypes.PeerConfig { } // OnModified registers a new handler which is called whenever the peer has been modified -func (p *Peer) OnModified(h PeerHandler) { +func (p *Peer) OnModified(h PeerModifiedHandler) { p.onModified = append(p.onModified, h) } @@ -174,6 +174,13 @@ func (p *Peer) SetPresharedKey(psk *crypto.Key) error { // AddAllowedIP adds a new IP network to the allowed ip list of the WireGuard peer func (p *Peer) AddAllowedIP(a net.IPNet) error { + if util.SliceContains(p.AllowedIPs, func(n net.IPNet) bool { + return util.CmpNet(n, a) == 0 + }) { + p.logger.Warn("Not adding already existing allowed IP", zap.Any("ip", a)) + return nil + } + cfg := wgtypes.Config{ Peers: []wgtypes.PeerConfig{ { @@ -190,11 +197,13 @@ func (p *Peer) AddAllowedIP(a net.IPNet) error { } // RemoveAllowedIP removes a new IP network from the allowed ip list of the WireGuard peer -func (p *Peer) RemoveAllowedIP(a *net.IPNet) error { - ips := util.FilterSlice(p.Peer.AllowedIPs, func(b net.IPNet) bool { - return util.CmpNet(a, &b) != 0 +func (p *Peer) RemoveAllowedIP(a net.IPNet) error { + ips := util.SliceFilter(p.Peer.AllowedIPs, func(b net.IPNet) bool { + return util.CmpNet(a, b) != 0 }) + // TODO: Check is net is in AllowedIPs before attempting removing it + cfg := wgtypes.Config{ Peers: []wgtypes.PeerConfig{ { @@ -243,7 +252,7 @@ func (p *Peer) Sync(new *wgtypes.Peer) (PeerModifier, []net.IPNet, []net.IPNet) } // Find changes in AllowedIP list - ipsAdded, ipsRemoved, _ := util.DiffSliceFunc(old.AllowedIPs, new.AllowedIPs, util.CmpNet) + ipsAdded, ipsRemoved, _ := util.SliceDiffFunc(old.AllowedIPs, new.AllowedIPs, util.CmpNet) if len(ipsAdded) > 0 || len(ipsRemoved) > 0 { mod |= PeerModifiedAllowedIPs } diff --git a/pkg/daemon.go b/pkg/daemon/daemon.go similarity index 53% rename from pkg/daemon.go rename to pkg/daemon/daemon.go index c6abd793..9ae488fa 100644 --- a/pkg/daemon.go +++ b/pkg/daemon/daemon.go @@ -1,14 +1,15 @@ -package cunicu +package daemon import ( "errors" "fmt" "net/url" + "strings" "github.com/stv0g/cunicu/pkg/config" + "github.com/stv0g/cunicu/pkg/core" + "github.com/stv0g/cunicu/pkg/crypto" "github.com/stv0g/cunicu/pkg/device" - "github.com/stv0g/cunicu/pkg/feat" - "github.com/stv0g/cunicu/pkg/feat/epdisc" "github.com/stv0g/cunicu/pkg/util" "github.com/stv0g/cunicu/pkg/watcher" "github.com/stv0g/cunicu/pkg/wg" @@ -21,16 +22,13 @@ import ( type Daemon struct { *watcher.Watcher - Features []feat.Feature - - EndpointDiscovery *epdisc.EndpointDiscovery - // Shared Backend *signaling.MultiBackend Client *wgctrl.Client Config *config.Config - devices []device.Device + devices []device.Device + interfaces map[*core.Interface]*Interface stop chan any reexecOnClose bool @@ -38,7 +36,7 @@ type Daemon struct { logger *zap.Logger } -func NewDaemon(cfg *config.Config) (*Daemon, error) { +func New(cfg *config.Config) (*Daemon, error) { var err error // Check permissions @@ -47,13 +45,19 @@ func NewDaemon(cfg *config.Config) (*Daemon, error) { } d := &Daemon{ - Config: cfg, - devices: []device.Device{}, - stop: make(chan any), + Config: cfg, + devices: []device.Device{}, + interfaces: map[*core.Interface]*Interface{}, + stop: make(chan any), } d.logger = zap.L().Named("daemon") + // Initialize some defaults configuration settings at runtime + if err = config.InitDefaults(); err != nil { + return nil, fmt.Errorf("failed to initialize defaults: %w", err) + } + // Create WireGuard netlink socket d.Client, err = wgctrl.New() if err != nil { @@ -71,34 +75,20 @@ func NewDaemon(cfg *config.Config) (*Daemon, error) { urls = append(urls, &u.URL) } - d.Backend, err = signaling.NewMultiBackend(urls, &signaling.BackendConfig{ + if d.Backend, err = signaling.NewMultiBackend(urls, &signaling.BackendConfig{ OnReady: []signaling.BackendReadyHandler{}, - }) - - if err != nil { + }); err != nil { return nil, fmt.Errorf("failed to initialize signaling backend: %w", err) } - // Check if WireGuard interface can be created by the kernel - if !cfg.DefaultInterfaceSettings.WireGuard.UserSpace && !wg.KernelModuleExists() { - d.logger.Warn("The system does not have kernel support for WireGuard. Falling back to user-space implementation.") - cfg.DefaultInterfaceSettings.WireGuard.UserSpace = true - } - - d.Features, d.EndpointDiscovery = feat.NewFeatures(d.Watcher, d.Config, d.Client, d.Backend) - - for _, feat := range d.Features { - if err := feat.Start(); err != nil { - return nil, err - } - } + d.Watcher.OnInterface(d) return d, nil } func (d *Daemon) Run() error { if err := wg.CleanupUserSockets(); err != nil { - return fmt.Errorf("failed to cleanup stale userspace sockets: %w", err) + return fmt.Errorf("failed to cleanup stale user space sockets: %w", err) } if err := d.CreateDevicesFromArgs(); err != nil { @@ -153,11 +143,9 @@ func (d *Daemon) Sync() error { return err } - for _, f := range d.Features { - if s, ok := f.(feat.Syncable); ok { - if err := s.Sync(); err != nil { - return err - } + for _, i := range d.interfaces { + if err := i.Sync(); err != nil { + return err } } @@ -172,12 +160,12 @@ func (d *Daemon) Close() error { } if err := d.Watcher.Close(); err != nil { - return fmt.Errorf("failed to close interface: %w", err) + return fmt.Errorf("failed to close watcher: %w", err) } - for _, feat := range d.Features { - if err := feat.Close(); err != nil { - return err + for _, i := range d.interfaces { + if err := i.Close(); err != nil { + return fmt.Errorf("failed to close interface: %w", err) } } @@ -195,27 +183,100 @@ func (d *Daemon) Close() error { } func (d *Daemon) CreateDevicesFromArgs() error { - var devs wg.Devices + var devs wg.DeviceList var err error if devs, err = d.Client.Devices(); err != nil { return fmt.Errorf("failed to get existing WireGuard devices: %w", err) } - for _, i := range d.Config.Interfaces { - if i.Name != "" { - if wgdev := devs.GetByName(i.Name); wgdev != nil { - return fmt.Errorf("device '%s' already exists", i.Name) - } + isPattern := func(s string) bool { + return strings.ContainsAny(s, "*?[]\\") + } - icfg := d.Config.InterfaceSettings(i.Name) + for name := range d.Config.Interfaces { + if isPattern(name) { + continue + } - dev, err := device.NewDevice(i.Name, icfg.WireGuard.UserSpace) - if err != nil { - return fmt.Errorf("failed to create WireGuard device: %w", err) - } + if wgdev := devs.GetByName(name); wgdev != nil { + // Device already exists + continue + } - d.devices = append(d.devices, dev) + icfg := d.Config.InterfaceSettings(name) + + dev, err := device.NewDevice(name, icfg.WireGuard.UserSpace) + if err != nil { + return fmt.Errorf("failed to create WireGuard device: %w", err) + } + + d.devices = append(d.devices, dev) + } + + return nil +} + +func (d *Daemon) OnInterfaceAdded(ci *core.Interface) { + i, err := d.NewInterface(ci) + if err != nil { + d.logger.Error("Failed to add interface", zap.Error(err)) + } + + d.interfaces[ci] = i + + if err := i.Start(); err != nil { + d.logger.Error("Failed to start interface", zap.Error(err)) + } +} + +func (d *Daemon) OnInterfaceRemoved(ci *core.Interface) { + i := d.interfaces[ci] + + if err := i.Close(); err != nil { + d.logger.Error("Failed to close interface", zap.Error(err)) + } + + delete(d.interfaces, ci) +} + +// Simple wrappers for d.Watcher.InterfaceBy* + +func (d *Daemon) InterfaceByCore(ci *core.Interface) *Interface { + return d.interfaces[ci] +} + +func (d *Daemon) InterfaceByName(name string) *Interface { + ci := d.Watcher.InterfaceByName(name) + if ci == nil { + return nil + } + + return d.interfaces[ci] +} + +func (d *Daemon) InterfaceByPublicKey(pk crypto.Key) *Interface { + ci := d.Watcher.InterfaceByPublicKey(pk) + if ci == nil { + return nil + } + + return d.interfaces[ci] +} + +func (d *Daemon) InterfaceByIndex(idx int) *Interface { + ci := d.Watcher.InterfaceByIndex(idx) + if ci == nil { + return nil + } + + return d.interfaces[ci] +} + +func (d *Daemon) ForEachInterface(cb func(i *Interface) error) error { + for _, i := range d.interfaces { + if err := cb(i); err != nil { + return err } } diff --git a/pkg/daemon/feature.go b/pkg/daemon/feature.go new file mode 100644 index 00000000..d9a0a1fa --- /dev/null +++ b/pkg/daemon/feature.go @@ -0,0 +1,43 @@ +// Package feat contains several sub-packages each implementing a dedicated feature. +package daemon + +import ( + "golang.org/x/exp/slices" +) + +var ( + Features = map[string]*FeaturePlugin{} + plugins []*FeaturePlugin +) + +type FeaturePlugin struct { + Name string + Description string + + New func(i *Interface) (Feature, error) + Order int +} + +type SyncableFeature interface { + Sync() error +} + +type Feature interface { + Start() error + Close() error +} + +func SortedFeatures() []*FeaturePlugin { + if plugins == nil { + for name, feat := range Features { + feat.Name = name + plugins = append(plugins, feat) + } + } + + slices.SortFunc(plugins, func(a, b *FeaturePlugin) bool { + return a.Order < b.Order + }) + + return plugins +} diff --git a/pkg/daemon/feature/autocfg/autocfg.go b/pkg/daemon/feature/autocfg/autocfg.go new file mode 100644 index 00000000..5324c1d2 --- /dev/null +++ b/pkg/daemon/feature/autocfg/autocfg.go @@ -0,0 +1,161 @@ +// Package autocfg handles initial auto-configuration of new interfaces and peers +package autocfg + +import ( + "errors" + "fmt" + "net" + "syscall" + + "github.com/stv0g/cunicu/pkg/crypto" + "github.com/stv0g/cunicu/pkg/daemon" + "github.com/stv0g/cunicu/pkg/device" + "github.com/stv0g/cunicu/pkg/util" + "go.uber.org/zap" + "golang.org/x/exp/slices" + "golang.zx2c4.com/wireguard/wgctrl/wgtypes" +) + +func init() { + daemon.Features["autocfg"] = &daemon.FeaturePlugin{ + New: New, + Description: "Interface auto-configuration", + Order: 10, + } +} + +type Interface struct { + *daemon.Interface + + logger *zap.Logger +} + +func New(i *daemon.Interface) (daemon.Feature, error) { + if !i.Settings.AutoConfig.Enabled { + return nil, nil + } + + a := &Interface{ + Interface: i, + logger: zap.L().Named("autocfg").With(zap.String("intf", i.Name())), + } + + i.OnModified(a) + i.OnPeer(a) + + return a, nil +} + +func (a *Interface) Start() error { + a.logger.Info("Started interface auto-configuration") + + if err := a.configureWireGuardInterface(); err != nil { + a.logger.Error("Failed to configure WireGuard interface", zap.Error(err)) + } + + // Assign addresses + addrs := slices.Clone(a.Settings.AutoConfig.Addresses) + if a.Settings.AutoConfig.LinkLocalAddresses && a.PublicKey().IsSet() { + addrs = append(addrs, a.PublicKey().IPv4Address(), a.PublicKey().IPv6Address()) + } + + if err := addAddresses(a.KernelDevice, addrs...); err != nil { + a.logger.Error("Failed to assign addresses", zap.Error(err), zap.Any("addrs", addrs)) + } + + // Autodetect MTU + // TODO: Update MTU when peers are added or their endpoints change + if mtu := a.Settings.AutoConfig.MTU; mtu == 0 { + var err error + if mtu, err = a.DetectMTU(); err != nil { + a.logger.Error("Failed to detect MTU", zap.Error(err)) + } else { + if err := a.KernelDevice.SetMTU(mtu); err != nil { + a.logger.Error("Failed to set MTU", zap.Error(err), zap.Int("mtu", a.Settings.AutoConfig.MTU)) + } + } + } + + // Set link up + if err := a.KernelDevice.SetUp(); err != nil { + a.logger.Error("Failed to bring link up", zap.Error(err)) + } + + return nil +} + +func (a *Interface) Close() error { + return nil +} + +// configureWireGuardInterface configures the WireGuard device using the configuration provided by the user. +// Missing settings such as a private key or listen port are automatically generated/allocated. +func (a *Interface) configureWireGuardInterface() error { + var err error + + cfg := wgtypes.Config{} + configure := false + + // Private key + if !a.PrivateKey().IsSet() || (a.Settings.WireGuard.PrivateKey.IsSet() && a.Settings.WireGuard.PrivateKey != a.PrivateKey()) { + sk := a.Settings.WireGuard.PrivateKey + if !sk.IsSet() { + sk, err = crypto.GeneratePrivateKey() + if err != nil { + return fmt.Errorf("failed to generate private key: %w", err) + } + } + + cfg.PrivateKey = (*wgtypes.Key)(&sk) + configure = true + } + + // Listen port + if a.ListenPort == 0 || (a.Settings.WireGuard.ListenPort != nil && a.ListenPort != *a.Settings.WireGuard.ListenPort) { + if a.Settings.WireGuard.ListenPort != nil { + cfg.ListenPort = a.Settings.WireGuard.ListenPort + } else { + a.logger.Warn("Device has no listen port. Setting a random one.") + + port, err := util.FindNextPortToListen("udp", + a.Settings.WireGuard.ListenPortRange.Min, + a.Settings.WireGuard.ListenPortRange.Max, + ) + if err != nil { + return fmt.Errorf("failed set listen port: %w", err) + } + + cfg.ListenPort = &port + } + + configure = true + } + + if configure { + if err := a.Daemon.Client.ConfigureDevice(a.Name(), cfg); err != nil { + return fmt.Errorf("failed to configure device: %w", err) + } + } + + return nil +} + +func addAddresses(dev device.Device, addrs ...net.IPNet) error { + for _, addr := range addrs { + if err := dev.AddAddress(addr); err != nil && !errors.Is(err, syscall.EEXIST) { + return fmt.Errorf("failed to assign address: %w", err) + } + } + + return nil +} + +func deleteAddresses(dev device.Device, addrs ...net.IPNet) error { + for _, addr := range addrs { + if err := dev.DeleteAddress(addr); err != nil { + return fmt.Errorf("failed to assign IPv4 link-local address: %w", err) + } + } + + return nil +} diff --git a/pkg/daemon/feature/autocfg/handlers.go b/pkg/daemon/feature/autocfg/handlers.go new file mode 100644 index 00000000..add9f4b6 --- /dev/null +++ b/pkg/daemon/feature/autocfg/handlers.go @@ -0,0 +1,64 @@ +package autocfg + +import ( + "net" + + "github.com/stv0g/cunicu/pkg/core" + "github.com/stv0g/cunicu/pkg/crypto" + "github.com/stv0g/cunicu/pkg/wg" + "go.uber.org/zap" + "golang.zx2c4.com/wireguard/wgctrl/wgtypes" +) + +func (a *Interface) OnInterfaceModified(i *core.Interface, old *wg.Device, mod core.InterfaceModifier) { + + // Update link-local addresses in case the interface key has changed + if mod&core.InterfaceModifiedPrivateKey != 0 { + oldPk := crypto.Key(old.PublicKey) + newPk := i.PublicKey() + + if oldPk.IsSet() { + if err := deleteAddresses(i.KernelDevice, + oldPk.IPv4Address(), + oldPk.IPv6Address(), + ); err != nil { + a.logger.Error("Failed to delete link-local addresses", zap.Error(err)) + } + } + + if newPk.IsSet() { + if err := addAddresses(i.KernelDevice, + newPk.IPv4Address(), + newPk.IPv6Address(), + ); err != nil { + a.logger.Error("Failed to assign link-local addresses", zap.Error(err)) + } + } + } +} + +func (a *Interface) OnPeerAdded(p *core.Peer) { + logger := a.logger.With(zap.Any("peer", p.PublicKey())) + + // Add default link-local address as allowed IP + ipV4 := p.PublicKey().IPv4Address() + ipV6 := p.PublicKey().IPv6Address() + + ipV4.Mask = net.CIDRMask(32, 32) + ipV6.Mask = net.CIDRMask(128, 128) + + if err := p.AddAllowedIP(ipV4); err != nil { + logger.Error("Failed to add link-local IPv4 address to AllowedIPs", zap.Error(err)) + } + + if err := p.AddAllowedIP(ipV6); err != nil { + logger.Error("Failed to add link-local IPv6 address to AllowedIPs", zap.Error(err)) + } + + p.OnModified(a) +} + +func (a *Interface) OnPeerRemoved(p *core.Peer) {} + +func (a *Interface) OnPeerModified(p *core.Peer, old *wgtypes.Peer, mod core.PeerModifier, ipsAdded, ipsRemoved []net.IPNet) { +} diff --git a/pkg/daemon/feature/cfgsync/cfgsync.go b/pkg/daemon/feature/cfgsync/cfgsync.go new file mode 100644 index 00000000..80344605 --- /dev/null +++ b/pkg/daemon/feature/cfgsync/cfgsync.go @@ -0,0 +1,128 @@ +// Package cfgsync synchronizes existing WireGuard configuration files with the kernel/userspace WireGuard device. +package cfgsync + +import ( + "errors" + "fmt" + "os" + "path" + "path/filepath" + "strings" + + "github.com/fsnotify/fsnotify" + "github.com/stv0g/cunicu/pkg/daemon" + "github.com/stv0g/cunicu/pkg/device" + "github.com/stv0g/cunicu/pkg/wg" + "go.uber.org/zap" +) + +func init() { + daemon.Features["cfgsync"] = &daemon.FeaturePlugin{ + New: New, + Description: "Config-file synchronization", + Order: 20, + } +} + +// Interface synchronizes the WireGuard device configuration with an on-disk configuration file. +type Interface struct { + *daemon.Interface + + path string + + logger *zap.Logger +} + +// New creates a new Syncer +func New(i *daemon.Interface) (daemon.Feature, error) { + if !i.Settings.ConfigSync.Enabled { + return nil, nil + } + + cs := &Interface{ + Interface: i, + path: filepath.Join(wg.ConfigPath, fmt.Sprintf("%s.conf", i.Name())), + logger: zap.L().Named("cfgsync").With(zap.String("intf", i.Name())), + } + + if err := i.SyncConfig(cs.path); err != nil && !errors.Is(err, os.ErrNotExist) { + cs.logger.Fatal("Failed to sync interface configuration", + zap.Error(err), + zap.String("config_file", cs.path)) + } + + i.OnModified(cs) + + return cs, nil +} + +func (cs *Interface) Start() error { + cs.logger.Info("Started configuration file synchronization") + + return nil +} + +func (cs *Interface) Close() error { + return nil +} + +func (cs *Interface) Sync() error { + des, err := os.ReadDir(wg.ConfigPath) + if err != nil { + return fmt.Errorf("failed to list config files in '%s': %w", wg.ConfigPath, err) + } + + for _, de := range des { + cs.handleFsnotifyEvent(fsnotify.Event{ + Name: filepath.Join(wg.ConfigPath, de.Name()), + Op: fsnotify.Write, + }) + } + + return nil +} + +func (cs *Interface) handleFsnotifyEvent(event fsnotify.Event) { + cfg := event.Name + filename := path.Base(cfg) + extension := path.Ext(filename) + name := strings.TrimSuffix(filename, extension) + + if extension != ".conf" || !cs.Daemon.Config.InterfaceFilter(name) { + return + } + + i := cs.Daemon.InterfaceByName(name) + + if event.Op&(fsnotify.Create|fsnotify.Write) != 0 { + if i == nil { + var err error + if _, err = device.NewDevice(name, cs.Settings.WireGuard.UserSpace); err != nil { + cs.logger.Error("Failed to create new device", + zap.Error(err), + zap.String("config_file", cfg)) + } + } else { + if err := i.SyncConfig(cfg); err != nil { + cs.logger.Error("Failed to sync interface configuration", + zap.Error(err), + zap.String("config_file", cfg)) + } + } + + } else if event.Op&(fsnotify.Remove) != 0 { + if i == nil { + cs.logger.Warn("Ignoring unknown interface") + return + } + + // TODO: Do we really want to delete devices if their config file vanish? + // Maybe make this configurable? + if err := i.KernelDevice.Close(); err != nil { + cs.logger.Error("Failed to close interface", zap.Error(err)) + } + } else if event.Op&(fsnotify.Rename) != 0 { + // TODO: This is not supported yet + cs.logger.Warn("We do not support tracking renamed WireGuard configuration files yet") + } +} diff --git a/pkg/daemon/feature/cfgsync/handlers.go b/pkg/daemon/feature/cfgsync/handlers.go new file mode 100644 index 00000000..e0149eef --- /dev/null +++ b/pkg/daemon/feature/cfgsync/handlers.go @@ -0,0 +1,9 @@ +package cfgsync + +import ( + "github.com/stv0g/cunicu/pkg/core" + "github.com/stv0g/cunicu/pkg/wg" +) + +func (cs *Interface) OnInterfaceModified(i *core.Interface, old *wg.Device, m core.InterfaceModifier) { +} diff --git a/pkg/daemon/feature/epdisc/epdisc.go b/pkg/daemon/feature/epdisc/epdisc.go new file mode 100644 index 00000000..ff325b6a --- /dev/null +++ b/pkg/daemon/feature/epdisc/epdisc.go @@ -0,0 +1,262 @@ +// Package epdisc implements endpoint (EP) discovery using Interactive Connection Establishment (ICE). +package epdisc + +import ( + "errors" + "fmt" + "net" + + "github.com/pion/ice/v2" + "github.com/pion/stun" + "go.uber.org/zap" + + "github.com/stv0g/cunicu/pkg/core" + "github.com/stv0g/cunicu/pkg/crypto" + "github.com/stv0g/cunicu/pkg/daemon" + "github.com/stv0g/cunicu/pkg/daemon/feature/epdisc/proxy" + "github.com/stv0g/cunicu/pkg/device" + + errorsx "github.com/stv0g/cunicu/pkg/errors" + icex "github.com/stv0g/cunicu/pkg/ice" + + protoepdisc "github.com/stv0g/cunicu/pkg/proto/feature/epdisc" +) + +func init() { + daemon.Features["epdisc"] = &daemon.FeaturePlugin{ + New: New, + Description: "Endpoint discovery", + Order: 50, + } +} + +type Interface struct { + *daemon.Interface + + Discovery *Interface + + nat *proxy.NAT + + natRule *proxy.NATRule + natRuleSrflx *proxy.NATRule + + udpMux ice.UDPMux + udpMuxSrflx ice.UniversalUDPMux + + udpMuxPort int + udpMuxSrflxPort int + + Peers map[*core.Peer]*Peer + + onConnectionStateChange []OnConnectionStateHandler + + logger *zap.Logger +} + +func New(i *daemon.Interface) (daemon.Feature, error) { + if !i.Settings.EndpointDisc.Enabled { + return nil, nil + } + + e := &Interface{ + Interface: i, + Peers: map[*core.Peer]*Peer{}, + + onConnectionStateChange: []OnConnectionStateHandler{}, + + logger: zap.L().Named("epdisc").With(zap.String("intf", i.Name())), + } + + // Create per-interface UDPMux + var err error + + if e.udpMux, e.udpMuxPort, err = proxy.CreateUDPMux(); err != nil && !errors.Is(err, errorsx.ErrNotSupported) { + return nil, fmt.Errorf("failed to setup host UDP mux: %w", err) + } + + if e.udpMuxSrflx, e.udpMuxSrflxPort, err = proxy.CreateUniversalUDPMux(); err != nil && !errors.Is(err, errorsx.ErrNotSupported) { + return nil, fmt.Errorf("failed to setup srflx UDP mux: %w", err) + } + + e.logger.Info("Created UDP muxes", + zap.Int("port-host", e.udpMuxPort), + zap.Int("port-srflx", e.udpMuxSrflxPort)) + + // Setup Netfilter PAT for non-userspace devices + if _, ok := i.KernelDevice.(*device.UserDevice); !ok { + // Setup NAT + ident := fmt.Sprintf("cunicu-if%d", i.KernelDevice.Index()) + if e.nat, err = proxy.NewNAT(ident); err != nil && !errors.Is(err, errorsx.ErrNotSupported) { + return nil, fmt.Errorf("failed to setup NAT: %w", err) + } + + // Setup DNAT redirects (STUN ports -> WireGuard listen ports) + if err := e.SetupRedirects(); err != nil { + return nil, fmt.Errorf("failed to setup redirects: %w", err) + } + } + + i.OnModified(e) + + return e, nil +} + +func (e *Interface) Start() error { + e.logger.Info("Started endpoint discovery") + + return nil +} + +func (e *Interface) Close() error { + // First switch all sessions to closing so they do not get restarted + for _, p := range e.Peers { + p.setConnectionState(icex.ConnectionStateClosing) + } + + for _, p := range e.Peers { + if err := p.Close(); err != nil { + return fmt.Errorf("failed to close peer: %w", err) + } + } + + if e.nat != nil { + if err := e.nat.Close(); err != nil { + return fmt.Errorf("failed to de-initialize NAT: %w", err) + } + } + + if err := e.udpMux.Close(); err != nil { + return fmt.Errorf("failed to do-initialize UDP mux: %w", err) + } + + if err := e.udpMuxSrflx.Close(); err != nil { + return fmt.Errorf("failed to do-initialize srflx UDP mux: %w", err) + } + + return nil +} + +func (e *Interface) Marshal() *protoepdisc.Interface { + is := &protoepdisc.Interface{ + MuxPort: uint32(e.udpMuxPort), + MuxSrflxPort: uint32(e.udpMuxSrflxPort), + } + + if e.nat != nil { + is.NatType = protoepdisc.NATType_NAT_NFTABLES + } + + return is +} + +func (e *Interface) UpdateRedirects() error { + // Userspace devices need no redirects + if e.nat == nil { + return nil + } + + // Delete old rules if presetn + if e.natRule != nil { + if err := e.natRule.Delete(); err != nil { + return fmt.Errorf("failed to delete rule: %w", err) + } + } + + if e.natRuleSrflx != nil { + if err := e.natRuleSrflx.Delete(); err != nil { + return fmt.Errorf("failed to delete rule: %w", err) + } + } + + return e.SetupRedirects() +} + +func (e *Interface) SetupRedirects() error { + var err error + + // Redirect non-STUN traffic directed at UDP muxes to WireGuard interface via in-kernel port redirect / NAT + if e.natRule, err = e.nat.RedirectNonSTUN(e.udpMuxPort, e.ListenPort); err != nil { + return fmt.Errorf("failed to setup port redirect for server reflexive UDP mux: %w", err) + } + + if e.natRuleSrflx, err = e.nat.RedirectNonSTUN(e.udpMuxSrflxPort, e.ListenPort); err != nil { + return fmt.Errorf("failed to setup port redirect for server reflexive UDP mux: %w", err) + } + + return nil +} + +func (e *Interface) PeerByPublicKey(pk crypto.Key) *Peer { + if cp, ok := e.Interface.Peers[pk]; ok { + return e.Peers[cp] + } + + return nil +} + +// Endpoint returns the best guess about our own endpoint +func (e *Interface) Endpoint() (*net.UDPAddr, error) { + var ep *net.UDPAddr + var bestPrio uint32 = 0 + + for _, p := range e.Peers { + cs, err := p.agent.GetLocalCandidates() + if err != nil { + return nil, err + } + + for _, c := range cs { + switch c.Type() { + case ice.CandidateTypeHost, ice.CandidateTypeServerReflexive: + if !c.NetworkType().IsUDP() { + continue + } + + if c.Priority() > bestPrio { + bestPrio = c.Priority() + ep = &net.UDPAddr{ + IP: net.ParseIP(c.Address()), + Port: c.Port(), + } + } + } + } + } + + // No connected peers? Initiate a STUN binding request ourself.. + if ep == nil { + c, err := stun.Dial("tcp", "stun.cunicu.li:3478") + if err != nil { + panic(err) + } + + // Building binding request with random transaction id. + message := stun.MustBuild(stun.TransactionID, stun.BindingRequest) + + var ip net.IP + + // Sending request to STUN server, waiting for response message. + if err := c.Do(message, func(res stun.Event) { + if res.Error != nil { + panic(res.Error) + } + + // Decoding XOR-MAPPED-ADDRESS attribute from message. + var xorAddr stun.XORMappedAddress + if err := xorAddr.GetFrom(res.Message); err != nil { + panic(err) + } + + ip = xorAddr.IP + }); err != nil { + return nil, err + } + + ep = &net.UDPAddr{ + IP: ip, + Port: e.ListenPort, + } + } + + return ep, nil +} diff --git a/pkg/daemon/feature/epdisc/handlers.go b/pkg/daemon/feature/epdisc/handlers.go new file mode 100644 index 00000000..be41f0c9 --- /dev/null +++ b/pkg/daemon/feature/epdisc/handlers.go @@ -0,0 +1,88 @@ +package epdisc + +import ( + "context" + "net" + + "go.uber.org/zap" + "golang.zx2c4.com/wireguard/wgctrl/wgtypes" + + "github.com/stv0g/cunicu/pkg/core" + "github.com/stv0g/cunicu/pkg/crypto" + "github.com/stv0g/cunicu/pkg/daemon/feature/epdisc/proxy" + "github.com/stv0g/cunicu/pkg/wg" + + icex "github.com/stv0g/cunicu/pkg/ice" +) + +type OnConnectionStateHandler interface { + OnConnectionStateChange(p *Peer, new, prev icex.ConnectionState) +} + +func (e *Interface) OnConnectionStateChange(h OnConnectionStateHandler) { + e.onConnectionStateChange = append(e.onConnectionStateChange, h) +} + +func (e *Interface) OnInterfaceModified(ci *core.Interface, old *wg.Device, m core.InterfaceModifier) { + if m.Is(core.InterfaceModifiedListenPort) { + if err := e.UpdateRedirects(); err != nil { + e.logger.Error("Failed to update DPAT redirects", zap.Error(err)) + } + } + + for _, p := range e.Peers { + if m.Is(core.InterfaceModifiedListenPort) { + if kproxy, ok := p.proxy.(*proxy.KernelProxy); ok { + if err := kproxy.UpdateListenPort(ci.ListenPort); err != nil { + e.logger.Error("Failed to update SPAT redirect", zap.Error(err)) + } + } + } + + if m.Is(core.InterfaceModifiedPrivateKey) { + skOld := crypto.Key(old.PrivateKey) + if err := p.Resubscribe(context.Background(), skOld); err != nil { + e.logger.Error("Failed to update subscription", zap.Error(err)) + } + } + } +} + +func (e *Interface) OnPeerAdded(cp *core.Peer) { + p, err := NewPeer(cp, e) + if err != nil { + e.logger.Error("Failed to initialize ICE peer", zap.Error(err)) + return + } + + e.Peers[cp] = p +} + +func (e *Interface) OnPeerRemoved(cp *core.Peer) { + p, ok := e.Peers[cp] + if !ok { + return + } + + if err := p.Close(); err != nil { + e.logger.Error("Failed to de-initialize ICE peer", zap.Error(err)) + } + + delete(e.Peers, cp) +} + +func (e *Interface) OnPeerModified(cp *core.Peer, old *wgtypes.Peer, m core.PeerModifier, ipsAdded, ipsRemoved []net.IPNet) { + p := e.Peers[cp] + + // TODO: Handle changed endpoint addresses + // What do we do when they have been changed externally? + if m.Is(core.PeerModifiedEndpoint) { + // Check if change was external + epNew := p.Endpoint + epExpected := p.lastEndpoint + + if (epExpected != nil && epNew != nil) && (!epNew.IP.Equal(epExpected.IP) || epNew.Port != epExpected.Port) { + e.logger.Warn("Endpoint address has been changed externally. This is breaks the connection and is most likely not desired.") + } + } +} diff --git a/pkg/feat/epdisc/peer.go b/pkg/daemon/feature/epdisc/peer.go similarity index 91% rename from pkg/feat/epdisc/peer.go rename to pkg/daemon/feature/epdisc/peer.go index ad2ad6ad..60de18de 100644 --- a/pkg/feat/epdisc/peer.go +++ b/pkg/daemon/feature/epdisc/peer.go @@ -14,23 +14,23 @@ import ( "github.com/stv0g/cunicu/pkg/config" "github.com/stv0g/cunicu/pkg/core" "github.com/stv0g/cunicu/pkg/crypto" + "github.com/stv0g/cunicu/pkg/daemon/feature/epdisc/proxy" "github.com/stv0g/cunicu/pkg/device" - "github.com/stv0g/cunicu/pkg/feat/epdisc/proxy" "github.com/stv0g/cunicu/pkg/log" "github.com/stv0g/cunicu/pkg/signaling" "github.com/stv0g/cunicu/pkg/util" - icex "github.com/stv0g/cunicu/pkg/feat/epdisc/ice" + icex "github.com/stv0g/cunicu/pkg/ice" proto "github.com/stv0g/cunicu/pkg/proto" - protoepdisc "github.com/stv0g/cunicu/pkg/proto/feat/epdisc" + protoepdisc "github.com/stv0g/cunicu/pkg/proto/feature/epdisc" ) type Peer struct { *core.Peer - Interface *Interface + Discovery *Interface - config *config.Config + config *config.InterfaceSettings agent *ice.Agent backend signaling.Backend proxy proxy.Proxy @@ -46,21 +46,17 @@ type Peer struct { logger *zap.Logger } -func NewPeer(cp *core.Peer, i *Interface) (*Peer, error) { +func NewPeer(cp *core.Peer, e *Interface) (*Peer, error) { var err error p := &Peer{ Peer: cp, - Interface: i, - - backend: i.Discovery.backend, - config: i.Discovery.config, + Discovery: e, signalingMessages: make(chan *signaling.Message, 32), connectionStateChanges: make(chan icex.ConnectionState, 32), - logger: zap.L().Named("ice.peer").With( - zap.String("intf", i.Name()), + logger: e.logger.Named("peer").With( zap.Any("peer", cp.PublicKey()), ), } @@ -76,12 +72,12 @@ func NewPeer(cp *core.Peer, i *Interface) (*Peer, error) { p.logger.Info("Subscribed to messages from peer", zap.Any("kp", kp)) // Setup proxy - if dev, ok := i.KernelDevice.(*device.UserDevice); ok { + if dev, ok := e.KernelDevice.(*device.UserDevice); ok { if p.proxy, err = proxy.NewUserBindProxy(dev.Bind); err != nil { return nil, fmt.Errorf("failed to setup proxy: %w", err) } - } else if i.nat != nil { - if p.proxy, err = proxy.NewKernelProxy(i.nat, cp.Interface.ListenPort); err != nil { + } else if e.nat != nil { + if p.proxy, err = proxy.NewKernelProxy(e.nat, cp.Interface.ListenPort); err != nil { return nil, fmt.Errorf("failed to setup proxy: %w", err) } } else { @@ -214,9 +210,8 @@ func (p *Peer) createAgent() error { p.logger.Info("Creating new agent") // Prepare ICE agent configuration - icfg := p.config.InterfaceSettings(p.Interface.Name()) pk := p.Interface.PublicKey() - acfg, err := icfg.AgentConfig(context.Background(), &pk) + acfg, err := p.config.AgentConfig(context.Background(), &pk) if err != nil { return fmt.Errorf("failed to generate ICE agent configuration: %w", err) } @@ -224,11 +219,11 @@ func (p *Peer) createAgent() error { // Do not use WireGuard interfaces for ICE origFilter := acfg.InterfaceFilter acfg.InterfaceFilter = func(name string) bool { - return origFilter(name) && p.Interface.Discovery.watcher.InterfaceByName(name) == nil + return origFilter(name) && p.Discovery.Daemon.InterfaceByName(name) == nil } - acfg.UDPMux = p.Interface.udpMux - acfg.UDPMuxSrflx = p.Interface.udpMuxSrflx + acfg.UDPMux = p.Discovery.udpMux + acfg.UDPMuxSrflx = p.Discovery.udpMuxSrflx acfg.LoggerFactory = log.NewPionLoggerFactory(p.logger) p.credentials = protoepdisc.NewCredentials() @@ -358,7 +353,7 @@ func (p *Peer) setConnectionState(new icex.ConnectionState) icex.ConnectionState zap.String("new", strings.ToLower(new.String())), zap.String("previous", strings.ToLower(prev.String()))) - for _, h := range p.Interface.Discovery.onConnectionStateChange { + for _, h := range p.Discovery.onConnectionStateChange { h.OnConnectionStateChange(p, new, prev) } @@ -376,7 +371,7 @@ func (p *Peer) setConnectionStateIf(prev, new icex.ConnectionState) bool { zap.String("new", strings.ToLower(new.String())), zap.String("previous", strings.ToLower(prev.String()))) - for _, h := range p.Interface.Discovery.onConnectionStateChange { + for _, h := range p.Discovery.onConnectionStateChange { h.OnConnectionStateChange(p, new, prev) } } diff --git a/pkg/feat/epdisc/peer_handlers.go b/pkg/daemon/feature/epdisc/peer_handlers.go similarity index 97% rename from pkg/feat/epdisc/peer_handlers.go rename to pkg/daemon/feature/epdisc/peer_handlers.go index 85893cb5..a8cdeef9 100644 --- a/pkg/feat/epdisc/peer_handlers.go +++ b/pkg/daemon/feature/epdisc/peer_handlers.go @@ -8,8 +8,8 @@ import ( "github.com/stv0g/cunicu/pkg/signaling" "go.uber.org/zap" - icex "github.com/stv0g/cunicu/pkg/feat/epdisc/ice" - protoepdisc "github.com/stv0g/cunicu/pkg/proto/feat/epdisc" + icex "github.com/stv0g/cunicu/pkg/ice" + protoepdisc "github.com/stv0g/cunicu/pkg/proto/feature/epdisc" ) // onConnectionStateChange is a callback which gets called by the ICE agent diff --git a/pkg/feat/epdisc/proxy/mux.go b/pkg/daemon/feature/epdisc/proxy/mux.go similarity index 100% rename from pkg/feat/epdisc/proxy/mux.go rename to pkg/daemon/feature/epdisc/proxy/mux.go diff --git a/pkg/feat/epdisc/proxy/nat_linux.go b/pkg/daemon/feature/epdisc/proxy/nat_linux.go similarity index 100% rename from pkg/feat/epdisc/proxy/nat_linux.go rename to pkg/daemon/feature/epdisc/proxy/nat_linux.go diff --git a/pkg/feat/epdisc/proxy/nat_others.go b/pkg/daemon/feature/epdisc/proxy/nat_others.go similarity index 100% rename from pkg/feat/epdisc/proxy/nat_others.go rename to pkg/daemon/feature/epdisc/proxy/nat_others.go diff --git a/pkg/feat/epdisc/proxy/proxy.go b/pkg/daemon/feature/epdisc/proxy/proxy.go similarity index 84% rename from pkg/feat/epdisc/proxy/proxy.go rename to pkg/daemon/feature/epdisc/proxy/proxy.go index fc1cef62..9eb56446 100644 --- a/pkg/feat/epdisc/proxy/proxy.go +++ b/pkg/daemon/feature/epdisc/proxy/proxy.go @@ -7,7 +7,7 @@ import ( "github.com/pion/ice/v2" - protoepdisc "github.com/stv0g/cunicu/pkg/proto/feat/epdisc" + protoepdisc "github.com/stv0g/cunicu/pkg/proto/feature/epdisc" ) type Proxy interface { diff --git a/pkg/feat/epdisc/proxy/proxy_kernel.go b/pkg/daemon/feature/epdisc/proxy/proxy_kernel.go similarity index 98% rename from pkg/feat/epdisc/proxy/proxy_kernel.go rename to pkg/daemon/feature/epdisc/proxy/proxy_kernel.go index a47d86b2..5929b02d 100644 --- a/pkg/feat/epdisc/proxy/proxy_kernel.go +++ b/pkg/daemon/feature/epdisc/proxy/proxy_kernel.go @@ -10,7 +10,7 @@ import ( "github.com/pion/ice/v2" "go.uber.org/zap" - epdiscproto "github.com/stv0g/cunicu/pkg/proto/feat/epdisc" + epdiscproto "github.com/stv0g/cunicu/pkg/proto/feature/epdisc" ) const ( diff --git a/pkg/feat/epdisc/proxy/proxy_user.go b/pkg/daemon/feature/epdisc/proxy/proxy_user.go similarity index 95% rename from pkg/feat/epdisc/proxy/proxy_user.go rename to pkg/daemon/feature/epdisc/proxy/proxy_user.go index 45566657..d5e93c4f 100644 --- a/pkg/feat/epdisc/proxy/proxy_user.go +++ b/pkg/daemon/feature/epdisc/proxy/proxy_user.go @@ -11,7 +11,7 @@ import ( "github.com/stv0g/cunicu/pkg/wg" - protoepdisc "github.com/stv0g/cunicu/pkg/proto/feat/epdisc" + protoepdisc "github.com/stv0g/cunicu/pkg/proto/feature/epdisc" ) type UserBindProxy struct { diff --git a/pkg/feat/hooks/exec.go b/pkg/daemon/feature/hooks/exec.go similarity index 92% rename from pkg/feat/hooks/exec.go rename to pkg/daemon/feature/hooks/exec.go index 9ef0cf9d..ec798f03 100644 --- a/pkg/feat/hooks/exec.go +++ b/pkg/daemon/feature/hooks/exec.go @@ -7,15 +7,17 @@ import ( "os/exec" "strings" - "github.com/stv0g/cunicu/pkg/config" - "github.com/stv0g/cunicu/pkg/core" - "github.com/stv0g/cunicu/pkg/feat/epdisc" - icex "github.com/stv0g/cunicu/pkg/feat/epdisc/ice" - "github.com/stv0g/cunicu/pkg/wg" "go.uber.org/zap" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" + + "github.com/stv0g/cunicu/pkg/config" + "github.com/stv0g/cunicu/pkg/core" + "github.com/stv0g/cunicu/pkg/daemon/feature/epdisc" + "github.com/stv0g/cunicu/pkg/wg" + + icex "github.com/stv0g/cunicu/pkg/ice" ) type ExecHook struct { @@ -24,6 +26,19 @@ type ExecHook struct { logger *zap.Logger } +func (h *Interface) NewExecHook(cfg *config.ExecHookSetting) { + hk := &ExecHook{ + ExecHookSetting: cfg, + logger: h.logger.Named("exec").With( + zap.String("command", cfg.Command), + ), + } + + h.logger.Debug("Created new exec hook", zap.Any("hook", hk)) + + h.registerHook(hk) +} + func (h *ExecHook) run(msg proto.Message, args ...any) { allArgs := []string{} allArgs = append(allArgs, h.Args...) diff --git a/pkg/daemon/feature/hooks/hooks.go b/pkg/daemon/feature/hooks/hooks.go new file mode 100644 index 00000000..d7f9e335 --- /dev/null +++ b/pkg/daemon/feature/hooks/hooks.go @@ -0,0 +1,67 @@ +package hooks + +import ( + "github.com/stv0g/cunicu/pkg/config" + "github.com/stv0g/cunicu/pkg/core" + "github.com/stv0g/cunicu/pkg/daemon" + "github.com/stv0g/cunicu/pkg/daemon/feature/epdisc" + "go.uber.org/zap" +) + +func init() { + daemon.Features["hooks"] = &daemon.FeaturePlugin{ + New: New, + Description: "Hooks", + Order: 70, + } +} + +type Hook interface { + core.AllHandler + epdisc.OnConnectionStateHandler +} + +type Interface struct { + *daemon.Interface + + logger *zap.Logger +} + +func New(i *daemon.Interface) (daemon.Feature, error) { + if len(i.Settings.Hooks) == 0 { + return nil, nil + } + + h := &Interface{ + Interface: i, + logger: zap.L().Named("hooks").With(zap.String("intf", i.Name())), + } + + for _, hk := range i.Settings.Hooks { + switch hk := hk.(type) { + case *config.ExecHookSetting: + h.NewExecHook(hk) + case *config.WebHookSetting: + h.NewWebHook(hk) + } + } + + return h, nil +} + +func (h *Interface) registerHook(j Hook) { + h.Daemon.Watcher.OnAll(j) + + ep := h.Features["epdisc"].(*epdisc.Interface) + ep.OnConnectionStateChange(j) +} + +func (h *Interface) Start() error { + h.logger.Info("Started hooks") + + return nil +} + +func (h *Interface) Close() error { + return nil +} diff --git a/pkg/feat/hooks/marshal.go b/pkg/daemon/feature/hooks/marshal.go similarity index 100% rename from pkg/feat/hooks/marshal.go rename to pkg/daemon/feature/hooks/marshal.go diff --git a/pkg/feat/hooks/web.go b/pkg/daemon/feature/hooks/web.go similarity index 87% rename from pkg/feat/hooks/web.go rename to pkg/daemon/feature/hooks/web.go index 17ec0476..131f4c85 100644 --- a/pkg/feat/hooks/web.go +++ b/pkg/daemon/feature/hooks/web.go @@ -13,12 +13,12 @@ import ( "github.com/stv0g/cunicu/pkg/config" "github.com/stv0g/cunicu/pkg/core" - "github.com/stv0g/cunicu/pkg/feat/epdisc" + "github.com/stv0g/cunicu/pkg/daemon/feature/epdisc" "github.com/stv0g/cunicu/pkg/util/buildinfo" "github.com/stv0g/cunicu/pkg/wg" - icex "github.com/stv0g/cunicu/pkg/feat/epdisc/ice" - hooksproto "github.com/stv0g/cunicu/pkg/proto/feat/hooks" + icex "github.com/stv0g/cunicu/pkg/ice" + hooksproto "github.com/stv0g/cunicu/pkg/proto/feature/hooks" rpcproto "github.com/stv0g/cunicu/pkg/proto/rpc" ) @@ -28,6 +28,19 @@ type WebHook struct { logger *zap.Logger } +func (h *Interface) NewWebHook(cfg *config.WebHookSetting) { + hk := &WebHook{ + WebHookSetting: cfg, + logger: h.logger.Named("web").With( + zap.Any("url", cfg.URL), + ), + } + + h.logger.Debug("Created new web hook", zap.Any("hook", hk)) + + h.registerHook(hk) +} + func (h *WebHook) run(msg proto.Message) { req := &http.Request{ Method: h.Method, diff --git a/pkg/daemon/feature/hsync/handlers.go b/pkg/daemon/feature/hsync/handlers.go new file mode 100644 index 00000000..df3bea9e --- /dev/null +++ b/pkg/daemon/feature/hsync/handlers.go @@ -0,0 +1,32 @@ +package hsync + +import ( + "net" + + "github.com/stv0g/cunicu/pkg/core" + "go.uber.org/zap" + "golang.zx2c4.com/wireguard/wgctrl/wgtypes" +) + +func (hs *Interface) OnPeerAdded(p *core.Peer) { + if err := hs.Sync(); err != nil { + hs.logger.Error("Failed to update hosts file", zap.Error(err)) + } + + p.OnModified(hs) +} + +func (hs *Interface) OnPeerRemoved(p *core.Peer) { + if err := hs.Sync(); err != nil { + hs.logger.Error("Failed to update hosts file", zap.Error(err)) + } +} + +func (hs *Interface) OnPeerModified(p *core.Peer, old *wgtypes.Peer, m core.PeerModifier, ipsAdded, ipsRemoved []net.IPNet) { + // Only update if the name has changed + if m.Is(core.PeerModifiedName) { + if err := hs.Sync(); err != nil { + hs.logger.Error("Failed to update hosts file", zap.Error(err)) + } + } +} diff --git a/pkg/feat/hsync/host.go b/pkg/daemon/feature/hsync/host.go similarity index 100% rename from pkg/feat/hsync/host.go rename to pkg/daemon/feature/hsync/host.go diff --git a/pkg/feat/hsync/hsync.go b/pkg/daemon/feature/hsync/hsync.go similarity index 57% rename from pkg/feat/hsync/hsync.go rename to pkg/daemon/feature/hsync/hsync.go index 577193a5..a5fd7b10 100644 --- a/pkg/feat/hsync/hsync.go +++ b/pkg/daemon/feature/hsync/hsync.go @@ -3,15 +3,13 @@ package hsync import ( "fmt" - "net" "strings" "github.com/stv0g/cunicu/pkg/core" + "github.com/stv0g/cunicu/pkg/daemon" "github.com/stv0g/cunicu/pkg/util" - "github.com/stv0g/cunicu/pkg/watcher" "go.uber.org/zap" "golang.org/x/exp/slices" - "golang.zx2c4.com/wireguard/wgctrl/wgtypes" ) const ( @@ -19,50 +17,61 @@ const ( hostsPath = "/etc/hosts" ) -type HostsSync struct { - domain string - - watcher *watcher.Watcher - logger *zap.Logger +func init() { + daemon.Features["hsync"] = &daemon.FeaturePlugin{ + New: New, + Description: "Hosts synchronization", + Order: 40, + } } -func New(w *watcher.Watcher, d string) *HostsSync { - if d != "" && !strings.HasPrefix(d, ".") { - d = "." + d - } +type Interface struct { + *daemon.Interface - hs := &HostsSync{ - domain: d, - watcher: w, - logger: zap.L().Named("hsync"), - } - - w.OnPeer(hs) - - return hs + logger *zap.Logger } -func (hs *HostsSync) Start() error { +func New(i *daemon.Interface) (daemon.Feature, error) { + if !i.Settings.HostSync.Enabled { + return nil, nil + } + + hs := &Interface{ + Interface: i, + logger: zap.L().Named("hsync").With(zap.String("intf", i.Name())), + } + + i.OnPeer(hs) + + return hs, nil +} + +func (hs *Interface) Start() error { hs.logger.Info("Started /etc/hosts synchronization") return nil } -func (hs *HostsSync) Close() error { +func (hs *Interface) Close() error { return nil } -func (hs *HostsSync) Hosts() []Host { +func (hs *Interface) Hosts() []Host { hosts := []Host{} - hs.watcher.ForEachPeer(func(p *core.Peer) error { + d := hs.Settings.HostSync.Domain + if d != "" && !strings.HasPrefix(d, ".") { + d = "." + d + } + + hs.Daemon.ForEachPeer(func(p *core.Peer) error { // We use a shorted version of the public key as a DNS name here pkName := p.PublicKey().String()[:8] h := Host{ IP: p.PublicKey().IPv6Address().IP, Names: []string{ - pkName + hs.domain, + pkName + d, }, Comment: fmt.Sprintf("%s: ifname=%s, ifindex=%d, pk=%s", hostsCommentPrefix, p.Interface.KernelDevice.Name(), @@ -71,7 +80,7 @@ func (hs *HostsSync) Hosts() []Host { } if p.Name != "" { - h.Names = append(h.Names, p.Name+hs.domain) + h.Names = append(h.Names, p.Name+d) } hosts = append(hosts, h) @@ -82,16 +91,16 @@ func (hs *HostsSync) Hosts() []Host { return hosts } -func (hs *HostsSync) Sync() error { +func (hs *Interface) Sync() error { lines, err := readLines(hostsPath) if err != nil { return fmt.Errorf("failed to read file: %w", err) } // Filter out lines not added by cunīcu - lines = util.FilterSlice(lines, func(line string) bool { + lines = util.SliceFilter(lines, func(line string) bool { h, err := ParseHost(line) - return err != nil || !strings.HasPrefix(h.Comment, hostsCommentPrefix) + return err != nil || !strings.HasPrefix(h.Comment, hostsCommentPrefix) || !strings.Contains(h.Comment, fmt.Sprintf("ifindex=%d", hs.KernelDevice.Index())) }) // Add a separating new line @@ -119,24 +128,3 @@ func (hs *HostsSync) Sync() error { return nil } - -func (hs *HostsSync) OnPeerAdded(p *core.Peer) { - if err := hs.Sync(); err != nil { - hs.logger.Error("Failed to update hosts file", zap.Error(err)) - } -} - -func (hs *HostsSync) OnPeerRemoved(p *core.Peer) { - if err := hs.Sync(); err != nil { - hs.logger.Error("Failed to update hosts file", zap.Error(err)) - } -} - -func (hs *HostsSync) OnPeerModified(p *core.Peer, old *wgtypes.Peer, m core.PeerModifier, ipsAdded, ipsRemoved []net.IPNet) { - // Only update if the name has changed - if m.Is(core.PeerModifiedName) { - if err := hs.Sync(); err != nil { - hs.logger.Error("Failed to update hosts file", zap.Error(err)) - } - } -} diff --git a/pkg/feat/hsync/util.go b/pkg/daemon/feature/hsync/util.go similarity index 100% rename from pkg/feat/hsync/util.go rename to pkg/daemon/feature/hsync/util.go diff --git a/pkg/daemon/feature/pdisc/handlers.go b/pkg/daemon/feature/pdisc/handlers.go new file mode 100644 index 00000000..7ca946ae --- /dev/null +++ b/pkg/daemon/feature/pdisc/handlers.go @@ -0,0 +1,126 @@ +package pdisc + +import ( + "fmt" + "time" + + "github.com/stv0g/cunicu/pkg/core" + "github.com/stv0g/cunicu/pkg/crypto" + "github.com/stv0g/cunicu/pkg/daemon" + pdiscproto "github.com/stv0g/cunicu/pkg/proto/feature/pdisc" + "github.com/stv0g/cunicu/pkg/signaling" + "github.com/stv0g/cunicu/pkg/wg" + "go.uber.org/zap" +) + +func (pd *Interface) OnInterfaceModified(i *core.Interface, old *wg.Device, m core.InterfaceModifier) { + // Ignore interface which do not have a private key yet + if !i.PrivateKey().IsSet() { + return + } + + // Only send an update if the private key changed. + // There are currently no other attributes which would need to be re-announced + if m.Is(core.InterfaceModifiedPrivateKey) { + var pkOld *crypto.Key + if skOld := crypto.Key(old.PrivateKey); skOld.IsSet() { + pk := skOld.PublicKey() + pkOld = &pk + } + + if err := pd.sendPeerDescription(pdiscproto.PeerDescriptionChange_PEER_UPDATE, pkOld); err != nil { + pd.logger.Error("Failed to send peer description", zap.Error(err)) + } + } +} + +func (pd *Interface) OnSignalingMessage(kp *crypto.PublicKeyPair, msg *signaling.Message) { + if msg.Peer != nil { + if i := pd.Daemon.Watcher.InterfaceByPublicKey(kp.Theirs); i != nil { + // Received our own peer description. Ignoring... + return + } + + if err := pd.OnPeerDescription(msg.Peer); err != nil { + pd.logger.Error("Failed to handle peer description", zap.Error(err), zap.Any("pd", msg.Peer)) + } + } +} + +func (pd *Interface) OnPeerDescription(pdisc *pdiscproto.PeerDescription) error { + pk, err := crypto.ParseKeyBytes(pdisc.PublicKey) + if err != nil { + return fmt.Errorf("invalid public key: %w", err) + } + + if !pd.isAccepted(pk) { + pd.logger.Warn("Ignoring non-whitelisted peer", zap.Any("peer", pk)) + return nil + } + + p := pd.Daemon.PeerByPublicKey(&pk) + + switch pdisc.Change { + case pdiscproto.PeerDescriptionChange_PEER_ADD: + if p != nil { + pd.logger.Warn("Peer already exists. Updating it instead") + pdisc.Change = pdiscproto.PeerDescriptionChange_PEER_UPDATE + } + + case pdiscproto.PeerDescriptionChange_PEER_UPDATE: + if p == nil { + pd.logger.Warn("Peer does not exist exists yet. Adding it instead") + pdisc.Change = pdiscproto.PeerDescriptionChange_PEER_ADD + } + + default: + if p == nil { + return fmt.Errorf("cant remove non-existing peer") + } + } + + cfg := pdisc.Config() + + switch pdisc.Change { + case pdiscproto.PeerDescriptionChange_PEER_ADD: + if err := pd.AddPeer(&cfg); err != nil { + return fmt.Errorf("failed to add peer: %w", err) + } + + case pdiscproto.PeerDescriptionChange_PEER_UPDATE: + if pdisc.PublicKeyNew != nil { + // Remove old peer + if err := p.Interface.RemovePeer(pk); err != nil { + return fmt.Errorf("failed to remove peer: %w", err) + } + + // Re-add peer with new public key + if err := p.Interface.AddPeer(&cfg); err != nil { + return fmt.Errorf("failed to add peer: %w", err) + } + } else { + if err := p.Interface.UpdatePeer(&cfg); err != nil { + return fmt.Errorf("failed to remove peer: %w", err) + } + } + + case pdiscproto.PeerDescriptionChange_PEER_REMOVE: + if err := p.Interface.RemovePeer(pk); err != nil { + return fmt.Errorf("failed to remove peer: %w", err) + } + } + + // Re-announce ourself in case this is a new peer we did not knew already + if p == nil { + // TODO: Check if delay is really necessary + time.AfterFunc(1*time.Second, func() { + if err := pd.Daemon.ForEachInterface(func(i *daemon.Interface) error { + return pd.sendPeerDescription(pdiscproto.PeerDescriptionChange_PEER_ADD, nil) + }); err != nil { + pd.logger.Error("Failed to send peer description", zap.Error(err)) + } + }) + } + + return nil +} diff --git a/pkg/daemon/feature/pdisc/pdisc.go b/pkg/daemon/feature/pdisc/pdisc.go new file mode 100644 index 00000000..d29ad6fb --- /dev/null +++ b/pkg/daemon/feature/pdisc/pdisc.go @@ -0,0 +1,163 @@ +// Package pdisc implements peer discovery based on a shared community passphrase. +package pdisc + +import ( + "context" + "fmt" + "net" + + "go.uber.org/zap" + + "github.com/stv0g/cunicu/pkg/crypto" + "github.com/stv0g/cunicu/pkg/daemon" + "github.com/stv0g/cunicu/pkg/signaling" + "github.com/stv0g/cunicu/pkg/util" + "github.com/stv0g/cunicu/pkg/util/buildinfo" + + pdiscproto "github.com/stv0g/cunicu/pkg/proto/feature/pdisc" +) + +func init() { + daemon.Features["pdisc"] = &daemon.FeaturePlugin{ + New: New, + Description: "Peer discovery", + Order: 60, + } +} + +type Interface struct { + *daemon.Interface + + whitelistMap map[crypto.Key]any + blacklistMap map[crypto.Key]any + + logger *zap.Logger +} + +func New(i *daemon.Interface) (daemon.Feature, error) { + if !i.Settings.PeerDisc.Enabled || !crypto.Key(i.Settings.PeerDisc.Community).IsSet() { + return nil, nil + } + + pd := &Interface{ + Interface: i, + whitelistMap: map[crypto.Key]any{}, + blacklistMap: map[crypto.Key]any{}, + logger: zap.L().Named("pdisc").With(zap.String("intf", i.Name())), + } + + for _, k := range pd.Settings.PeerDisc.Whitelist { + pd.whitelistMap[crypto.Key(k)] = nil + } + + for _, k := range pd.Settings.PeerDisc.Blacklist { + pd.blacklistMap[crypto.Key(k)] = nil + } + + if err := pd.sendPeerDescription(pdiscproto.PeerDescriptionChange_PEER_ADD, nil); err != nil { + pd.logger.Error("Failed to send peer description", zap.Error(err)) + } + + i.OnModified(pd) + + return pd, nil +} + +func (pd *Interface) Start() error { + pd.logger.Info("Started peer discovery") + + // Subscribe to peer updates + // TODO: Support per-interface communities + + kp := &crypto.KeyPair{ + Ours: crypto.Key(pd.Settings.PeerDisc.Community), + Theirs: signaling.AnyKey, + } + if _, err := pd.Daemon.Backend.Subscribe(context.Background(), kp, pd); err != nil { + return fmt.Errorf("failed to subscribe on peer discovery channel: %w", err) + } + + return nil +} + +func (pd *Interface) Close() error { + if err := pd.sendPeerDescription(pdiscproto.PeerDescriptionChange_PEER_REMOVE, nil); err != nil { + pd.logger.Error("Failed to send peer description", zap.Error(err)) + } + + return nil +} + +func (pd *Interface) sendPeerDescription(chg pdiscproto.PeerDescriptionChange, pkOld *crypto.Key) error { + // Gather all allowed IPs for this interface + allowedIPs := []net.IPNet{} + allowedIPs = append(allowedIPs, pd.Settings.AutoConfig.Addresses...) + + if pd.Settings.AutoConfig.LinkLocalAddresses { + allowedIPs = append(allowedIPs, + pd.PublicKey().IPv6Address(), + pd.PublicKey().IPv4Address(), + ) + } + + // Only the /32 or /128 for local addresses + for _, allowedIP := range allowedIPs { + for i := range allowedIP.Mask { + allowedIP.Mask[i] = 0xff + } + } + + // But networks are taken in full + allowedIPs = append(allowedIPs, pd.Settings.PeerDisc.Networks...) + + d := &pdiscproto.PeerDescription{ + Change: chg, + Hostname: pd.Settings.PeerDisc.Hostname, + AllowedIps: util.SliceString(allowedIPs), + BuildInfo: buildinfo.BuildInfo(), + } + + if pkOld != nil { + if d.Change != pdiscproto.PeerDescriptionChange_PEER_UPDATE { + return fmt.Errorf("can not change public key in non-update message") + } + + d.PublicKeyNew = pd.PublicKey().Bytes() + d.PublicKey = pkOld.Bytes() + } else { + d.PublicKey = pd.PublicKey().Bytes() + } + + msg := &signaling.Message{ + Peer: d, + } + + kp := &crypto.KeyPair{ + Ours: pd.PrivateKey(), + Theirs: crypto.Key(pd.Settings.PeerDisc.Community).PublicKey(), + } + + if err := pd.Daemon.Backend.Publish(context.Background(), kp, msg); err != nil { + return err + } + + pd.logger.Debug("Send peer description", zap.Any("description", d)) + + return nil +} + +func (pd *Interface) isAccepted(pk crypto.Key) bool { + if pd.whitelistMap != nil { + if _, ok := pd.whitelistMap[pk]; !ok { + return false + } + } + + if pd.blacklistMap != nil { + if _, ok := pd.whitelistMap[pk]; ok { + return false + } + } + + return true +} diff --git a/pkg/feat/rtsync/rtsync.go b/pkg/daemon/feature/rtsync/handlers.go similarity index 57% rename from pkg/feat/rtsync/rtsync.go rename to pkg/daemon/feature/rtsync/handlers.go index 187a6543..36f96703 100644 --- a/pkg/feat/rtsync/rtsync.go +++ b/pkg/daemon/feature/rtsync/handlers.go @@ -1,4 +1,3 @@ -// Package rtsync synchronizes the kernel routing table with the AllowedIPs of each WireGuard peer package rtsync import ( @@ -8,52 +7,11 @@ import ( "syscall" "github.com/stv0g/cunicu/pkg/core" - "github.com/stv0g/cunicu/pkg/watcher" "go.uber.org/zap" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" ) -type RouteSync struct { - gwMap map[netip.Addr]*core.Peer - table int - - stop chan struct{} - - logger *zap.Logger -} - -func New(w *watcher.Watcher, table int, watch bool) *RouteSync { - rs := &RouteSync{ - gwMap: map[netip.Addr]*core.Peer{}, - table: table, - stop: make(chan struct{}), - logger: zap.L().Named("rtsync"), - } - - w.OnPeer(rs) - - if watch { - go rs.watchKernel() - } - - return rs -} - -func (rs *RouteSync) Start() error { - rs.logger.Info("Started route synchronization") - - return nil -} - -func (rs *RouteSync) Close() error { - // TODO: Remove Kernel routes added by us - - close(rs.stop) - - return nil -} - -func (rs *RouteSync) OnPeerAdded(p *core.Peer) { +func (rs *Interface) OnPeerAdded(p *core.Peer) { pk := p.PublicKey() gwV4, ok1 := netip.AddrFromSlice(pk.IPv4Address().IP) gwV6, ok2 := netip.AddrFromSlice(pk.IPv6Address().IP) @@ -65,9 +23,11 @@ func (rs *RouteSync) OnPeerAdded(p *core.Peer) { rs.gwMap[gwV6] = p rs.syncKernel() // Initial sync + + p.OnModified(rs) } -func (rs *RouteSync) OnPeerRemoved(p *core.Peer) { +func (rs *Interface) OnPeerRemoved(p *core.Peer) { pk := p.PublicKey() gwV4, ok1 := netip.AddrFromSlice(pk.IPv4Address().IP) gwV6, ok2 := netip.AddrFromSlice(pk.IPv6Address().IP) @@ -87,9 +47,9 @@ func (rs *RouteSync) OnPeerRemoved(p *core.Peer) { } } -func (rs *RouteSync) OnPeerModified(p *core.Peer, old *wgtypes.Peer, m core.PeerModifier, ipsAdded, ipsRemoved []net.IPNet) { +func (rs *Interface) OnPeerModified(p *core.Peer, old *wgtypes.Peer, m core.PeerModifier, ipsAdded, ipsRemoved []net.IPNet) { for _, dst := range ipsAdded { - if err := p.Interface.KernelDevice.AddRoute(dst, rs.table); err != nil { + if err := p.Interface.KernelDevice.AddRoute(dst, rs.Settings.RouteSync.Table); err != nil { rs.logger.Error("Failed to add route", zap.Error(err)) continue } @@ -101,7 +61,7 @@ func (rs *RouteSync) OnPeerModified(p *core.Peer, old *wgtypes.Peer, m core.Peer } for _, dst := range ipsRemoved { - if err := p.Interface.KernelDevice.DeleteRoute(dst, rs.table); err != nil && !errors.Is(err, syscall.ESRCH) { + if err := p.Interface.KernelDevice.DeleteRoute(dst, rs.Settings.RouteSync.Table); err != nil && !errors.Is(err, syscall.ESRCH) { rs.logger.Error("Failed to delete route", zap.Error(err)) continue } diff --git a/pkg/daemon/feature/rtsync/rtsync.go b/pkg/daemon/feature/rtsync/rtsync.go new file mode 100644 index 00000000..5de6f24d --- /dev/null +++ b/pkg/daemon/feature/rtsync/rtsync.go @@ -0,0 +1,68 @@ +// Package rtsync synchronizes the kernel routing table with the AllowedIPs of each WireGuard peer +package rtsync + +import ( + "net/netip" + + "github.com/stv0g/cunicu/pkg/core" + "github.com/stv0g/cunicu/pkg/daemon" + "go.uber.org/zap" +) + +func init() { + daemon.Features["rtsync"] = &daemon.FeaturePlugin{ + New: New, + Description: "Route synchronization", + Order: 30, + } +} + +type Interface struct { + *daemon.Interface + + gwMap map[netip.Addr]*core.Peer + + stop chan struct{} + + logger *zap.Logger +} + +func New(i *daemon.Interface) (daemon.Feature, error) { + if !i.Settings.RouteSync.Enabled { + return nil, nil + } + + rs := &Interface{ + Interface: i, + gwMap: map[netip.Addr]*core.Peer{}, + stop: make(chan struct{}), + logger: zap.L().Named("rtsync").With(zap.String("intf", i.Name())), + } + + i.OnPeer(rs) + // i.Daemon.Config.OnInterfaceChanged("rtsync", rs) + + if i.Settings.RouteSync.Watch { + go rs.watchKernel() + } + + return rs, nil +} + +func (rs *Interface) Start() error { + rs.logger.Info("Started route synchronization") + + return nil +} + +func (rs *Interface) Close() error { + // TODO: Remove Kernel routes added by us + + close(rs.stop) + + return nil +} + +func (rs *Interface) OnConfigChanged(key string, old, new any) { + rs.logger.Warn("Config changed", zap.String("key", key), zap.Any("old", old), zap.Any("new", new)) +} diff --git a/pkg/feat/rtsync/sync_linux.go b/pkg/daemon/feature/rtsync/sync_linux.go similarity index 85% rename from pkg/feat/rtsync/sync_linux.go rename to pkg/daemon/feature/rtsync/sync_linux.go index 7fc35eeb..225d87d4 100644 --- a/pkg/feat/rtsync/sync_linux.go +++ b/pkg/daemon/feature/rtsync/sync_linux.go @@ -17,7 +17,7 @@ import ( // removeKernel removes all routes from the kernel which have the peers link-local address // configured as their destination -func (s *RouteSync) removeKernel(p *core.Peer) error { +func (rs *Interface) removeKernel(p *core.Peer) error { pk := p.PublicKey() gwV4, ok1 := netip.AddrFromSlice(pk.IPv4Address().IP) gwV6, ok2 := netip.AddrFromSlice(pk.IPv6Address().IP) @@ -27,11 +27,11 @@ func (s *RouteSync) removeKernel(p *core.Peer) error { routes, err := netlink.RouteList(nil, unix.AF_INET6) if err != nil { - s.logger.Error("Failed to get routes from kernel", zap.Error(err)) + rs.logger.Error("Failed to get routes from kernel", zap.Error(err)) } for _, route := range routes { - if route.Table != s.table { + if route.Table != rs.Settings.RouteSync.Table { continue } @@ -41,8 +41,8 @@ func (s *RouteSync) removeKernel(p *core.Peer) error { } if gwV4.Compare(gw) == 0 || gwV6.Compare(gw) == 0 { - if err := p.Interface.KernelDevice.DeleteRoute(*route.Dst, s.table); err != nil && !errors.Is(err, syscall.ESRCH) { - s.logger.Error("Failed to delete route", zap.Error(err)) + if err := p.Interface.KernelDevice.DeleteRoute(*route.Dst, rs.Settings.RouteSync.Table); err != nil && !errors.Is(err, syscall.ESRCH) { + rs.logger.Error("Failed to delete route", zap.Error(err)) continue } } @@ -53,7 +53,7 @@ func (s *RouteSync) removeKernel(p *core.Peer) error { // syncKernel adds routes from the kernel routing table as new AllowedIPs to the respective peer // based on the destination address of the route. -func (s *RouteSync) syncKernel() error { +func (s *Interface) syncKernel() error { routes, err := netlink.RouteList(nil, unix.AF_INET6) if err != nil { return fmt.Errorf("failed to list routes from kernel: %w", err) @@ -73,7 +73,7 @@ func (s *RouteSync) syncKernel() error { // watchKernel watches for added/removed routes in the kernel routing table and adds/removes AllowedIPs // to the respective peers based on the destination address of the routes. -func (s *RouteSync) watchKernel() { +func (s *Interface) watchKernel() { rus := make(chan netlink.RouteUpdate) errs := make(chan error) @@ -102,12 +102,12 @@ func (s *RouteSync) watchKernel() { } } -func (s *RouteSync) handleRouteUpdate(ru *netlink.RouteUpdate) error { +func (s *Interface) handleRouteUpdate(ru *netlink.RouteUpdate) error { logger := s.logger.WithOptions(log.WithVerbose(10)) logger.Debug("Received netlink route update", zap.Any("update", ru)) - if ru.Table != s.table { + if ru.Table != s.Settings.RouteSync.Table { logger.Debug("Ignore route from another table") return nil } @@ -161,7 +161,7 @@ func (s *RouteSync) handleRouteUpdate(ru *netlink.RouteUpdate) error { } case unix.RTM_DELROUTE: - if err := p.RemoveAllowedIP(ru.Dst); err != nil { + if err := p.RemoveAllowedIP(*ru.Dst); err != nil { return fmt.Errorf("failed to remove allowed IP: %w", err) } } @@ -169,7 +169,7 @@ func (s *RouteSync) handleRouteUpdate(ru *netlink.RouteUpdate) error { return nil } -func (s *RouteSync) Sync() error { +func (s *Interface) Sync() error { if err := s.syncFamily(unix.AF_INET); err != nil { return fmt.Errorf("failed to sync IPv4 routes: %w", err) } @@ -181,9 +181,9 @@ func (s *RouteSync) Sync() error { return nil } -func (s *RouteSync) syncFamily(family int) error { +func (s *Interface) syncFamily(family int) error { rts, err := netlink.RouteListFiltered(family, &netlink.Route{ - Table: s.table, + Table: s.Settings.RouteSync.Table, }, netlink.RT_FILTER_TABLE) if err != nil { return fmt.Errorf("failed to list routes: %w", err) diff --git a/pkg/feat/rtsync/sync_others.go b/pkg/daemon/feature/rtsync/sync_others.go similarity index 58% rename from pkg/feat/rtsync/sync_others.go rename to pkg/daemon/feature/rtsync/sync_others.go index 12d4cc3f..e21d074e 100644 --- a/pkg/feat/rtsync/sync_others.go +++ b/pkg/daemon/feature/rtsync/sync_others.go @@ -7,12 +7,12 @@ import ( "github.com/stv0g/cunicu/pkg/errors" ) -func (s *RouteSync) removeKernel(p *core.Peer) error { +func (s *Interface) removeKernel(p *core.Peer) error { return errors.ErrNotSupported } -func (s *RouteSync) syncKernel() error { +func (s *Interface) syncKernel() error { return errors.ErrNotSupported } -func (s *RouteSync) watchKernel() {} +func (s *Interface) watchKernel() {} diff --git a/pkg/daemon/interface.go b/pkg/daemon/interface.go new file mode 100644 index 00000000..32814087 --- /dev/null +++ b/pkg/daemon/interface.go @@ -0,0 +1,69 @@ +package daemon + +import ( + "github.com/stv0g/cunicu/pkg/config" + "github.com/stv0g/cunicu/pkg/core" +) + +type Interface struct { + *core.Interface + + Daemon *Daemon + Settings *config.InterfaceSettings + + Features map[string]Feature +} + +func (d *Daemon) NewInterface(ci *core.Interface) (*Interface, error) { + i := &Interface{ + Interface: ci, + Daemon: d, + Settings: d.Config.InterfaceSettings(ci.Name()), + Features: map[string]Feature{}, + } + + for _, fp := range SortedFeatures() { + f, err := fp.New(i) + if err != nil { + return nil, err + } else if f == nil { + continue + } + + i.Features[fp.Name] = f + } + + return i, nil +} + +func (i *Interface) Start() error { + for _, f := range i.Features { + if err := f.Start(); err != nil { + return err + } + } + + return nil +} + +func (i *Interface) Sync() error { + for _, f := range i.Features { + if s, ok := f.(SyncableFeature); ok { + if err := s.Sync(); err != nil { + return err + } + } + } + + return nil +} + +func (i *Interface) Close() error { + for _, feat := range i.Features { + if err := feat.Close(); err != nil { + return err + } + } + + return nil +} diff --git a/pkg/device/device_linux_test.go b/pkg/device/device_linux_test.go index e4c035fd..f4515c89 100644 --- a/pkg/device/device_linux_test.go +++ b/pkg/device/device_linux_test.go @@ -27,14 +27,14 @@ var _ = Describe("device", func() { var nlh *nl.Handle var l nl.Link - getAddrs := func() []*net.IPNet { + getAddrs := func() []net.IPNet { addrs, err := nlh.AddrList(l, unix.AF_INET) Expect(err).To(Succeed()) - ips := []*net.IPNet{} + ips := []net.IPNet{} for _, addr := range addrs { addr.IP = addr.IP.To16() - ips = append(ips, addr.IPNet) + ips = append(ips, *addr.IPNet) } return ips diff --git a/pkg/feat/autocfg/autocfg.go b/pkg/feat/autocfg/autocfg.go deleted file mode 100644 index 5c4e32df..00000000 --- a/pkg/feat/autocfg/autocfg.go +++ /dev/null @@ -1,218 +0,0 @@ -// Package autocfg handles initial auto-configuration of new interfaces and peers -package autocfg - -import ( - "errors" - "fmt" - "net" - "syscall" - - "github.com/stv0g/cunicu/pkg/config" - "github.com/stv0g/cunicu/pkg/core" - "github.com/stv0g/cunicu/pkg/crypto" - "github.com/stv0g/cunicu/pkg/device" - "github.com/stv0g/cunicu/pkg/util" - "github.com/stv0g/cunicu/pkg/watcher" - "github.com/stv0g/cunicu/pkg/wg" - "go.uber.org/zap" - "golang.org/x/exp/slices" - "golang.zx2c4.com/wireguard/wgctrl" - "golang.zx2c4.com/wireguard/wgctrl/wgtypes" -) - -type AutoConfig struct { - client *wgctrl.Client - config *config.Config - - logger *zap.Logger -} - -func addAddresses(dev device.Device, addrs ...net.IPNet) error { - for _, addr := range addrs { - if err := dev.AddAddress(addr); err != nil && !errors.Is(err, syscall.EEXIST) { - return fmt.Errorf("failed to assign address: %w", err) - } - } - - return nil -} - -func deleteAddresses(dev device.Device, addrs ...net.IPNet) error { - for _, addr := range addrs { - if err := dev.DeleteAddress(addr); err != nil { - return fmt.Errorf("failed to assign IPv4 link-local address: %w", err) - } - } - - return nil -} - -func New(w *watcher.Watcher, cfg *config.Config, client *wgctrl.Client) *AutoConfig { - s := &AutoConfig{ - client: client, - config: cfg, - logger: zap.L().Named("autocfg"), - } - - w.OnAll(s) - - return s -} - -func (a *AutoConfig) Start() error { - a.logger.Info("Started interface auto-configuration") - - return nil -} - -func (a *AutoConfig) Close() error { - return nil -} - -func (a *AutoConfig) OnInterfaceAdded(i *core.Interface) { - logger := a.logger.With(zap.String("intf", i.Name())) - - icfg := a.config.InterfaceSettings(i.Name()) - - if err := a.configureWireGuardInterface(i, &icfg.WireGuard); err != nil { - logger.Error("Failed to configure WireGuard interface", zap.Error(err)) - } - - // Assign addresses - addrs := slices.Clone(icfg.AutoConfig.Addresses) - if icfg.AutoConfig.LinkLocalAddresses && i.PublicKey().IsSet() { - pk := i.PublicKey() - addrs = append(addrs, pk.IPv4Address(), pk.IPv6Address()) - } - - if err := addAddresses(i.KernelDevice, addrs...); err != nil { - logger.Error("Failed to assign addresses", zap.Error(err), zap.Any("addrs", addrs)) - } - - // Autodetect MTU - // TODO: Update MTU when peers are added or their endpoints change - if mtu := icfg.AutoConfig.MTU; mtu == 0 { - var err error - if mtu, err = i.DetectMTU(); err != nil { - logger.Error("Failed to detect MTU", zap.Error(err)) - } else { - if err := i.KernelDevice.SetMTU(mtu); err != nil { - logger.Error("Failed to set MTU", zap.Error(err), zap.Int("mtu", icfg.AutoConfig.MTU)) - } - } - } - - // Set link up - if err := i.KernelDevice.SetUp(); err != nil { - logger.Error("Failed to bring link up", zap.Error(err)) - } -} - -func (a *AutoConfig) OnInterfaceRemoved(i *core.Interface) {} - -func (a *AutoConfig) OnInterfaceModified(i *core.Interface, old *wg.Device, mod core.InterfaceModifier) { - - // Update link-local addresses in case the interface key has changed - if mod&core.InterfaceModifiedPrivateKey != 0 { - oldPk := crypto.Key(old.PublicKey) - newPk := i.PublicKey() - - if oldPk.IsSet() { - if err := deleteAddresses(i.KernelDevice, - oldPk.IPv4Address(), - oldPk.IPv6Address(), - ); err != nil { - a.logger.Error("Failed to delete link-local addresses", zap.Error(err)) - } - } - - if newPk.IsSet() { - if err := addAddresses(i.KernelDevice, - newPk.IPv4Address(), - newPk.IPv6Address(), - ); err != nil { - a.logger.Error("Failed to assign link-local addresses", zap.Error(err)) - } - } - } -} - -func (a *AutoConfig) OnPeerAdded(p *core.Peer) { - logger := a.logger.With( - zap.String("intf", p.Interface.Name()), - zap.Any("peer", p.PublicKey())) - - // Add default link-local address as allowed IP - ipV4 := p.PublicKey().IPv4Address() - ipV6 := p.PublicKey().IPv6Address() - - ipV4.Mask = net.CIDRMask(32, 32) - ipV6.Mask = net.CIDRMask(128, 128) - - if err := p.AddAllowedIP(ipV4); err != nil { - logger.Error("Failed to add link-local IPv4 address to AllowedIPs", zap.Error(err)) - } - - if err := p.AddAllowedIP(ipV6); err != nil { - logger.Error("Failed to add link-local IPv6 address to AllowedIPs", zap.Error(err)) - } -} - -func (a *AutoConfig) OnPeerRemoved(p *core.Peer) {} - -func (a *AutoConfig) OnPeerModified(p *core.Peer, old *wgtypes.Peer, mod core.PeerModifier, ipsAdded, ipsRemoved []net.IPNet) { -} - -// configureInterface configures the WireGuard device using the configuration provided by the user -// Missing settings such as a private key or listen port are automatically generated/allocated. -func (a *AutoConfig) configureWireGuardInterface(i *core.Interface, icfg *config.WireGuardSettings) error { - var err error - - cfg := wgtypes.Config{} - configure := false - - logger := a.logger.With(zap.String("intf", i.Name())) - - // Private key - if !i.PrivateKey().IsSet() || i.PrivateKey() != icfg.PrivateKey { - sk := icfg.PrivateKey - if !sk.IsSet() { - sk, err = crypto.GeneratePrivateKey() - if err != nil { - return fmt.Errorf("failed to generate private key: %w", err) - } - } - - cfg.PrivateKey = (*wgtypes.Key)(&sk) - configure = true - } - - // Listen port - if i.ListenPort == 0 || i.ListenPort != *icfg.ListenPort { - if icfg.ListenPort != nil { - cfg.ListenPort = icfg.ListenPort - } else { - logger.Warn("Device has no listen port. Setting a random one.") - - port, err := util.FindNextPortToListen("udp", - icfg.ListenPortRange.Min, - icfg.ListenPortRange.Max, - ) - if err != nil { - return fmt.Errorf("failed set listen port: %w", err) - } - - cfg.ListenPort = &port - } - - configure = true - } - - if configure { - if err := a.client.ConfigureDevice(i.Name(), cfg); err != nil { - return fmt.Errorf("failed to configure device: %w", err) - } - } - - return nil -} diff --git a/pkg/feat/cfgsync/cfgsync.go b/pkg/feat/cfgsync/cfgsync.go deleted file mode 100644 index ddc83008..00000000 --- a/pkg/feat/cfgsync/cfgsync.go +++ /dev/null @@ -1,175 +0,0 @@ -// Package cfgsync synchronizes existing WireGuard configuration files with the kernel/userspace WireGuard device. -package cfgsync - -import ( - "errors" - "fmt" - "os" - "path" - "path/filepath" - "strings" - - "github.com/fsnotify/fsnotify" - "github.com/stv0g/cunicu/pkg/core" - "github.com/stv0g/cunicu/pkg/device" - "github.com/stv0g/cunicu/pkg/watcher" - "github.com/stv0g/cunicu/pkg/wg" - "go.uber.org/zap" - "golang.zx2c4.com/wireguard/wgctrl" -) - -// ConfigSync synchronizes the WireGuard device configuration with an on-disk configuration file. -type ConfigSync struct { - watcher *watcher.Watcher - client *wgctrl.Client - - // Settings - cfgPath string - user bool - filter func(string) bool - - logger *zap.Logger -} - -// New creates a new Syncer -func New(w *watcher.Watcher, client *wgctrl.Client, cfgPath string, watch bool, user bool, filter func(string) bool) *ConfigSync { - cs := &ConfigSync{ - watcher: w, - client: client, - cfgPath: cfgPath, - user: user, - filter: filter, - logger: zap.L().Named("cfgsync"), - } - - w.OnInterface(cs) - - if watch { - go cs.watch() - } - - return cs -} - -func (cs *ConfigSync) Start() error { - cs.logger.Info("Started configuration file synchronization") - - return nil -} - -func (cs *ConfigSync) Close() error { - return nil -} - -// OnInterfaceAdded is a handler which is called whenever an interface has been added -func (cs *ConfigSync) OnInterfaceAdded(i *core.Interface) { - cfg := filepath.Join(cs.cfgPath, fmt.Sprintf("%s.conf", i.Name())) - if err := i.SyncConfig(cfg); err != nil && !errors.Is(err, os.ErrNotExist) { - cs.logger.Fatal("Failed to sync interface configuration", - zap.Error(err), - zap.String("intf", i.Name()), - zap.String("config_file", cfg)) - } -} - -func (cs *ConfigSync) OnInterfaceRemoved(i *core.Interface) {} - -func (cs *ConfigSync) OnInterfaceModified(i *core.Interface, old *wg.Device, m core.InterfaceModifier) { -} - -func (cs *ConfigSync) watch() { - watcher, err := fsnotify.NewWatcher() - if err != nil { - cs.logger.Fatal("failed to create fsnotify watcher", zap.Error(err)) - } - - if _, err := os.Stat(cs.cfgPath); !os.IsNotExist(err) { - if err := watcher.Add(cs.cfgPath); err != nil { - cs.logger.Fatal("Failed to watch WireGuard configuration directory", - zap.Error(err), - zap.String("path", cs.cfgPath)) - } - } - - for { - select { - - // Fsnotify events - case event := <-watcher.Events: - cs.logger.Debug("Received fsnotify event", zap.Any("event", event)) - - cs.handleFsnotifyEvent(event) - - // Fsnotify errors - case err := <-watcher.Errors: - cs.logger.Error("Error while watching for WireGuard configuration files", zap.Error(err)) - } - } -} - -func (cs *ConfigSync) handleFsnotifyEvent(event fsnotify.Event) { - cfg := event.Name - filename := path.Base(cfg) - extension := path.Ext(filename) - name := strings.TrimSuffix(filename, extension) - - if extension != ".conf" { - cs.logger.Warn("Ignoring non-configuration file", zap.String("config_file", cfg)) - return - } - - if !cs.filter(name) { - cs.logger.Warn("Ignoring configuration file for interface which does not match the interface filter", zap.String("config_file", cfg)) - return - } - - i := cs.watcher.InterfaceByName(name) - - if event.Op&(fsnotify.Create|fsnotify.Write) != 0 { - if i == nil { - if i, err := device.NewDevice(name, cs.user); err != nil { - cs.logger.Error("Failed to create new device", - zap.Error(err), - zap.String("intf", i.Name()), - zap.String("config_file", cfg)) - } - } - - if err := i.SyncConfig(cfg); err != nil { - cs.logger.Error("Failed to sync interface configuration", - zap.Error(err), - zap.String("intf", i.Name()), - zap.String("config_file", cfg)) - } - } else if event.Op&(fsnotify.Remove) != 0 { - if i == nil { - cs.logger.Warn("Ignoring unknown interface", zap.String("intf", name)) - return - } - - // TODO: Do we really want to delete devices if their config file vanish? - // Maybe make this configurable? - if err := i.KernelDevice.Close(); err != nil { - cs.logger.Error("Failed to close interface", zap.Error(err)) - } - } else if event.Op&(fsnotify.Rename) != 0 { - // TODO: This is not supported yet - cs.logger.Warn("We do not support tracking renamed WireGuard configuration files yet") - } -} - -func (cs *ConfigSync) Sync() error { - des, err := os.ReadDir(cs.cfgPath) - if err != nil { - return fmt.Errorf("failed to list config files in '%s': %w", cs.cfgPath, err) - } - - for _, de := range des { - cs.handleFsnotifyEvent(fsnotify.Event{ - Name: filepath.Join(cs.cfgPath, de.Name()), - Op: fsnotify.Write, - }) - } - - return nil -} diff --git a/pkg/feat/epdisc/epdisc.go b/pkg/feat/epdisc/epdisc.go deleted file mode 100644 index b1c39c4e..00000000 --- a/pkg/feat/epdisc/epdisc.go +++ /dev/null @@ -1,171 +0,0 @@ -// Package epdisc implements endpoint (EP) discovery using Interactive Connection Establishment (ICE). -package epdisc - -import ( - "context" - "fmt" - "net" - - "github.com/stv0g/cunicu/pkg/config" - "github.com/stv0g/cunicu/pkg/core" - "github.com/stv0g/cunicu/pkg/crypto" - icex "github.com/stv0g/cunicu/pkg/feat/epdisc/ice" - "github.com/stv0g/cunicu/pkg/feat/epdisc/proxy" - "github.com/stv0g/cunicu/pkg/signaling" - "github.com/stv0g/cunicu/pkg/watcher" - "github.com/stv0g/cunicu/pkg/wg" - "go.uber.org/zap" - "golang.zx2c4.com/wireguard/wgctrl" - "golang.zx2c4.com/wireguard/wgctrl/wgtypes" -) - -type EndpointDiscovery struct { - Peers map[*core.Peer]*Peer - Interfaces map[*core.Interface]*Interface - - onConnectionStateChange []OnConnectionStateHandler - - watcher *watcher.Watcher - config *config.Config - client *wgctrl.Client - backend signaling.Backend - - logger *zap.Logger -} - -func New(w *watcher.Watcher, cfg *config.Config, client *wgctrl.Client, backend signaling.Backend) *EndpointDiscovery { - e := &EndpointDiscovery{ - Peers: map[*core.Peer]*Peer{}, - Interfaces: map[*core.Interface]*Interface{}, - - onConnectionStateChange: []OnConnectionStateHandler{}, - - watcher: w, - config: cfg, - client: client, - backend: backend, - - logger: zap.L().Named("epdisc"), - } - - w.OnAll(e) - - return e -} - -func (e *EndpointDiscovery) Start() error { - e.logger.Info("Started endpoint discovery") - - return nil -} - -func (e *EndpointDiscovery) Close() error { - // First switch all sessions to closing so they dont get restarted - for _, p := range e.Peers { - p.setConnectionState(icex.ConnectionStateClosing) - } - - for _, p := range e.Peers { - if err := p.Close(); err != nil { - return fmt.Errorf("failed to close peer: %w", err) - } - } - - for _, i := range e.Interfaces { - if err := i.Close(); err != nil { - return fmt.Errorf("failed to close interface: %w", err) - } - } - - return nil -} - -func (e *EndpointDiscovery) OnInterfaceAdded(ci *core.Interface) { - i, err := NewInterface(ci, e) - if err != nil { - e.logger.Error("Failed to initialize ICE interface", zap.Error(err)) - return - } - - e.Interfaces[ci] = i -} - -func (e *EndpointDiscovery) OnInterfaceRemoved(ci *core.Interface) { - i := e.Interfaces[ci] - - if err := i.Close(); err != nil { - e.logger.Error("Failed to de-initialize ICE interface", zap.Error(err)) - } - - delete(e.Interfaces, ci) -} - -func (e *EndpointDiscovery) OnInterfaceModified(ci *core.Interface, old *wg.Device, m core.InterfaceModifier) { - i := e.Interfaces[ci] - - if m.Is(core.InterfaceModifiedListenPort) { - if err := i.UpdateRedirects(); err != nil { - e.logger.Error("Failed to update DPAT redirects", zap.Error(err)) - } - } - - for _, cp := range i.Peers { - p := e.Peers[cp] - - if m.Is(core.InterfaceModifiedListenPort) { - if kproxy, ok := p.proxy.(*proxy.KernelProxy); ok { - if err := kproxy.UpdateListenPort(i.ListenPort); err != nil { - e.logger.Error("Failed to update SPAT redirect", zap.Error(err)) - } - } - } - - if m.Is(core.InterfaceModifiedPrivateKey) { - skOld := crypto.Key(old.PrivateKey) - if err := p.Resubscribe(context.Background(), skOld); err != nil { - e.logger.Error("Failed to update subscription", zap.Error(err)) - } - } - } -} - -func (e *EndpointDiscovery) OnPeerAdded(cp *core.Peer) { - i := e.Interfaces[cp.Interface] - - p, err := NewPeer(cp, i) - if err != nil { - e.logger.Error("Failed to initialize ICE peer", zap.Error(err)) - return - } - - e.Peers[cp] = p -} - -func (e *EndpointDiscovery) OnPeerRemoved(cp *core.Peer) { - p, ok := e.Peers[cp] - if !ok { - return - } - - if err := p.Close(); err != nil { - e.logger.Error("Failed to de-initialize ICE peer", zap.Error(err)) - } - - delete(e.Peers, cp) -} - -func (e *EndpointDiscovery) OnPeerModified(cp *core.Peer, old *wgtypes.Peer, m core.PeerModifier, ipsAdded, ipsRemoved []net.IPNet) { - p := e.Peers[cp] - - // TODO: Handle changed endpoint addresses - // What do we do when they have been changed externally? - if m.Is(core.PeerModifiedEndpoint) { - // Check if change was external - epNew := p.Endpoint - epExpected := p.lastEndpoint - - if (epExpected != nil && epNew != nil) && (!epNew.IP.Equal(epExpected.IP) || epNew.Port != epExpected.Port) { - e.logger.Warn("Endpoint address has been changed externally. This is breaks the connection and is most likely not desired.") - } - } -} diff --git a/pkg/feat/epdisc/handlers.go b/pkg/feat/epdisc/handlers.go deleted file mode 100644 index be420f26..00000000 --- a/pkg/feat/epdisc/handlers.go +++ /dev/null @@ -1,11 +0,0 @@ -package epdisc - -import icex "github.com/stv0g/cunicu/pkg/feat/epdisc/ice" - -type OnConnectionStateHandler interface { - OnConnectionStateChange(p *Peer, new, prev icex.ConnectionState) -} - -func (e *EndpointDiscovery) OnConnectionStateChange(h OnConnectionStateHandler) { - e.onConnectionStateChange = append(e.onConnectionStateChange, h) -} diff --git a/pkg/feat/epdisc/interface.go b/pkg/feat/epdisc/interface.go deleted file mode 100644 index 7a302d44..00000000 --- a/pkg/feat/epdisc/interface.go +++ /dev/null @@ -1,143 +0,0 @@ -package epdisc - -import ( - "fmt" - - "errors" - - "github.com/pion/ice/v2" - "github.com/stv0g/cunicu/pkg/core" - "github.com/stv0g/cunicu/pkg/device" - "github.com/stv0g/cunicu/pkg/feat/epdisc/proxy" - "go.uber.org/zap" - - errorsx "github.com/stv0g/cunicu/pkg/errors" - protoepdisc "github.com/stv0g/cunicu/pkg/proto/feat/epdisc" -) - -type Interface struct { - *core.Interface - - Discovery *EndpointDiscovery - - nat *proxy.NAT - - natRule *proxy.NATRule - natRuleSrflx *proxy.NATRule - - udpMux ice.UDPMux - udpMuxSrflx ice.UniversalUDPMux - - udpMuxPort int - udpMuxSrflxPort int - - logger *zap.Logger -} - -func NewInterface(ci *core.Interface, d *EndpointDiscovery) (*Interface, error) { - i := &Interface{ - Interface: ci, - Discovery: d, - - logger: zap.L().Named("epdisc.interface"), - } - - // Create per-interface UDPMux - var err error - - if i.udpMux, i.udpMuxPort, err = proxy.CreateUDPMux(); err != nil && !errors.Is(err, errorsx.ErrNotSupported) { - return nil, fmt.Errorf("failed to setup host UDP mux: %w", err) - } - - if i.udpMuxSrflx, i.udpMuxSrflxPort, err = proxy.CreateUniversalUDPMux(); err != nil && !errors.Is(err, errorsx.ErrNotSupported) { - return nil, fmt.Errorf("failed to setup srflx UDP mux: %w", err) - } - - i.logger.Info("Created UDP muxes", - zap.Int("port-host", i.udpMuxPort), - zap.Int("port-srflx", i.udpMuxSrflxPort)) - - // Setup Netfilter PAT for non-userspace devices - if _, ok := i.KernelDevice.(*device.UserDevice); !ok { - // Setup NAT - ident := fmt.Sprintf("cunicu-if%d", i.KernelDevice.Index()) - if i.nat, err = proxy.NewNAT(ident); err != nil && !errors.Is(err, errorsx.ErrNotSupported) { - return nil, fmt.Errorf("failed to setup NAT: %w", err) - } - - // Setup DNAT redirects (STUN ports -> WireGuard listen ports) - if err := i.SetupRedirects(); err != nil { - return nil, fmt.Errorf("failed to setup redirects: %w", err) - } - } - - return i, nil -} - -func (i *Interface) Close() error { - if i.nat != nil { - if err := i.nat.Close(); err != nil { - return fmt.Errorf("failed to de-initialize NAT: %w", err) - } - } - - if err := i.udpMux.Close(); err != nil { - return fmt.Errorf("failed to do-initialize UDP mux: %w", err) - } - - if err := i.udpMuxSrflx.Close(); err != nil { - return fmt.Errorf("failed to do-initialize srflx UDP mux: %w", err) - } - - return nil -} - -func (i *Interface) Marshal() *protoepdisc.Interface { - is := &protoepdisc.Interface{ - MuxPort: uint32(i.udpMuxPort), - MuxSrflxPort: uint32(i.udpMuxSrflxPort), - } - - if i.nat != nil { - is.NatType = protoepdisc.NATType_NAT_NFTABLES - } - - return is -} - -func (i *Interface) UpdateRedirects() error { - // Userspace devices need no redirects - if i.nat == nil { - return nil - } - - // Delete old rules if presetn - if i.natRule != nil { - if err := i.natRule.Delete(); err != nil { - return fmt.Errorf("failed to delete rule: %w", err) - } - } - - if i.natRuleSrflx != nil { - if err := i.natRuleSrflx.Delete(); err != nil { - return fmt.Errorf("failed to delete rule: %w", err) - } - } - - return i.SetupRedirects() -} - -func (i *Interface) SetupRedirects() error { - var err error - - // Redirect non-STUN traffic directed at UDP muxes to WireGuard interface via in-kernel port redirect / NAT - if i.natRule, err = i.nat.RedirectNonSTUN(i.udpMuxPort, i.ListenPort); err != nil { - return fmt.Errorf("failed to setup port redirect for server reflexive UDP mux: %w", err) - } - - if i.natRuleSrflx, err = i.nat.RedirectNonSTUN(i.udpMuxSrflxPort, i.ListenPort); err != nil { - return fmt.Errorf("failed to setup port redirect for server reflexive UDP mux: %w", err) - } - - return nil -} diff --git a/pkg/feat/feat.go b/pkg/feat/feat.go deleted file mode 100644 index 2c949040..00000000 --- a/pkg/feat/feat.go +++ /dev/null @@ -1,62 +0,0 @@ -// Package feat contains several sub-packages each implementing a dedicated feature. -package feat - -import ( - "github.com/stv0g/cunicu/pkg/config" - "github.com/stv0g/cunicu/pkg/crypto" - "github.com/stv0g/cunicu/pkg/feat/autocfg" - "github.com/stv0g/cunicu/pkg/feat/cfgsync" - "github.com/stv0g/cunicu/pkg/feat/epdisc" - "github.com/stv0g/cunicu/pkg/feat/hooks" - "github.com/stv0g/cunicu/pkg/feat/hsync" - "github.com/stv0g/cunicu/pkg/feat/pdisc" - "github.com/stv0g/cunicu/pkg/feat/rtsync" - "github.com/stv0g/cunicu/pkg/signaling" - "github.com/stv0g/cunicu/pkg/watcher" - "golang.zx2c4.com/wireguard/wgctrl" -) - -type Syncable interface { - Sync() error -} - -type Feature interface { - Start() error - Close() error -} - -func NewFeatures(w *watcher.Watcher, cfg *config.Config, c *wgctrl.Client, b signaling.Backend) ([]Feature, *epdisc.EndpointDiscovery) { - var ep *epdisc.EndpointDiscovery - var feats = []Feature{} - - if cfg.DefaultInterfaceSettings.AutoConfig.Enabled { - feats = append(feats, autocfg.New(w, cfg, c)) - } - - if cfg.DefaultInterfaceSettings.ConfigSync.Enabled { - feats = append(feats, cfgsync.New(w, c, cfg.DefaultInterfaceSettings.ConfigSync.Path, cfg.DefaultInterfaceSettings.ConfigSync.Watch, cfg.DefaultInterfaceSettings.WireGuard.UserSpace, cfg.InterfaceFilter)) - } - - if cfg.DefaultInterfaceSettings.RouteSync.Enabled { - feats = append(feats, rtsync.New(w, cfg.DefaultInterfaceSettings.RouteSync.Table, cfg.DefaultInterfaceSettings.RouteSync.Watch)) - } - - if cfg.DefaultInterfaceSettings.HostSync.Enabled { - feats = append(feats, hsync.New(w, cfg.DefaultInterfaceSettings.HostSync.Domain)) - } - - if cfg.DefaultInterfaceSettings.EndpointDisc.Enabled { - ep = epdisc.New(w, cfg, c, b) - feats = append(feats, ep) - } - - if cfg.DefaultInterfaceSettings.PeerDisc.Enabled && crypto.Key(cfg.DefaultInterfaceSettings.PeerDisc.Community).IsSet() { - feats = append(feats, pdisc.New(w, c, b, cfg)) - } - - if len(cfg.Hooks) > 0 { - feats = append(feats, hooks.New(w, cfg, ep)) - } - - return feats, ep -} diff --git a/pkg/feat/hooks/hooks.go b/pkg/feat/hooks/hooks.go deleted file mode 100644 index 07d986b6..00000000 --- a/pkg/feat/hooks/hooks.go +++ /dev/null @@ -1,75 +0,0 @@ -package hooks - -import ( - "github.com/stv0g/cunicu/pkg/config" - "github.com/stv0g/cunicu/pkg/feat/epdisc" - "github.com/stv0g/cunicu/pkg/watcher" - "go.uber.org/zap" -) - -type Hooks struct { - config *config.Config - watcher *watcher.Watcher - epdisc *epdisc.EndpointDiscovery - - logger *zap.Logger -} - -func New(w *watcher.Watcher, cfg *config.Config, ep *epdisc.EndpointDiscovery) *Hooks { - h := &Hooks{ - config: cfg, - watcher: w, - epdisc: ep, - - logger: zap.L().Named("hooks"), - } - - for _, hk := range cfg.Hooks { - switch hk := hk.(type) { - case *config.ExecHookSetting: - h.NewExecHook(hk) - case *config.WebHookSetting: - h.NewWebHook(hk) - } - } - - return h -} - -func (h *Hooks) NewExecHook(cfg *config.ExecHookSetting) { - hk := &ExecHook{ - ExecHookSetting: cfg, - logger: h.logger.Named("exec").With( - zap.String("command", cfg.Command), - ), - } - - h.logger.Debug("Created new exec hook", zap.Any("hook", hk)) - - h.watcher.OnAll(hk) - h.epdisc.OnConnectionStateChange(hk) -} - -func (h *Hooks) NewWebHook(cfg *config.WebHookSetting) { - hk := &WebHook{ - WebHookSetting: cfg, - logger: h.logger.Named("web").With( - zap.Any("url", cfg.URL), - ), - } - - h.logger.Debug("Created new web hook", zap.Any("hook", hk)) - - h.watcher.OnAll(hk) - h.epdisc.OnConnectionStateChange(hk) -} - -func (h *Hooks) Start() error { - h.logger.Info("Started hooks") - - return nil -} - -func (h *Hooks) Close() error { - return nil -} diff --git a/pkg/feat/pdisc/pdisc.go b/pkg/feat/pdisc/pdisc.go deleted file mode 100644 index 64b2430f..00000000 --- a/pkg/feat/pdisc/pdisc.go +++ /dev/null @@ -1,297 +0,0 @@ -// Package pdisc implements peer discovery based on a shared community passphrase. -package pdisc - -import ( - "context" - "fmt" - "net" - "time" - - "go.uber.org/zap" - "golang.zx2c4.com/wireguard/wgctrl" - - "github.com/stv0g/cunicu/pkg/config" - "github.com/stv0g/cunicu/pkg/core" - "github.com/stv0g/cunicu/pkg/crypto" - "github.com/stv0g/cunicu/pkg/signaling" - "github.com/stv0g/cunicu/pkg/util" - "github.com/stv0g/cunicu/pkg/util/buildinfo" - "github.com/stv0g/cunicu/pkg/watcher" - "github.com/stv0g/cunicu/pkg/wg" - - pdiscproto "github.com/stv0g/cunicu/pkg/proto/feat/pdisc" -) - -type PeerDiscovery struct { - backend signaling.Backend - watcher *watcher.Watcher - - config *config.Config - - whitelistMap map[*core.Interface]map[crypto.Key]any - - logger *zap.Logger -} - -func New(w *watcher.Watcher, c *wgctrl.Client, b signaling.Backend, cfg *config.Config) *PeerDiscovery { - pd := &PeerDiscovery{ - backend: b, - watcher: w, - whitelistMap: map[*core.Interface]map[crypto.Key]any{}, - config: cfg, - logger: zap.L().Named("pdisc"), - } - - w.OnInterface(pd) - - return pd -} - -func (pd *PeerDiscovery) Start() error { - pd.logger.Info("Started peer discovery") - - // Subscribe to peer updates - // TODO: Support per-interface communities - - kp := &crypto.KeyPair{ - Ours: crypto.Key(pd.config.DefaultInterfaceSettings.PeerDisc.Community), - Theirs: signaling.AnyKey, - } - if _, err := pd.backend.Subscribe(context.Background(), kp, pd); err != nil { - return fmt.Errorf("failed to subscribe on peer discovery channel: %w", err) - } - - return nil -} - -func (pd *PeerDiscovery) Close() error { - return nil -} - -func (pd *PeerDiscovery) OnInterfaceAdded(i *core.Interface) { - i.OnModified(pd) - - // Ignore interface which do not have a private key yet - if !i.PrivateKey().IsSet() { - return - } - - cfg := pd.config.InterfaceSettings(i.Name()) - - if cfg.PeerDisc.Whitelist != nil { - pd.whitelistMap[i] = map[crypto.Key]any{} - for _, k := range cfg.PeerDisc.Whitelist { - pd.whitelistMap[i][crypto.Key(k)] = nil - } - } - - if err := pd.sendPeerDescription(i, pdiscproto.PeerDescriptionChange_PEER_ADD, nil); err != nil { - pd.logger.Error("Failed to send peer description", zap.Error(err)) - } -} - -func (pd *PeerDiscovery) OnInterfaceRemoved(i *core.Interface) { - // Ignore interface which do not have a private key yet - if !i.PrivateKey().IsSet() { - return - } - - if err := pd.sendPeerDescription(i, pdiscproto.PeerDescriptionChange_PEER_REMOVE, nil); err != nil { - pd.logger.Error("Failed to send peer description", zap.Error(err)) - } -} - -func (pd *PeerDiscovery) OnInterfaceModified(i *core.Interface, old *wg.Device, m core.InterfaceModifier) { - // Ignore interface which do not have a private key yet - if !i.PrivateKey().IsSet() { - return - } - - // Only send an update if the private key changed. - // There are currently no other attributes which would need to be re-announced - if m.Is(core.InterfaceModifiedPrivateKey) { - var pkOld *crypto.Key - if skOld := crypto.Key(old.PrivateKey); skOld.IsSet() { - pk := skOld.PublicKey() - pkOld = &pk - } - - if err := pd.sendPeerDescription(i, pdiscproto.PeerDescriptionChange_PEER_UPDATE, pkOld); err != nil { - pd.logger.Error("Failed to send peer description", zap.Error(err)) - } - } -} - -func (pd *PeerDiscovery) OnSignalingMessage(kp *crypto.PublicKeyPair, msg *signaling.Message) { - if msg.Peer != nil { - if i := pd.watcher.InterfaceByPublicKey(kp.Theirs); i != nil { - // Received our own peer description. Ignoring... - return - } - - if err := pd.onPeerDescription(msg.Peer); err != nil { - pd.logger.Error("Failed to handle peer description", zap.Error(err), zap.Any("pd", msg.Peer)) - } - } -} - -func (pd *PeerDiscovery) onPeerDescription(pdisc *pdiscproto.PeerDescription) error { - pk, err := crypto.ParseKeyBytes(pdisc.PublicKey) - if err != nil { - return fmt.Errorf("invalid public key: %w", err) - } - - // TODO: support per interface communities - whitelisted := false - for i := range pd.whitelistMap { - if pd.isWhitelisted(i, pk) { - whitelisted = true - break - } - } - - if !whitelisted { - pd.logger.Warn("Ignoring non-whitelisted peer", zap.Any("peer", pk)) - return nil - } - - p := pd.watcher.PeerByPublicKey(&pk) - - switch pdisc.Change { - case pdiscproto.PeerDescriptionChange_PEER_ADD: - if p != nil { - pd.logger.Warn("Peer already exists. Updating it instead", zap.String("intf", p.Interface.Name())) - pdisc.Change = pdiscproto.PeerDescriptionChange_PEER_UPDATE - } - - case pdiscproto.PeerDescriptionChange_PEER_UPDATE: - if p == nil { - pd.logger.Warn("Peer does not exist exists yet. Adding it instead") - pdisc.Change = pdiscproto.PeerDescriptionChange_PEER_ADD - } - - default: - if p == nil { - return fmt.Errorf("cant remove non-existing peer") - } - } - - cfg := pdisc.Config() - - switch pdisc.Change { - case pdiscproto.PeerDescriptionChange_PEER_ADD: - if err := pd.watcher.ForEachInterface(func(i *core.Interface) error { - return i.AddPeer(&cfg) - }); err != nil { - return fmt.Errorf("failed to add peer: %w", err) - } - - case pdiscproto.PeerDescriptionChange_PEER_UPDATE: - if pdisc.PublicKeyNew != nil { - // Remove old peer - if err := p.Interface.RemovePeer(pk); err != nil { - return fmt.Errorf("failed to remove peer: %w", err) - } - - // Re-add peer with new public key - if err := p.Interface.AddPeer(&cfg); err != nil { - return fmt.Errorf("failed to add peer: %w", err) - } - } else { - if err := p.Interface.UpdatePeer(&cfg); err != nil { - return fmt.Errorf("failed to remove peer: %w", err) - } - } - - case pdiscproto.PeerDescriptionChange_PEER_REMOVE: - if err := p.Interface.RemovePeer(pk); err != nil { - return fmt.Errorf("failed to remove peer: %w", err) - } - } - - // Re-announce ourself in case this is a new peer we did not knew already - if p == nil { - // TODO: Check if delay is really necessary - time.AfterFunc(1*time.Second, func() { - if err := pd.watcher.ForEachInterface(func(i *core.Interface) error { - return pd.sendPeerDescription(i, pdiscproto.PeerDescriptionChange_PEER_ADD, nil) - }); err != nil { - pd.logger.Error("Failed to send peer description", zap.Error(err)) - } - }) - } - - return nil -} - -func (pd *PeerDiscovery) sendPeerDescription(i *core.Interface, chg pdiscproto.PeerDescriptionChange, pkOld *crypto.Key) error { - icfg := pd.config.InterfaceSettings(i.Name()) - - // Gather all allowed IPs for this interface - allowedIPs := []net.IPNet{} - allowedIPs = append(allowedIPs, icfg.AutoConfig.Addresses...) - - if icfg.AutoConfig.LinkLocalAddresses { - allowedIPs = append(allowedIPs, - i.PublicKey().IPv6Address(), - i.PublicKey().IPv4Address(), - ) - } - - // Only the /32 or /128 for local addresses - for _, allowedIP := range allowedIPs { - for i := range allowedIP.Mask { - allowedIP.Mask[i] = 0xff - } - } - - // But networks are taken in full - allowedIPs = append(allowedIPs, icfg.PeerDisc.Networks...) - - d := &pdiscproto.PeerDescription{ - Change: chg, - Hostname: icfg.PeerDisc.Hostname, - AllowedIps: util.StringSlice(allowedIPs), - BuildInfo: buildinfo.BuildInfo(), - } - - if pkOld != nil { - if d.Change != pdiscproto.PeerDescriptionChange_PEER_UPDATE { - return fmt.Errorf("can not change public key in non-update message") - } - - d.PublicKeyNew = i.PublicKey().Bytes() - d.PublicKey = pkOld.Bytes() - } else { - d.PublicKey = i.PublicKey().Bytes() - } - - msg := &signaling.Message{ - Peer: d, - } - - kp := &crypto.KeyPair{ - Ours: i.PrivateKey(), - Theirs: crypto.Key(icfg.PeerDisc.Community).PublicKey(), - } - - if err := pd.backend.Publish(context.Background(), kp, msg); err != nil { - return err - } - - pd.logger.Debug("Send peer description", zap.Any("description", d)) - - return nil -} - -func (pd *PeerDiscovery) isWhitelisted(i *core.Interface, pk crypto.Key) bool { - if pd.whitelistMap == nil { - return true - } else if wl, ok := pd.whitelistMap[i]; ok { - if _, ok := wl[pk]; ok { - return true - } - } - - return false -} diff --git a/pkg/proto/core/interface.go b/pkg/proto/core/interface.go index c9238d40..8fac281e 100644 --- a/pkg/proto/core/interface.go +++ b/pkg/proto/core/interface.go @@ -33,7 +33,7 @@ func (i *Interface) Device() *wg.Device { func (i *Interface) Dump(wr io.Writer, verbosity int) error { wri := t.NewIndenter(wr, " ") - if _, err := fmt.Fprintf(wr, t.Color("interface", t.Bold, t.FgGreen)+": "+t.Color("%s", t.FgGreen)+"\n", i.Name); err != nil { + if _, err := fmt.Fprintf(wr, t.Mods("interface", t.Bold, t.FgGreen)+": "+t.Mods("%s", t.FgGreen)+"\n", i.Name); err != nil { return err } diff --git a/pkg/proto/core/interface.pb.go b/pkg/proto/core/interface.pb.go index 15b779b9..7872b0b9 100644 --- a/pkg/proto/core/interface.pb.go +++ b/pkg/proto/core/interface.pb.go @@ -8,7 +8,7 @@ package core import ( proto "github.com/stv0g/cunicu/pkg/proto" - epdisc "github.com/stv0g/cunicu/pkg/proto/feat/epdisc" + epdisc "github.com/stv0g/cunicu/pkg/proto/feature/epdisc" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -214,43 +214,43 @@ var file_core_interface_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x1a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x65, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x11, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x99, 0x03, 0x0a, 0x09, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, - 0x61, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x63, - 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, - 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, - 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, - 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x72, 0x69, - 0x76, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x73, 0x74, 0x65, - 0x6e, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x6c, 0x69, - 0x73, 0x74, 0x65, 0x6e, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x69, 0x72, 0x65, - 0x77, 0x61, 0x6c, 0x6c, 0x5f, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, - 0x0c, 0x66, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x4d, 0x61, 0x72, 0x6b, 0x12, 0x27, 0x0a, - 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, - 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, - 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x12, 0x2a, 0x0a, 0x03, 0x69, 0x63, 0x65, 0x18, 0x08, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, - 0x69, 0x73, 0x63, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x03, 0x69, - 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x66, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x07, 0x69, 0x66, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x10, 0x0a, 0x03, - 0x6d, 0x74, 0x75, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6d, 0x74, 0x75, 0x12, 0x41, - 0x0a, 0x13, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, - 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x11, - 0x6c, 0x61, 0x73, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x2a, 0x65, 0x0a, 0x0d, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, - 0x10, 0x0a, 0x0c, 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x5f, 0x4b, 0x45, 0x52, 0x4e, 0x45, 0x4c, 0x10, - 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x4f, 0x50, 0x45, 0x4e, 0x42, 0x53, 0x44, 0x5f, 0x4b, 0x45, 0x52, - 0x4e, 0x45, 0x4c, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x57, 0x49, 0x4e, 0x44, 0x4f, 0x57, 0x53, - 0x5f, 0x4b, 0x45, 0x52, 0x4e, 0x45, 0x4c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x53, 0x45, - 0x52, 0x53, 0x50, 0x41, 0x43, 0x45, 0x10, 0x04, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, - 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, - 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x6f, 0x1a, 0x14, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x65, 0x70, 0x64, 0x69, + 0x73, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x99, 0x03, 0x0a, 0x09, 0x49, 0x6e, 0x74, + 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, + 0x75, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, + 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, + 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x69, + 0x76, 0x61, 0x74, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, + 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, + 0x73, 0x74, 0x65, 0x6e, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x0a, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x66, + 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x5f, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x0c, 0x66, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x4d, 0x61, 0x72, 0x6b, + 0x12, 0x27, 0x0a, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x65, + 0x65, 0x72, 0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x12, 0x2a, 0x0a, 0x03, 0x69, 0x63, 0x65, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, + 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, + 0x52, 0x03, 0x69, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x66, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x69, 0x66, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, + 0x10, 0x0a, 0x03, 0x6d, 0x74, 0x75, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6d, 0x74, + 0x75, 0x12, 0x41, 0x0a, 0x13, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, + 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x52, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x2a, 0x65, 0x0a, 0x0d, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, + 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x5f, 0x4b, 0x45, 0x52, 0x4e, + 0x45, 0x4c, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x4f, 0x50, 0x45, 0x4e, 0x42, 0x53, 0x44, 0x5f, + 0x4b, 0x45, 0x52, 0x4e, 0x45, 0x4c, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x57, 0x49, 0x4e, 0x44, + 0x4f, 0x57, 0x53, 0x5f, 0x4b, 0x45, 0x52, 0x4e, 0x45, 0x4c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, + 0x55, 0x53, 0x45, 0x52, 0x53, 0x50, 0x41, 0x43, 0x45, 0x10, 0x04, 0x42, 0x28, 0x5a, 0x26, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, + 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/proto/core/peer.go b/pkg/proto/core/peer.go index 0a63f32d..1d0c7281 100644 --- a/pkg/proto/core/peer.go +++ b/pkg/proto/core/peer.go @@ -53,7 +53,7 @@ func (p *Peer) Peer() wgtypes.Peer { func (p *Peer) Dump(wr io.Writer, verbosity int) error { wri := t.NewIndenter(wr, " ") - if _, err := fmt.Fprintf(wr, t.Color("peer", t.Bold, t.FgYellow)+": "+t.Color("%s", t.FgYellow)+"\n", base64.StdEncoding.EncodeToString(p.PublicKey)); err != nil { + if _, err := fmt.Fprintf(wr, t.Mods("peer", t.Bold, t.FgYellow)+": "+t.Mods("%s", t.FgYellow)+"\n", base64.StdEncoding.EncodeToString(p.PublicKey)); err != nil { return err } diff --git a/pkg/proto/core/peer.pb.go b/pkg/proto/core/peer.pb.go index 87c32c8d..69ace794 100644 --- a/pkg/proto/core/peer.pb.go +++ b/pkg/proto/core/peer.pb.go @@ -8,7 +8,7 @@ package core import ( proto "github.com/stv0g/cunicu/pkg/proto" - epdisc "github.com/stv0g/cunicu/pkg/proto/feat/epdisc" + epdisc "github.com/stv0g/cunicu/pkg/proto/feature/epdisc" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -168,48 +168,49 @@ var File_core_peer_proto protoreflect.FileDescriptor var file_core_peer_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x65, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x1a, 0x0c, - 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x11, 0x66, 0x65, - 0x61, 0x74, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0xca, 0x04, 0x0a, 0x04, 0x50, 0x65, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, - 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, - 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x65, 0x73, 0x68, - 0x61, 0x72, 0x65, 0x64, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, - 0x70, 0x72, 0x65, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, - 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x69, 0x70, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x49, 0x70, 0x73, 0x12, 0x42, 0x0a, - 0x1d, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x65, 0x70, - 0x61, 0x6c, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x1b, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x74, - 0x4b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, - 0x6c, 0x12, 0x4b, 0x0a, 0x18, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x68, 0x61, 0x6e, 0x64, 0x73, 0x68, - 0x61, 0x6b, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x16, 0x6c, 0x61, 0x73, 0x74, 0x48, 0x61, 0x6e, 0x64, - 0x73, 0x68, 0x61, 0x6b, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x47, - 0x0a, 0x16, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, - 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x52, 0x14, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x49, 0x0a, 0x17, 0x6c, 0x61, 0x73, 0x74, 0x5f, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, - 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x15, 0x6c, 0x61, 0x73, - 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x5f, 0x62, - 0x79, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x6d, 0x69, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x63, - 0x65, 0x69, 0x76, 0x65, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1a, - 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0b, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x03, 0x69, 0x63, 0x65, 0x18, 0x0c, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, - 0x73, 0x63, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x03, 0x69, 0x63, 0x65, 0x42, 0x28, 0x5a, 0x26, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, - 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x66, 0x65, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0xca, 0x04, 0x0a, 0x04, 0x50, 0x65, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, + 0x65, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x0c, 0x70, 0x72, 0x65, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x12, + 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x69, 0x70, 0x73, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x49, 0x70, 0x73, + 0x12, 0x42, 0x0a, 0x1d, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x6b, + 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, + 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x1b, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, + 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, 0x65, + 0x72, 0x76, 0x61, 0x6c, 0x12, 0x4b, 0x0a, 0x18, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x68, 0x61, 0x6e, + 0x64, 0x73, 0x68, 0x61, 0x6b, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x16, 0x6c, 0x61, 0x73, 0x74, 0x48, + 0x61, 0x6e, 0x64, 0x73, 0x68, 0x61, 0x6b, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x12, 0x47, 0x0a, 0x16, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, + 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x14, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, + 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x49, 0x0a, 0x17, 0x6c, 0x61, + 0x73, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, + 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x15, + 0x6c, 0x61, 0x73, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, + 0x74, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x23, 0x0a, 0x0d, + 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x42, 0x79, 0x74, 0x65, + 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x0a, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x29, 0x0a, + 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x03, 0x69, 0x63, 0x65, 0x18, + 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, + 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x03, 0x69, 0x63, 0x65, 0x42, + 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, + 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/pkg/proto/feat/epdisc/epdisc.go b/pkg/proto/feature/epdisc/epdisc.go similarity index 75% rename from pkg/proto/feat/epdisc/epdisc.go rename to pkg/proto/feature/epdisc/epdisc.go index 0d4c4865..047637c9 100644 --- a/pkg/proto/feat/epdisc/epdisc.go +++ b/pkg/proto/feature/epdisc/epdisc.go @@ -7,10 +7,12 @@ import ( "github.com/pion/ice/v2" "github.com/pion/randutil" - icex "github.com/stv0g/cunicu/pkg/feat/epdisc/ice" - "github.com/stv0g/cunicu/pkg/util" - t "github.com/stv0g/cunicu/pkg/util/terminal" "golang.org/x/exp/slices" + + "github.com/stv0g/cunicu/pkg/util" + "github.com/stv0g/cunicu/pkg/util/terminal" + + icex "github.com/stv0g/cunicu/pkg/ice" ) const ( @@ -36,12 +38,12 @@ func NewCredentials() Credentials { } func (i *Interface) Dump(wr io.Writer, verbosity int) error { - if _, err := t.FprintKV(wr, "nat type", i.NatType); err != nil { + if _, err := terminal.FprintKV(wr, "nat type", i.NatType); err != nil { return err } if i.NatType == NATType_NAT_NFTABLES { - if _, err := t.FprintKV(wr, "mux ports", fmt.Sprintf("%d, %d", i.MuxPort, i.MuxSrflxPort)); err != nil { + if _, err := terminal.FprintKV(wr, "mux ports", fmt.Sprintf("%d, %d", i.MuxPort, i.MuxSrflxPort)); err != nil { return err } } @@ -52,24 +54,24 @@ func (i *Interface) Dump(wr io.Writer, verbosity int) error { func (p *Peer) Dump(wr io.Writer, verbosity int) error { var v string - if _, err := t.FprintKV(wr, "state", t.Color(p.State.String(), t.Bold, p.State.Color())); err != nil { + if _, err := terminal.FprintKV(wr, "state", terminal.Mods(p.State.String(), terminal.Bold, p.State.Color())); err != nil { return err } - if _, err := t.FprintKV(wr, "proxy type", p.ProxyType); err != nil { + if _, err := terminal.FprintKV(wr, "proxy type", p.ProxyType); err != nil { return err } - if _, err := t.FprintKV(wr, "reachability", p.Reachability); err != nil { + if _, err := terminal.FprintKV(wr, "reachability", p.Reachability); err != nil { return err } - if _, err := t.FprintKV(wr, "latest state change", util.Ago(p.LastStateChangeTimestamp.Time())); err != nil { + if _, err := terminal.FprintKV(wr, "latest state change", util.Ago(p.LastStateChangeTimestamp.Time())); err != nil { return err } if p.Restarts > 0 { - if _, err := t.FprintKV(wr, "restarts", p.Restarts); err != nil { + if _, err := terminal.FprintKV(wr, "restarts", p.Restarts); err != nil { return err } } @@ -86,17 +88,17 @@ func (p *Peer) Dump(wr io.Writer, verbosity int) error { } } - if _, err := t.FprintKV(wr, "\ncandidates"); err != nil { + if _, err := terminal.FprintKV(wr, "\ncandidates"); err != nil { return err } - wr := t.NewIndenter(wr, " ") - wri := t.NewIndenter(wr, " ") + wr := terminal.NewIndenter(wr, " ") + wri := terminal.NewIndenter(wr, " ") if len(p.LocalCandidateStats) > 0 { slices.SortFunc(p.LocalCandidateStats, func(a, b *CandidateStats) bool { return a.Priority < b.Priority }) - if _, err := t.FprintKV(wr, "local"); err != nil { + if _, err := terminal.FprintKV(wr, "local"); err != nil { return err } @@ -104,9 +106,9 @@ func (p *Peer) Dump(wr io.Writer, verbosity int) error { cmap[cs.Id] = i v = fmt.Sprintf("l%d", i) if isNominated := cs.Id == cpsNom.LocalCandidateId; isNominated { - v = t.Color(v, t.FgRed) + v = terminal.Mods(v, terminal.FgRed) } - if _, err := t.FprintKV(wri, v, cs.ToString()); err != nil { + if _, err := terminal.FprintKV(wri, v, cs.ToString()); err != nil { return err } } @@ -115,7 +117,7 @@ func (p *Peer) Dump(wr io.Writer, verbosity int) error { if len(p.RemoteCandidateStats) > 0 { slices.SortFunc(p.RemoteCandidateStats, func(a, b *CandidateStats) bool { return a.Priority < b.Priority }) - if _, err := t.FprintKV(wr, "\nremote"); err != nil { + if _, err := terminal.FprintKV(wr, "\nremote"); err != nil { return err } @@ -123,16 +125,16 @@ func (p *Peer) Dump(wr io.Writer, verbosity int) error { cmap[cs.Id] = i v = fmt.Sprintf("r%d", i) if isNominated := cs.Id == cpsNom.RemoteCandidateId; isNominated { - v = t.Color(v, t.FgRed) + v = terminal.Mods(v, terminal.FgRed) } - if _, err := t.FprintKV(wri, v, cs.ToString()); err != nil { + if _, err := terminal.FprintKV(wri, v, cs.ToString()); err != nil { return err } } } if len(p.CandidatePairStats) > 0 && verbosity > 6 { - if _, err := t.FprintKV(wr, "\npairs"); err != nil { + if _, err := terminal.FprintKV(wr, "\npairs"); err != nil { return err } @@ -146,14 +148,14 @@ func (p *Peer) Dump(wr io.Writer, verbosity int) error { v = fmt.Sprintf("p%d", i) if cps.Nominated { - v = t.Color(v, t.FgRed) + v = terminal.Mods(v, terminal.FgRed) } if cps.Nominated { flags = append(flags, "nominated") } - if _, err := t.FprintKV(wri, v, fmt.Sprintf("l%d <-> r%d, %s", + if _, err := terminal.FprintKV(wri, v, fmt.Sprintf("l%d <-> r%d, %s", lci, rci, strings.Join(flags, ", "), )); err != nil { @@ -229,13 +231,13 @@ func (s *ConnectionState) ConnectionState() icex.ConnectionState { func (s *ConnectionState) Color() string { switch *s { case ConnectionState_CHECKING: - return t.FgYellow + return terminal.FgYellow case ConnectionState_CONNECTED: - return t.FgGreen + return terminal.FgGreen case ConnectionState_FAILED: fallthrough case ConnectionState_DISCONNECTED: - return t.FgRed + return terminal.FgRed case ConnectionState_NEW: fallthrough case ConnectionState_COMPLETED: @@ -249,10 +251,10 @@ func (s *ConnectionState) Color() string { case ConnectionState_CONNECTING: fallthrough case ConnectionState_IDLE: - return t.FgWhite + return terminal.FgWhite } - return t.FgDefault + return terminal.FgDefault } func (s *ConnectionState) MarshalText() ([]byte, error) { diff --git a/pkg/proto/feat/epdisc/epdisc.pb.go b/pkg/proto/feature/epdisc/epdisc.pb.go similarity index 58% rename from pkg/proto/feat/epdisc/epdisc.pb.go rename to pkg/proto/feature/epdisc/epdisc.pb.go index 17ee6682..adc6d77b 100644 --- a/pkg/proto/feat/epdisc/epdisc.pb.go +++ b/pkg/proto/feature/epdisc/epdisc.pb.go @@ -2,7 +2,7 @@ // versions: // protoc-gen-go v1.28.1 // protoc v3.6.1 -// source: feat/epdisc.proto +// source: feature/epdisc.proto package epdisc @@ -80,11 +80,11 @@ func (x ConnectionState) String() string { } func (ConnectionState) Descriptor() protoreflect.EnumDescriptor { - return file_feat_epdisc_proto_enumTypes[0].Descriptor() + return file_feature_epdisc_proto_enumTypes[0].Descriptor() } func (ConnectionState) Type() protoreflect.EnumType { - return &file_feat_epdisc_proto_enumTypes[0] + return &file_feature_epdisc_proto_enumTypes[0] } func (x ConnectionState) Number() protoreflect.EnumNumber { @@ -93,7 +93,7 @@ func (x ConnectionState) Number() protoreflect.EnumNumber { // Deprecated: Use ConnectionState.Descriptor instead. func (ConnectionState) EnumDescriptor() ([]byte, []int) { - return file_feat_epdisc_proto_rawDescGZIP(), []int{0} + return file_feature_epdisc_proto_rawDescGZIP(), []int{0} } type Reachability int32 @@ -138,11 +138,11 @@ func (x Reachability) String() string { } func (Reachability) Descriptor() protoreflect.EnumDescriptor { - return file_feat_epdisc_proto_enumTypes[1].Descriptor() + return file_feature_epdisc_proto_enumTypes[1].Descriptor() } func (Reachability) Type() protoreflect.EnumType { - return &file_feat_epdisc_proto_enumTypes[1] + return &file_feature_epdisc_proto_enumTypes[1] } func (x Reachability) Number() protoreflect.EnumNumber { @@ -151,7 +151,7 @@ func (x Reachability) Number() protoreflect.EnumNumber { // Deprecated: Use Reachability.Descriptor instead. func (Reachability) EnumDescriptor() ([]byte, []int) { - return file_feat_epdisc_proto_rawDescGZIP(), []int{1} + return file_feature_epdisc_proto_rawDescGZIP(), []int{1} } type NATType int32 @@ -181,11 +181,11 @@ func (x NATType) String() string { } func (NATType) Descriptor() protoreflect.EnumDescriptor { - return file_feat_epdisc_proto_enumTypes[2].Descriptor() + return file_feature_epdisc_proto_enumTypes[2].Descriptor() } func (NATType) Type() protoreflect.EnumType { - return &file_feat_epdisc_proto_enumTypes[2] + return &file_feature_epdisc_proto_enumTypes[2] } func (x NATType) Number() protoreflect.EnumNumber { @@ -194,7 +194,7 @@ func (x NATType) Number() protoreflect.EnumNumber { // Deprecated: Use NATType.Descriptor instead. func (NATType) EnumDescriptor() ([]byte, []int) { - return file_feat_epdisc_proto_rawDescGZIP(), []int{2} + return file_feature_epdisc_proto_rawDescGZIP(), []int{2} } type ProxyType int32 @@ -233,11 +233,11 @@ func (x ProxyType) String() string { } func (ProxyType) Descriptor() protoreflect.EnumDescriptor { - return file_feat_epdisc_proto_enumTypes[3].Descriptor() + return file_feature_epdisc_proto_enumTypes[3].Descriptor() } func (ProxyType) Type() protoreflect.EnumType { - return &file_feat_epdisc_proto_enumTypes[3] + return &file_feature_epdisc_proto_enumTypes[3] } func (x ProxyType) Number() protoreflect.EnumNumber { @@ -246,7 +246,7 @@ func (x ProxyType) Number() protoreflect.EnumNumber { // Deprecated: Use ProxyType.Descriptor instead. func (ProxyType) EnumDescriptor() ([]byte, []int) { - return file_feat_epdisc_proto_rawDescGZIP(), []int{3} + return file_feature_epdisc_proto_rawDescGZIP(), []int{3} } type Credentials struct { @@ -265,7 +265,7 @@ type Credentials struct { func (x *Credentials) Reset() { *x = Credentials{} if protoimpl.UnsafeEnabled { - mi := &file_feat_epdisc_proto_msgTypes[0] + mi := &file_feature_epdisc_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -278,7 +278,7 @@ func (x *Credentials) String() string { func (*Credentials) ProtoMessage() {} func (x *Credentials) ProtoReflect() protoreflect.Message { - mi := &file_feat_epdisc_proto_msgTypes[0] + mi := &file_feature_epdisc_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -291,7 +291,7 @@ func (x *Credentials) ProtoReflect() protoreflect.Message { // Deprecated: Use Credentials.ProtoReflect.Descriptor instead. func (*Credentials) Descriptor() ([]byte, []int) { - return file_feat_epdisc_proto_rawDescGZIP(), []int{0} + return file_feature_epdisc_proto_rawDescGZIP(), []int{0} } func (x *Credentials) GetUfrag() string { @@ -328,7 +328,7 @@ type Interface struct { func (x *Interface) Reset() { *x = Interface{} if protoimpl.UnsafeEnabled { - mi := &file_feat_epdisc_proto_msgTypes[1] + mi := &file_feature_epdisc_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -341,7 +341,7 @@ func (x *Interface) String() string { func (*Interface) ProtoMessage() {} func (x *Interface) ProtoReflect() protoreflect.Message { - mi := &file_feat_epdisc_proto_msgTypes[1] + mi := &file_feature_epdisc_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -354,7 +354,7 @@ func (x *Interface) ProtoReflect() protoreflect.Message { // Deprecated: Use Interface.ProtoReflect.Descriptor instead. func (*Interface) Descriptor() ([]byte, []int) { - return file_feat_epdisc_proto_rawDescGZIP(), []int{1} + return file_feature_epdisc_proto_rawDescGZIP(), []int{1} } func (x *Interface) GetNatType() NATType { @@ -397,7 +397,7 @@ type Peer struct { func (x *Peer) Reset() { *x = Peer{} if protoimpl.UnsafeEnabled { - mi := &file_feat_epdisc_proto_msgTypes[2] + mi := &file_feature_epdisc_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -410,7 +410,7 @@ func (x *Peer) String() string { func (*Peer) ProtoMessage() {} func (x *Peer) ProtoReflect() protoreflect.Message { - mi := &file_feat_epdisc_proto_msgTypes[2] + mi := &file_feature_epdisc_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -423,7 +423,7 @@ func (x *Peer) ProtoReflect() protoreflect.Message { // Deprecated: Use Peer.ProtoReflect.Descriptor instead. func (*Peer) Descriptor() ([]byte, []int) { - return file_feat_epdisc_proto_rawDescGZIP(), []int{2} + return file_feature_epdisc_proto_rawDescGZIP(), []int{2} } func (x *Peer) GetProxyType() ProxyType { @@ -489,112 +489,112 @@ func (x *Peer) GetReachability() Reachability { return Reachability_NO_REACHABILITY } -var File_feat_epdisc_proto protoreflect.FileDescriptor +var File_feature_epdisc_proto protoreflect.FileDescriptor -var file_feat_epdisc_proto_rawDesc = []byte{ - 0x0a, 0x11, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, - 0x73, 0x63, 0x1a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x1b, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x5f, 0x63, 0x61, - 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x54, 0x0a, - 0x0b, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x12, 0x14, 0x0a, 0x05, - 0x75, 0x66, 0x72, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x75, 0x66, 0x72, - 0x61, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x77, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x70, 0x77, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x65, 0x65, 0x64, 0x5f, 0x63, 0x72, 0x65, - 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6e, 0x65, 0x65, 0x64, 0x43, 0x72, - 0x65, 0x64, 0x73, 0x22, 0x7f, 0x0a, 0x09, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, - 0x12, 0x31, 0x0a, 0x08, 0x6e, 0x61, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, - 0x73, 0x63, 0x2e, 0x4e, 0x41, 0x54, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x6e, 0x61, 0x74, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6d, 0x75, 0x78, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x6d, 0x75, 0x78, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x24, - 0x0a, 0x0e, 0x6d, 0x75, 0x78, 0x5f, 0x73, 0x72, 0x66, 0x6c, 0x78, 0x5f, 0x70, 0x6f, 0x72, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x6d, 0x75, 0x78, 0x53, 0x72, 0x66, 0x6c, 0x78, - 0x50, 0x6f, 0x72, 0x74, 0x22, 0xf7, 0x04, 0x0a, 0x04, 0x50, 0x65, 0x65, 0x72, 0x12, 0x37, 0x0a, - 0x0a, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x18, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, - 0x63, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x34, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, - 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x54, 0x0a, 0x17, - 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x5f, 0x70, 0x61, 0x69, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, - 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, - 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x69, 0x72, 0x52, 0x15, 0x73, 0x65, 0x6c, - 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, - 0x69, 0x72, 0x12, 0x51, 0x0a, 0x15, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x63, 0x61, 0x6e, 0x64, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, - 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, - 0x52, 0x13, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x53, 0x0a, 0x16, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x5f, - 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, - 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, - 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x53, - 0x74, 0x61, 0x74, 0x73, 0x52, 0x14, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x61, 0x6e, 0x64, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x53, 0x0a, 0x14, 0x63, 0x61, - 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x61, 0x69, 0x72, 0x5f, 0x73, 0x74, 0x61, - 0x74, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, - 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x50, 0x61, 0x69, 0x72, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x12, 0x63, 0x61, 0x6e, - 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x69, 0x72, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, - 0x50, 0x0a, 0x1b, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x68, - 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x09, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x18, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x18, 0x0a, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x12, 0x3f, 0x0a, - 0x0c, 0x72, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x18, 0x0b, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, - 0x69, 0x73, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, - 0x52, 0x0c, 0x72, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2a, 0xa5, - 0x01, 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4e, 0x45, 0x57, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x43, - 0x48, 0x45, 0x43, 0x4b, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, - 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4d, 0x50, - 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x41, 0x49, 0x4c, 0x45, - 0x44, 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x49, 0x53, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, - 0x54, 0x45, 0x44, 0x10, 0x05, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, - 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x52, 0x45, 0x41, 0x54, 0x49, 0x4e, 0x47, 0x10, 0x64, 0x12, - 0x08, 0x0a, 0x04, 0x49, 0x44, 0x4c, 0x45, 0x10, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x4f, 0x4e, - 0x4e, 0x45, 0x43, 0x54, 0x49, 0x4e, 0x47, 0x10, 0x66, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4c, 0x4f, - 0x53, 0x49, 0x4e, 0x47, 0x10, 0x67, 0x2a, 0x6d, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, - 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x13, 0x0a, 0x0f, 0x4e, 0x4f, 0x5f, 0x52, 0x45, 0x41, - 0x43, 0x48, 0x41, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x44, - 0x49, 0x52, 0x45, 0x43, 0x54, 0x5f, 0x55, 0x44, 0x50, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x44, - 0x49, 0x52, 0x45, 0x43, 0x54, 0x5f, 0x54, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, - 0x45, 0x4c, 0x41, 0x59, 0x5f, 0x55, 0x44, 0x50, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x45, - 0x4c, 0x41, 0x59, 0x5f, 0x54, 0x43, 0x50, 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x52, 0x4f, 0x55, - 0x54, 0x45, 0x44, 0x10, 0x05, 0x2a, 0x1b, 0x0a, 0x07, 0x4e, 0x41, 0x54, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x10, 0x0a, 0x0c, 0x4e, 0x41, 0x54, 0x5f, 0x4e, 0x46, 0x54, 0x41, 0x42, 0x4c, 0x45, 0x53, - 0x10, 0x00, 0x2a, 0x49, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x0c, 0x0a, 0x08, 0x4e, 0x4f, 0x5f, 0x50, 0x52, 0x4f, 0x58, 0x59, 0x10, 0x00, 0x12, 0x0d, 0x0a, - 0x09, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x42, 0x49, 0x4e, 0x44, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, - 0x4b, 0x45, 0x52, 0x4e, 0x45, 0x4c, 0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x10, 0x02, 0x12, 0x0e, 0x0a, - 0x0a, 0x4b, 0x45, 0x52, 0x4e, 0x45, 0x4c, 0x5f, 0x4e, 0x41, 0x54, 0x10, 0x03, 0x42, 0x2f, 0x5a, - 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, - 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +var file_feature_epdisc_proto_rawDesc = []byte{ + 0x0a, 0x14, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, + 0x70, 0x64, 0x69, 0x73, 0x63, 0x1a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x65, 0x70, 0x64, + 0x69, 0x73, 0x63, 0x5f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0x54, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, + 0x6c, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x75, 0x66, 0x72, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x75, 0x66, 0x72, 0x61, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x77, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x77, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x65, + 0x65, 0x64, 0x5f, 0x63, 0x72, 0x65, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, + 0x6e, 0x65, 0x65, 0x64, 0x43, 0x72, 0x65, 0x64, 0x73, 0x22, 0x7f, 0x0a, 0x09, 0x49, 0x6e, 0x74, + 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x31, 0x0a, 0x08, 0x6e, 0x61, 0x74, 0x5f, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, + 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x4e, 0x41, 0x54, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x07, 0x6e, 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6d, 0x75, 0x78, + 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x6d, 0x75, 0x78, + 0x50, 0x6f, 0x72, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x75, 0x78, 0x5f, 0x73, 0x72, 0x66, 0x6c, + 0x78, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x6d, 0x75, + 0x78, 0x53, 0x72, 0x66, 0x6c, 0x78, 0x50, 0x6f, 0x72, 0x74, 0x22, 0xf7, 0x04, 0x0a, 0x04, 0x50, + 0x65, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, + 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x54, 0x79, 0x70, + 0x65, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x34, 0x0a, 0x05, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x75, + 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x12, 0x54, 0x0a, 0x17, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, + 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x61, 0x69, 0x72, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, + 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x69, + 0x72, 0x52, 0x15, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x61, 0x6e, 0x64, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x69, 0x72, 0x12, 0x51, 0x0a, 0x15, 0x6c, 0x6f, 0x63, 0x61, + 0x6c, 0x5f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, + 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, + 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, + 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x13, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x43, 0x61, 0x6e, + 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x53, 0x0a, 0x16, 0x72, + 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x5f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x75, + 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x14, 0x72, 0x65, 0x6d, 0x6f, + 0x74, 0x65, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, + 0x12, 0x53, 0x0a, 0x14, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x61, + 0x69, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, + 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, + 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x69, 0x72, 0x53, 0x74, 0x61, 0x74, + 0x73, 0x52, 0x12, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x69, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x50, 0x0a, 0x1b, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, + 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x18, 0x6c, + 0x61, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x74, 0x61, + 0x72, 0x74, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x73, 0x74, 0x61, + 0x72, 0x74, 0x73, 0x12, 0x3f, 0x0a, 0x0c, 0x72, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, + 0x69, 0x74, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x63, 0x75, 0x6e, 0x69, + 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, + 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x0c, 0x72, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, + 0x6c, 0x69, 0x74, 0x79, 0x2a, 0xa5, 0x01, 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4e, 0x45, 0x57, 0x10, + 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x48, 0x45, 0x43, 0x4b, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, + 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0d, + 0x0a, 0x09, 0x43, 0x4f, 0x4d, 0x50, 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x03, 0x12, 0x0a, 0x0a, + 0x06, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x49, 0x53, + 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x05, 0x12, 0x0a, 0x0a, 0x06, 0x43, + 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x52, 0x45, 0x41, 0x54, + 0x49, 0x4e, 0x47, 0x10, 0x64, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x44, 0x4c, 0x45, 0x10, 0x65, 0x12, + 0x0e, 0x0a, 0x0a, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x49, 0x4e, 0x47, 0x10, 0x66, 0x12, + 0x0b, 0x0a, 0x07, 0x43, 0x4c, 0x4f, 0x53, 0x49, 0x4e, 0x47, 0x10, 0x67, 0x2a, 0x6d, 0x0a, 0x0c, + 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x13, 0x0a, 0x0f, + 0x4e, 0x4f, 0x5f, 0x52, 0x45, 0x41, 0x43, 0x48, 0x41, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x10, + 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x5f, 0x55, 0x44, 0x50, 0x10, + 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x5f, 0x54, 0x43, 0x50, 0x10, + 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x45, 0x4c, 0x41, 0x59, 0x5f, 0x55, 0x44, 0x50, 0x10, 0x03, + 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x45, 0x4c, 0x41, 0x59, 0x5f, 0x54, 0x43, 0x50, 0x10, 0x04, 0x12, + 0x0a, 0x0a, 0x06, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x44, 0x10, 0x05, 0x2a, 0x1b, 0x0a, 0x07, 0x4e, + 0x41, 0x54, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x4e, 0x41, 0x54, 0x5f, 0x4e, 0x46, + 0x54, 0x41, 0x42, 0x4c, 0x45, 0x53, 0x10, 0x00, 0x2a, 0x49, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x78, + 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x4e, 0x4f, 0x5f, 0x50, 0x52, 0x4f, 0x58, + 0x59, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x42, 0x49, 0x4e, 0x44, + 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x4b, 0x45, 0x52, 0x4e, 0x45, 0x4c, 0x5f, 0x43, 0x4f, 0x4e, + 0x4e, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x4b, 0x45, 0x52, 0x4e, 0x45, 0x4c, 0x5f, 0x4e, 0x41, + 0x54, 0x10, 0x03, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, + 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_feat_epdisc_proto_rawDescOnce sync.Once - file_feat_epdisc_proto_rawDescData = file_feat_epdisc_proto_rawDesc + file_feature_epdisc_proto_rawDescOnce sync.Once + file_feature_epdisc_proto_rawDescData = file_feature_epdisc_proto_rawDesc ) -func file_feat_epdisc_proto_rawDescGZIP() []byte { - file_feat_epdisc_proto_rawDescOnce.Do(func() { - file_feat_epdisc_proto_rawDescData = protoimpl.X.CompressGZIP(file_feat_epdisc_proto_rawDescData) +func file_feature_epdisc_proto_rawDescGZIP() []byte { + file_feature_epdisc_proto_rawDescOnce.Do(func() { + file_feature_epdisc_proto_rawDescData = protoimpl.X.CompressGZIP(file_feature_epdisc_proto_rawDescData) }) - return file_feat_epdisc_proto_rawDescData + return file_feature_epdisc_proto_rawDescData } -var file_feat_epdisc_proto_enumTypes = make([]protoimpl.EnumInfo, 4) -var file_feat_epdisc_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_feat_epdisc_proto_goTypes = []interface{}{ +var file_feature_epdisc_proto_enumTypes = make([]protoimpl.EnumInfo, 4) +var file_feature_epdisc_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_feature_epdisc_proto_goTypes = []interface{}{ (ConnectionState)(0), // 0: cunicu.epdisc.ConnectionState (Reachability)(0), // 1: cunicu.epdisc.Reachability (NATType)(0), // 2: cunicu.epdisc.NATType @@ -607,7 +607,7 @@ var file_feat_epdisc_proto_goTypes = []interface{}{ (*CandidatePairStats)(nil), // 9: cunicu.epdisc.CandidatePairStats (*proto.Timestamp)(nil), // 10: cunicu.Timestamp } -var file_feat_epdisc_proto_depIdxs = []int32{ +var file_feature_epdisc_proto_depIdxs = []int32{ 2, // 0: cunicu.epdisc.Interface.nat_type:type_name -> cunicu.epdisc.NATType 3, // 1: cunicu.epdisc.Peer.proxy_type:type_name -> cunicu.epdisc.ProxyType 0, // 2: cunicu.epdisc.Peer.state:type_name -> cunicu.epdisc.ConnectionState @@ -624,14 +624,14 @@ var file_feat_epdisc_proto_depIdxs = []int32{ 0, // [0:9] is the sub-list for field type_name } -func init() { file_feat_epdisc_proto_init() } -func file_feat_epdisc_proto_init() { - if File_feat_epdisc_proto != nil { +func init() { file_feature_epdisc_proto_init() } +func file_feature_epdisc_proto_init() { + if File_feature_epdisc_proto != nil { return } - file_feat_epdisc_candidate_proto_init() + file_feature_epdisc_candidate_proto_init() if !protoimpl.UnsafeEnabled { - file_feat_epdisc_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_feature_epdisc_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Credentials); i { case 0: return &v.state @@ -643,7 +643,7 @@ func file_feat_epdisc_proto_init() { return nil } } - file_feat_epdisc_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_feature_epdisc_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Interface); i { case 0: return &v.state @@ -655,7 +655,7 @@ func file_feat_epdisc_proto_init() { return nil } } - file_feat_epdisc_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_feature_epdisc_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Peer); i { case 0: return &v.state @@ -672,19 +672,19 @@ func file_feat_epdisc_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_feat_epdisc_proto_rawDesc, + RawDescriptor: file_feature_epdisc_proto_rawDesc, NumEnums: 4, NumMessages: 3, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_feat_epdisc_proto_goTypes, - DependencyIndexes: file_feat_epdisc_proto_depIdxs, - EnumInfos: file_feat_epdisc_proto_enumTypes, - MessageInfos: file_feat_epdisc_proto_msgTypes, + GoTypes: file_feature_epdisc_proto_goTypes, + DependencyIndexes: file_feature_epdisc_proto_depIdxs, + EnumInfos: file_feature_epdisc_proto_enumTypes, + MessageInfos: file_feature_epdisc_proto_msgTypes, }.Build() - File_feat_epdisc_proto = out.File - file_feat_epdisc_proto_rawDesc = nil - file_feat_epdisc_proto_goTypes = nil - file_feat_epdisc_proto_depIdxs = nil + File_feature_epdisc_proto = out.File + file_feature_epdisc_proto_rawDesc = nil + file_feature_epdisc_proto_goTypes = nil + file_feature_epdisc_proto_depIdxs = nil } diff --git a/pkg/proto/feat/epdisc/epdisc_candidate.go b/pkg/proto/feature/epdisc/epdisc_candidate.go similarity index 97% rename from pkg/proto/feat/epdisc/epdisc_candidate.go rename to pkg/proto/feature/epdisc/epdisc_candidate.go index 3046f710..050f86de 100644 --- a/pkg/proto/feat/epdisc/epdisc_candidate.go +++ b/pkg/proto/feature/epdisc/epdisc_candidate.go @@ -183,7 +183,7 @@ func (cs *CandidateStats) ToString() string { func (cs *CandidateStats) Dump(wr io.Writer) error { // wri := util.NewIndenter(wr, " ") - if _, err := fmt.Fprintf(wr, t.Color("candidate", t.Bold, t.FgMagenta)+": "+t.Color("%s", t.FgMagenta)+"\n", cs.ToString()); err != nil { + if _, err := fmt.Fprintf(wr, t.Mods("candidate", t.Bold, t.FgMagenta)+": "+t.Mods("%s", t.FgMagenta)+"\n", cs.ToString()); err != nil { return err } diff --git a/pkg/proto/feat/epdisc/epdisc_candidate.pb.go b/pkg/proto/feature/epdisc/epdisc_candidate.pb.go similarity index 61% rename from pkg/proto/feat/epdisc/epdisc_candidate.pb.go rename to pkg/proto/feature/epdisc/epdisc_candidate.pb.go index 80dd07a7..bce5b610 100644 --- a/pkg/proto/feat/epdisc/epdisc_candidate.pb.go +++ b/pkg/proto/feature/epdisc/epdisc_candidate.pb.go @@ -2,7 +2,7 @@ // versions: // protoc-gen-go v1.28.1 // protoc v3.6.1 -// source: feat/epdisc_candidate.proto +// source: feature/epdisc_candidate.proto package epdisc @@ -69,11 +69,11 @@ func (x CandidatePairState) String() string { } func (CandidatePairState) Descriptor() protoreflect.EnumDescriptor { - return file_feat_epdisc_candidate_proto_enumTypes[0].Descriptor() + return file_feature_epdisc_candidate_proto_enumTypes[0].Descriptor() } func (CandidatePairState) Type() protoreflect.EnumType { - return &file_feat_epdisc_candidate_proto_enumTypes[0] + return &file_feature_epdisc_candidate_proto_enumTypes[0] } func (x CandidatePairState) Number() protoreflect.EnumNumber { @@ -82,7 +82,7 @@ func (x CandidatePairState) Number() protoreflect.EnumNumber { // Deprecated: Use CandidatePairState.Descriptor instead. func (CandidatePairState) EnumDescriptor() ([]byte, []int) { - return file_feat_epdisc_candidate_proto_rawDescGZIP(), []int{0} + return file_feature_epdisc_candidate_proto_rawDescGZIP(), []int{0} } // ICE Candidate types @@ -126,11 +126,11 @@ func (x CandidateType) String() string { } func (CandidateType) Descriptor() protoreflect.EnumDescriptor { - return file_feat_epdisc_candidate_proto_enumTypes[1].Descriptor() + return file_feature_epdisc_candidate_proto_enumTypes[1].Descriptor() } func (CandidateType) Type() protoreflect.EnumType { - return &file_feat_epdisc_candidate_proto_enumTypes[1] + return &file_feature_epdisc_candidate_proto_enumTypes[1] } func (x CandidateType) Number() protoreflect.EnumNumber { @@ -139,7 +139,7 @@ func (x CandidateType) Number() protoreflect.EnumNumber { // Deprecated: Use CandidateType.Descriptor instead. func (CandidateType) EnumDescriptor() ([]byte, []int) { - return file_feat_epdisc_candidate_proto_rawDescGZIP(), []int{1} + return file_feature_epdisc_candidate_proto_rawDescGZIP(), []int{1} } type NetworkType int32 @@ -181,11 +181,11 @@ func (x NetworkType) String() string { } func (NetworkType) Descriptor() protoreflect.EnumDescriptor { - return file_feat_epdisc_candidate_proto_enumTypes[2].Descriptor() + return file_feature_epdisc_candidate_proto_enumTypes[2].Descriptor() } func (NetworkType) Type() protoreflect.EnumType { - return &file_feat_epdisc_candidate_proto_enumTypes[2] + return &file_feature_epdisc_candidate_proto_enumTypes[2] } func (x NetworkType) Number() protoreflect.EnumNumber { @@ -194,7 +194,7 @@ func (x NetworkType) Number() protoreflect.EnumNumber { // Deprecated: Use NetworkType.Descriptor instead. func (NetworkType) EnumDescriptor() ([]byte, []int) { - return file_feat_epdisc_candidate_proto_rawDescGZIP(), []int{2} + return file_feature_epdisc_candidate_proto_rawDescGZIP(), []int{2} } // Type of TCP candidate @@ -235,11 +235,11 @@ func (x TCPType) String() string { } func (TCPType) Descriptor() protoreflect.EnumDescriptor { - return file_feat_epdisc_candidate_proto_enumTypes[3].Descriptor() + return file_feature_epdisc_candidate_proto_enumTypes[3].Descriptor() } func (TCPType) Type() protoreflect.EnumType { - return &file_feat_epdisc_candidate_proto_enumTypes[3] + return &file_feature_epdisc_candidate_proto_enumTypes[3] } func (x TCPType) Number() protoreflect.EnumNumber { @@ -248,7 +248,7 @@ func (x TCPType) Number() protoreflect.EnumNumber { // Deprecated: Use TCPType.Descriptor instead. func (TCPType) EnumDescriptor() ([]byte, []int) { - return file_feat_epdisc_candidate_proto_rawDescGZIP(), []int{3} + return file_feature_epdisc_candidate_proto_rawDescGZIP(), []int{3} } type CandidatePair struct { @@ -263,7 +263,7 @@ type CandidatePair struct { func (x *CandidatePair) Reset() { *x = CandidatePair{} if protoimpl.UnsafeEnabled { - mi := &file_feat_epdisc_candidate_proto_msgTypes[0] + mi := &file_feature_epdisc_candidate_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -276,7 +276,7 @@ func (x *CandidatePair) String() string { func (*CandidatePair) ProtoMessage() {} func (x *CandidatePair) ProtoReflect() protoreflect.Message { - mi := &file_feat_epdisc_candidate_proto_msgTypes[0] + mi := &file_feature_epdisc_candidate_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -289,7 +289,7 @@ func (x *CandidatePair) ProtoReflect() protoreflect.Message { // Deprecated: Use CandidatePair.ProtoReflect.Descriptor instead. func (*CandidatePair) Descriptor() ([]byte, []int) { - return file_feat_epdisc_candidate_proto_rawDescGZIP(), []int{0} + return file_feature_epdisc_candidate_proto_rawDescGZIP(), []int{0} } func (x *CandidatePair) GetLocal() *Candidate { @@ -321,7 +321,7 @@ type RelatedAddress struct { func (x *RelatedAddress) Reset() { *x = RelatedAddress{} if protoimpl.UnsafeEnabled { - mi := &file_feat_epdisc_candidate_proto_msgTypes[1] + mi := &file_feature_epdisc_candidate_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -334,7 +334,7 @@ func (x *RelatedAddress) String() string { func (*RelatedAddress) ProtoMessage() {} func (x *RelatedAddress) ProtoReflect() protoreflect.Message { - mi := &file_feat_epdisc_candidate_proto_msgTypes[1] + mi := &file_feature_epdisc_candidate_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -347,7 +347,7 @@ func (x *RelatedAddress) ProtoReflect() protoreflect.Message { // Deprecated: Use RelatedAddress.ProtoReflect.Descriptor instead. func (*RelatedAddress) Descriptor() ([]byte, []int) { - return file_feat_epdisc_candidate_proto_rawDescGZIP(), []int{1} + return file_feature_epdisc_candidate_proto_rawDescGZIP(), []int{1} } func (x *RelatedAddress) GetAddress() string { @@ -392,7 +392,7 @@ type Candidate struct { func (x *Candidate) Reset() { *x = Candidate{} if protoimpl.UnsafeEnabled { - mi := &file_feat_epdisc_candidate_proto_msgTypes[2] + mi := &file_feature_epdisc_candidate_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -405,7 +405,7 @@ func (x *Candidate) String() string { func (*Candidate) ProtoMessage() {} func (x *Candidate) ProtoReflect() protoreflect.Message { - mi := &file_feat_epdisc_candidate_proto_msgTypes[2] + mi := &file_feature_epdisc_candidate_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -418,7 +418,7 @@ func (x *Candidate) ProtoReflect() protoreflect.Message { // Deprecated: Use Candidate.ProtoReflect.Descriptor instead. func (*Candidate) Descriptor() ([]byte, []int) { - return file_feat_epdisc_candidate_proto_rawDescGZIP(), []int{2} + return file_feature_epdisc_candidate_proto_rawDescGZIP(), []int{2} } func (x *Candidate) GetType() CandidateType { @@ -586,7 +586,7 @@ type CandidatePairStats struct { func (x *CandidatePairStats) Reset() { *x = CandidatePairStats{} if protoimpl.UnsafeEnabled { - mi := &file_feat_epdisc_candidate_proto_msgTypes[3] + mi := &file_feature_epdisc_candidate_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -599,7 +599,7 @@ func (x *CandidatePairStats) String() string { func (*CandidatePairStats) ProtoMessage() {} func (x *CandidatePairStats) ProtoReflect() protoreflect.Message { - mi := &file_feat_epdisc_candidate_proto_msgTypes[3] + mi := &file_feature_epdisc_candidate_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -612,7 +612,7 @@ func (x *CandidatePairStats) ProtoReflect() protoreflect.Message { // Deprecated: Use CandidatePairStats.ProtoReflect.Descriptor instead. func (*CandidatePairStats) Descriptor() ([]byte, []int) { - return file_feat_epdisc_candidate_proto_rawDescGZIP(), []int{3} + return file_feature_epdisc_candidate_proto_rawDescGZIP(), []int{3} } func (x *CandidatePairStats) GetTimestamp() *proto.Timestamp { @@ -853,7 +853,7 @@ type CandidateStats struct { func (x *CandidateStats) Reset() { *x = CandidateStats{} if protoimpl.UnsafeEnabled { - mi := &file_feat_epdisc_candidate_proto_msgTypes[4] + mi := &file_feature_epdisc_candidate_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -866,7 +866,7 @@ func (x *CandidateStats) String() string { func (*CandidateStats) ProtoMessage() {} func (x *CandidateStats) ProtoReflect() protoreflect.Message { - mi := &file_feat_epdisc_candidate_proto_msgTypes[4] + mi := &file_feature_epdisc_candidate_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -879,7 +879,7 @@ func (x *CandidateStats) ProtoReflect() protoreflect.Message { // Deprecated: Use CandidateStats.ProtoReflect.Descriptor instead. func (*CandidateStats) Descriptor() ([]byte, []int) { - return file_feat_epdisc_candidate_proto_rawDescGZIP(), []int{4} + return file_feature_epdisc_candidate_proto_rawDescGZIP(), []int{4} } func (x *CandidateStats) GetTimestamp() *proto.Timestamp { @@ -952,224 +952,225 @@ func (x *CandidateStats) GetDeleted() bool { return false } -var File_feat_epdisc_candidate_proto protoreflect.FileDescriptor +var File_feature_epdisc_candidate_proto protoreflect.FileDescriptor -var file_feat_epdisc_candidate_proto_rawDesc = []byte{ - 0x0a, 0x1b, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x5f, 0x63, 0x61, - 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x63, - 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x1a, 0x0c, 0x63, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x71, 0x0a, 0x0d, 0x43, 0x61, - 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x69, 0x72, 0x12, 0x2e, 0x0a, 0x05, 0x6c, - 0x6f, 0x63, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x75, 0x6e, - 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x52, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x12, 0x30, 0x0a, 0x06, 0x72, - 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x75, - 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x06, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x22, 0x3e, 0x0a, - 0x0e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, - 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x22, 0xff, 0x02, - 0x0a, 0x09, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x63, 0x75, 0x6e, 0x69, +var file_feature_epdisc_candidate_proto_rawDesc = []byte{ + 0x0a, 0x1e, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, + 0x5f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x0d, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x1a, + 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x71, 0x0a, + 0x0d, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x69, 0x72, 0x12, 0x2e, + 0x0a, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, + 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, + 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x12, 0x30, + 0x0a, 0x06, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, + 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, + 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x06, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, + 0x22, 0x3e, 0x0a, 0x0e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, + 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, + 0x22, 0xff, 0x02, 0x0a, 0x09, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x12, 0x30, + 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x63, + 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, + 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x12, 0x3d, 0x0a, 0x0c, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, + 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, + 0x70, 0x65, 0x52, 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x31, 0x0a, 0x08, 0x74, 0x63, 0x70, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x16, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, + 0x63, 0x2e, 0x54, 0x43, 0x50, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x74, 0x63, 0x70, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, + 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x46, 0x0a, 0x0f, 0x72, 0x65, + 0x6c, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, + 0x69, 0x73, 0x63, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x52, 0x0e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x22, 0xd5, 0x0b, 0x0a, 0x12, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x50, 0x61, 0x69, 0x72, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x09, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, + 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2c, 0x0a, 0x12, 0x6c, 0x6f, + 0x63, 0x61, 0x6c, 0x5f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x43, 0x61, 0x6e, + 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x13, 0x72, 0x65, 0x6d, 0x6f, + 0x74, 0x65, 0x5f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x61, 0x6e, + 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x49, 0x64, 0x12, 0x37, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, + 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, + 0x65, 0x50, 0x61, 0x69, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x6f, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6e, 0x6f, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x12, + 0x21, 0x0a, 0x0c, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x53, 0x65, + 0x6e, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x5f, 0x72, 0x65, + 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x70, 0x61, + 0x63, 0x6b, 0x65, 0x74, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x12, 0x1d, 0x0a, + 0x0a, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x09, 0x62, 0x79, 0x74, 0x65, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, + 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x62, 0x79, 0x74, 0x65, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, + 0x76, 0x65, 0x64, 0x12, 0x4e, 0x0a, 0x1a, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x70, 0x61, 0x63, 0x6b, + 0x65, 0x74, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x17, 0x6c, 0x61, 0x73, 0x74, + 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x12, 0x56, 0x0a, 0x1e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x70, 0x61, 0x63, 0x6b, + 0x65, 0x74, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, + 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x1b, + 0x6c, 0x61, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, + 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x49, 0x0a, 0x17, 0x66, + 0x69, 0x72, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, + 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x15, 0x66, 0x69, 0x72, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x47, 0x0a, 0x16, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x14, 0x6c, 0x61, 0x73, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, + 0x49, 0x0a, 0x17, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x15, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x30, 0x0a, 0x14, 0x74, 0x6f, + 0x74, 0x61, 0x6c, 0x5f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x74, 0x72, 0x69, 0x70, 0x5f, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x01, 0x52, 0x12, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x52, + 0x6f, 0x75, 0x6e, 0x64, 0x74, 0x72, 0x69, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x34, 0x0a, 0x16, + 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x5f, 0x74, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x74, 0x72, 0x69, + 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x01, 0x52, 0x14, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x54, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x74, 0x72, 0x69, 0x70, 0x54, 0x69, + 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x1a, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x5f, + 0x6f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x5f, 0x62, 0x69, 0x74, 0x72, 0x61, 0x74, 0x65, + 0x18, 0x11, 0x20, 0x01, 0x28, 0x01, 0x52, 0x18, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, + 0x65, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x42, 0x69, 0x74, 0x72, 0x61, 0x74, 0x65, + 0x12, 0x3c, 0x0a, 0x1a, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x69, 0x6e, + 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x5f, 0x62, 0x69, 0x74, 0x72, 0x61, 0x74, 0x65, 0x18, 0x12, + 0x20, 0x01, 0x28, 0x01, 0x52, 0x18, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x49, + 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x42, 0x69, 0x74, 0x72, 0x61, 0x74, 0x65, 0x12, 0x41, + 0x0a, 0x1d, 0x63, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x5f, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x65, + 0x72, 0x5f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x13, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x1a, 0x63, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x42, 0x72, + 0x65, 0x61, 0x6b, 0x65, 0x72, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x2b, 0x0a, 0x11, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x72, 0x65, + 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x12, 0x23, + 0x0a, 0x0d, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, + 0x15, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x53, + 0x65, 0x6e, 0x74, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, + 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x16, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x11, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, + 0x65, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x5f, + 0x73, 0x65, 0x6e, 0x74, 0x18, 0x17, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x12, 0x39, 0x0a, 0x18, 0x72, 0x65, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x5f, 0x72, 0x65, 0x63, + 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x18, 0x20, 0x01, 0x28, 0x04, 0x52, 0x17, 0x72, 0x65, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x63, 0x65, + 0x69, 0x76, 0x65, 0x64, 0x12, 0x31, 0x0a, 0x14, 0x72, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, + 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, 0x19, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x13, 0x72, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x63, 0x6f, 0x6e, 0x73, 0x65, + 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, + 0x18, 0x1a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x13, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x12, 0x4d, 0x0a, 0x19, 0x63, + 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, + 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x52, 0x17, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, + 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xe8, 0x02, 0x0a, 0x0e, 0x43, + 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x2f, 0x0a, + 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3d, + 0x0a, 0x0c, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, + 0x64, 0x69, 0x73, 0x63, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x12, 0x0a, + 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, + 0x74, 0x12, 0x43, 0x0a, 0x0e, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x3d, 0x0a, - 0x0c, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, - 0x69, 0x73, 0x63, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x52, - 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x31, 0x0a, 0x08, - 0x74, 0x63, 0x70, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, - 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x54, - 0x43, 0x50, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x74, 0x63, 0x70, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x1e, 0x0a, 0x0a, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, - 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x46, 0x0a, 0x0f, 0x72, 0x65, 0x6c, 0x61, 0x74, - 0x65, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, - 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, - 0x0e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, - 0xd5, 0x0b, 0x0a, 0x12, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x69, - 0x72, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, - 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2c, 0x0a, 0x12, 0x6c, 0x6f, 0x63, 0x61, 0x6c, - 0x5f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x10, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x13, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x5f, - 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x11, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x49, 0x64, 0x12, 0x37, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, - 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, - 0x69, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1c, - 0x0a, 0x09, 0x6e, 0x6f, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x09, 0x6e, 0x6f, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x12, 0x21, 0x0a, 0x0c, - 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x0b, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x12, - 0x29, 0x0a, 0x10, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, - 0x76, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x70, 0x61, 0x63, 0x6b, 0x65, - 0x74, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x79, - 0x74, 0x65, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, - 0x62, 0x79, 0x74, 0x65, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x62, 0x79, 0x74, - 0x65, 0x73, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x0d, 0x62, 0x79, 0x74, 0x65, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, - 0x12, 0x4e, 0x0a, 0x1a, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x5f, - 0x73, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x17, 0x6c, 0x61, 0x73, 0x74, 0x50, 0x61, 0x63, - 0x6b, 0x65, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x12, 0x56, 0x0a, 0x1e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x5f, - 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, - 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x1b, 0x6c, 0x61, 0x73, - 0x74, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x49, 0x0a, 0x17, 0x66, 0x69, 0x72, 0x73, - 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, - 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x15, 0x66, 0x69, - 0x72, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x12, 0x47, 0x0a, 0x16, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x0d, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x14, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x49, 0x0a, 0x17, - 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, - 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x52, 0x15, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x30, 0x0a, 0x14, 0x74, 0x6f, 0x74, 0x61, 0x6c, - 0x5f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x74, 0x72, 0x69, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, - 0x0f, 0x20, 0x01, 0x28, 0x01, 0x52, 0x12, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x6f, 0x75, 0x6e, - 0x64, 0x74, 0x72, 0x69, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x34, 0x0a, 0x16, 0x63, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x5f, 0x74, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x74, 0x72, 0x69, 0x70, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x01, 0x52, 0x14, 0x63, 0x75, 0x72, 0x72, 0x65, - 0x6e, 0x54, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x74, 0x72, 0x69, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x12, - 0x3c, 0x0a, 0x1a, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x75, 0x74, - 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x5f, 0x62, 0x69, 0x74, 0x72, 0x61, 0x74, 0x65, 0x18, 0x11, 0x20, - 0x01, 0x28, 0x01, 0x52, 0x18, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x75, - 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x42, 0x69, 0x74, 0x72, 0x61, 0x74, 0x65, 0x12, 0x3c, 0x0a, - 0x1a, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x69, 0x6e, 0x63, 0x6f, 0x6d, - 0x69, 0x6e, 0x67, 0x5f, 0x62, 0x69, 0x74, 0x72, 0x61, 0x74, 0x65, 0x18, 0x12, 0x20, 0x01, 0x28, - 0x01, 0x52, 0x18, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x49, 0x6e, 0x63, 0x6f, - 0x6d, 0x69, 0x6e, 0x67, 0x42, 0x69, 0x74, 0x72, 0x61, 0x74, 0x65, 0x12, 0x41, 0x0a, 0x1d, 0x63, - 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x5f, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x65, 0x72, 0x5f, 0x74, - 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x13, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x1a, 0x63, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x42, 0x72, 0x65, 0x61, 0x6b, - 0x65, 0x72, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2b, - 0x0a, 0x11, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, - 0x76, 0x65, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, 0x15, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x0c, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x53, 0x65, 0x6e, 0x74, - 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x5f, 0x72, 0x65, - 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x16, 0x20, 0x01, 0x28, 0x04, 0x52, 0x11, 0x72, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x12, - 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x5f, 0x73, 0x65, 0x6e, - 0x74, 0x18, 0x17, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x12, 0x39, 0x0a, 0x18, 0x72, 0x65, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, - 0x65, 0x64, 0x18, 0x18, 0x20, 0x01, 0x28, 0x04, 0x52, 0x17, 0x72, 0x65, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, - 0x64, 0x12, 0x31, 0x0a, 0x14, 0x72, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, 0x19, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x13, 0x72, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, - 0x53, 0x65, 0x6e, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x5f, - 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, 0x1a, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x13, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x12, 0x4d, 0x0a, 0x19, 0x63, 0x6f, 0x6e, 0x73, - 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, - 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x17, - 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xe8, 0x02, 0x0a, 0x0e, 0x43, 0x61, 0x6e, 0x64, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, - 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3d, 0x0a, 0x0c, 0x6e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x1a, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, - 0x63, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0b, 0x6e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, - 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x43, - 0x0a, 0x0e, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, - 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x54, 0x79, 0x70, 0x65, 0x52, 0x0d, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, - 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x79, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x64, 0x2a, 0xc6, 0x01, 0x0a, 0x12, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x50, 0x61, 0x69, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x24, 0x0a, 0x20, 0x43, 0x41, 0x4e, + 0x61, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0d, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, + 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, + 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, + 0x74, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x75, 0x72, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, + 0x6c, 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x64, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x64, 0x2a, 0xc6, 0x01, 0x0a, 0x12, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, + 0x61, 0x74, 0x65, 0x50, 0x61, 0x69, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x24, 0x0a, 0x20, + 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x50, 0x41, 0x49, 0x52, 0x5f, 0x53, + 0x54, 0x41, 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, + 0x10, 0x00, 0x12, 0x20, 0x0a, 0x1c, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, + 0x50, 0x41, 0x49, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x57, 0x41, 0x49, 0x54, 0x49, + 0x4e, 0x47, 0x10, 0x01, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, + 0x45, 0x5f, 0x50, 0x41, 0x49, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x49, 0x4e, 0x50, + 0x52, 0x4f, 0x47, 0x52, 0x45, 0x53, 0x53, 0x10, 0x02, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x50, 0x41, 0x49, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, - 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, - 0x20, 0x0a, 0x1c, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x50, 0x41, 0x49, - 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x57, 0x41, 0x49, 0x54, 0x49, 0x4e, 0x47, 0x10, - 0x01, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x50, - 0x41, 0x49, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x49, 0x4e, 0x50, 0x52, 0x4f, 0x47, - 0x52, 0x45, 0x53, 0x53, 0x10, 0x02, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, - 0x41, 0x54, 0x45, 0x5f, 0x50, 0x41, 0x49, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x46, - 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x03, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x41, 0x4e, 0x44, 0x49, - 0x44, 0x41, 0x54, 0x45, 0x5f, 0x50, 0x41, 0x49, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, - 0x53, 0x55, 0x43, 0x43, 0x45, 0x45, 0x44, 0x45, 0x44, 0x10, 0x04, 0x2a, 0xaa, 0x01, 0x0a, 0x0d, - 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, - 0x1a, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, - 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, - 0x13, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, - 0x48, 0x4f, 0x53, 0x54, 0x10, 0x01, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, - 0x41, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x5f, - 0x52, 0x45, 0x46, 0x4c, 0x45, 0x58, 0x49, 0x56, 0x45, 0x10, 0x02, 0x12, 0x21, 0x0a, 0x1d, 0x43, - 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x50, 0x45, - 0x45, 0x52, 0x5f, 0x52, 0x45, 0x46, 0x4c, 0x45, 0x58, 0x49, 0x56, 0x45, 0x10, 0x03, 0x12, 0x18, - 0x0a, 0x14, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, - 0x5f, 0x52, 0x45, 0x4c, 0x41, 0x59, 0x10, 0x04, 0x2a, 0x87, 0x01, 0x0a, 0x0b, 0x4e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x18, 0x4e, 0x45, 0x54, 0x57, - 0x4f, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, - 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, - 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x44, 0x50, 0x34, 0x10, 0x01, 0x12, 0x15, 0x0a, - 0x11, 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x44, - 0x50, 0x36, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x5f, - 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x43, 0x50, 0x34, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x4e, - 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x43, 0x50, 0x36, - 0x10, 0x04, 0x2a, 0x6e, 0x0a, 0x07, 0x54, 0x43, 0x50, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, - 0x14, 0x54, 0x43, 0x50, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, - 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x54, 0x43, 0x50, 0x5f, 0x54, - 0x59, 0x50, 0x45, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, - 0x54, 0x43, 0x50, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x50, 0x41, 0x53, 0x53, 0x49, 0x56, 0x45, - 0x10, 0x02, 0x12, 0x1e, 0x0a, 0x1a, 0x54, 0x43, 0x50, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, - 0x49, 0x4d, 0x55, 0x4c, 0x54, 0x41, 0x4e, 0x45, 0x4f, 0x55, 0x53, 0x5f, 0x4f, 0x50, 0x45, 0x4e, - 0x10, 0x03, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, - 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x65, 0x70, 0x64, - 0x69, 0x73, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x45, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x03, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x41, + 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x50, 0x41, 0x49, 0x52, 0x5f, 0x53, 0x54, 0x41, + 0x54, 0x45, 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x45, 0x44, 0x45, 0x44, 0x10, 0x04, 0x2a, 0xaa, + 0x01, 0x0a, 0x0d, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x54, 0x59, + 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x17, 0x0a, 0x13, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x54, 0x59, + 0x50, 0x45, 0x5f, 0x48, 0x4f, 0x53, 0x54, 0x10, 0x01, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x41, 0x4e, + 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x45, 0x52, 0x56, + 0x45, 0x52, 0x5f, 0x52, 0x45, 0x46, 0x4c, 0x45, 0x58, 0x49, 0x56, 0x45, 0x10, 0x02, 0x12, 0x21, + 0x0a, 0x1d, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, + 0x5f, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x52, 0x45, 0x46, 0x4c, 0x45, 0x58, 0x49, 0x56, 0x45, 0x10, + 0x03, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x41, 0x4e, 0x44, 0x49, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x54, + 0x59, 0x50, 0x45, 0x5f, 0x52, 0x45, 0x4c, 0x41, 0x59, 0x10, 0x04, 0x2a, 0x87, 0x01, 0x0a, 0x0b, + 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x18, 0x4e, + 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x4e, 0x45, 0x54, + 0x57, 0x4f, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x44, 0x50, 0x34, 0x10, 0x01, + 0x12, 0x15, 0x0a, 0x11, 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, + 0x5f, 0x55, 0x44, 0x50, 0x36, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x4e, 0x45, 0x54, 0x57, 0x4f, + 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x43, 0x50, 0x34, 0x10, 0x03, 0x12, 0x15, + 0x0a, 0x11, 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, + 0x43, 0x50, 0x36, 0x10, 0x04, 0x2a, 0x6e, 0x0a, 0x07, 0x54, 0x43, 0x50, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x18, 0x0a, 0x14, 0x54, 0x43, 0x50, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, + 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x54, 0x43, + 0x50, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x01, 0x12, + 0x14, 0x0a, 0x10, 0x54, 0x43, 0x50, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x50, 0x41, 0x53, 0x53, + 0x49, 0x56, 0x45, 0x10, 0x02, 0x12, 0x1e, 0x0a, 0x1a, 0x54, 0x43, 0x50, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x53, 0x49, 0x4d, 0x55, 0x4c, 0x54, 0x41, 0x4e, 0x45, 0x4f, 0x55, 0x53, 0x5f, 0x4f, + 0x50, 0x45, 0x4e, 0x10, 0x03, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, + 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( - file_feat_epdisc_candidate_proto_rawDescOnce sync.Once - file_feat_epdisc_candidate_proto_rawDescData = file_feat_epdisc_candidate_proto_rawDesc + file_feature_epdisc_candidate_proto_rawDescOnce sync.Once + file_feature_epdisc_candidate_proto_rawDescData = file_feature_epdisc_candidate_proto_rawDesc ) -func file_feat_epdisc_candidate_proto_rawDescGZIP() []byte { - file_feat_epdisc_candidate_proto_rawDescOnce.Do(func() { - file_feat_epdisc_candidate_proto_rawDescData = protoimpl.X.CompressGZIP(file_feat_epdisc_candidate_proto_rawDescData) +func file_feature_epdisc_candidate_proto_rawDescGZIP() []byte { + file_feature_epdisc_candidate_proto_rawDescOnce.Do(func() { + file_feature_epdisc_candidate_proto_rawDescData = protoimpl.X.CompressGZIP(file_feature_epdisc_candidate_proto_rawDescData) }) - return file_feat_epdisc_candidate_proto_rawDescData + return file_feature_epdisc_candidate_proto_rawDescData } -var file_feat_epdisc_candidate_proto_enumTypes = make([]protoimpl.EnumInfo, 4) -var file_feat_epdisc_candidate_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_feat_epdisc_candidate_proto_goTypes = []interface{}{ +var file_feature_epdisc_candidate_proto_enumTypes = make([]protoimpl.EnumInfo, 4) +var file_feature_epdisc_candidate_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_feature_epdisc_candidate_proto_goTypes = []interface{}{ (CandidatePairState)(0), // 0: cunicu.epdisc.CandidatePairState (CandidateType)(0), // 1: cunicu.epdisc.CandidateType (NetworkType)(0), // 2: cunicu.epdisc.NetworkType @@ -1181,7 +1182,7 @@ var file_feat_epdisc_candidate_proto_goTypes = []interface{}{ (*CandidateStats)(nil), // 8: cunicu.epdisc.CandidateStats (*proto.Timestamp)(nil), // 9: cunicu.Timestamp } -var file_feat_epdisc_candidate_proto_depIdxs = []int32{ +var file_feature_epdisc_candidate_proto_depIdxs = []int32{ 6, // 0: cunicu.epdisc.CandidatePair.local:type_name -> cunicu.epdisc.Candidate 6, // 1: cunicu.epdisc.CandidatePair.remote:type_name -> cunicu.epdisc.Candidate 1, // 2: cunicu.epdisc.Candidate.type:type_name -> cunicu.epdisc.CandidateType @@ -1206,13 +1207,13 @@ var file_feat_epdisc_candidate_proto_depIdxs = []int32{ 0, // [0:17] is the sub-list for field type_name } -func init() { file_feat_epdisc_candidate_proto_init() } -func file_feat_epdisc_candidate_proto_init() { - if File_feat_epdisc_candidate_proto != nil { +func init() { file_feature_epdisc_candidate_proto_init() } +func file_feature_epdisc_candidate_proto_init() { + if File_feature_epdisc_candidate_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_feat_epdisc_candidate_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_feature_epdisc_candidate_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CandidatePair); i { case 0: return &v.state @@ -1224,7 +1225,7 @@ func file_feat_epdisc_candidate_proto_init() { return nil } } - file_feat_epdisc_candidate_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_feature_epdisc_candidate_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RelatedAddress); i { case 0: return &v.state @@ -1236,7 +1237,7 @@ func file_feat_epdisc_candidate_proto_init() { return nil } } - file_feat_epdisc_candidate_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_feature_epdisc_candidate_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Candidate); i { case 0: return &v.state @@ -1248,7 +1249,7 @@ func file_feat_epdisc_candidate_proto_init() { return nil } } - file_feat_epdisc_candidate_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_feature_epdisc_candidate_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CandidatePairStats); i { case 0: return &v.state @@ -1260,7 +1261,7 @@ func file_feat_epdisc_candidate_proto_init() { return nil } } - file_feat_epdisc_candidate_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_feature_epdisc_candidate_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CandidateStats); i { case 0: return &v.state @@ -1277,19 +1278,19 @@ func file_feat_epdisc_candidate_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_feat_epdisc_candidate_proto_rawDesc, + RawDescriptor: file_feature_epdisc_candidate_proto_rawDesc, NumEnums: 4, NumMessages: 5, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_feat_epdisc_candidate_proto_goTypes, - DependencyIndexes: file_feat_epdisc_candidate_proto_depIdxs, - EnumInfos: file_feat_epdisc_candidate_proto_enumTypes, - MessageInfos: file_feat_epdisc_candidate_proto_msgTypes, + GoTypes: file_feature_epdisc_candidate_proto_goTypes, + DependencyIndexes: file_feature_epdisc_candidate_proto_depIdxs, + EnumInfos: file_feature_epdisc_candidate_proto_enumTypes, + MessageInfos: file_feature_epdisc_candidate_proto_msgTypes, }.Build() - File_feat_epdisc_candidate_proto = out.File - file_feat_epdisc_candidate_proto_rawDesc = nil - file_feat_epdisc_candidate_proto_goTypes = nil - file_feat_epdisc_candidate_proto_depIdxs = nil + File_feature_epdisc_candidate_proto = out.File + file_feature_epdisc_candidate_proto_rawDesc = nil + file_feature_epdisc_candidate_proto_goTypes = nil + file_feature_epdisc_candidate_proto_depIdxs = nil } diff --git a/pkg/proto/feat/hooks/hooks.pb.go b/pkg/proto/feature/hooks/hooks.pb.go similarity index 50% rename from pkg/proto/feat/hooks/hooks.pb.go rename to pkg/proto/feature/hooks/hooks.pb.go index 168702ce..f748aa55 100644 --- a/pkg/proto/feat/hooks/hooks.pb.go +++ b/pkg/proto/feature/hooks/hooks.pb.go @@ -2,7 +2,7 @@ // versions: // protoc-gen-go v1.28.1 // protoc v3.6.1 -// source: feat/hooks.proto +// source: feature/hooks.proto package hooks @@ -36,7 +36,7 @@ type WebHookBody struct { func (x *WebHookBody) Reset() { *x = WebHookBody{} if protoimpl.UnsafeEnabled { - mi := &file_feat_hooks_proto_msgTypes[0] + mi := &file_feature_hooks_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -49,7 +49,7 @@ func (x *WebHookBody) String() string { func (*WebHookBody) ProtoMessage() {} func (x *WebHookBody) ProtoReflect() protoreflect.Message { - mi := &file_feat_hooks_proto_msgTypes[0] + mi := &file_feature_hooks_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -62,7 +62,7 @@ func (x *WebHookBody) ProtoReflect() protoreflect.Message { // Deprecated: Use WebHookBody.ProtoReflect.Descriptor instead. func (*WebHookBody) Descriptor() ([]byte, []int) { - return file_feat_hooks_proto_rawDescGZIP(), []int{0} + return file_feature_hooks_proto_rawDescGZIP(), []int{0} } func (x *WebHookBody) GetType() rpc.EventType { @@ -93,52 +93,52 @@ func (x *WebHookBody) GetModified() []string { return nil } -var File_feat_hooks_proto protoreflect.FileDescriptor +var File_feature_hooks_proto protoreflect.FileDescriptor -var file_feat_hooks_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x68, 0x6f, 0x6f, 0x6b, 0x73, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x0c, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x68, 0x6f, 0x6f, 0x6b, 0x73, - 0x1a, 0x14, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x65, 0x65, - 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x76, 0x65, - 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb1, 0x01, 0x0a, 0x0b, 0x57, 0x65, 0x62, - 0x48, 0x6f, 0x6f, 0x6b, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x29, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, - 0x72, 0x70, 0x63, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x12, 0x34, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, - 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x09, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x25, 0x0a, 0x04, 0x70, 0x65, 0x65, - 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, - 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x04, 0x70, 0x65, 0x65, 0x72, - 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x42, 0x2e, 0x5a, 0x2c, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, - 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x68, 0x6f, 0x6f, 0x6b, 0x73, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, +var file_feature_hooks_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x68, 0x6f, 0x6f, 0x6b, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x68, 0x6f, + 0x6f, 0x6b, 0x73, 0x1a, 0x14, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, + 0x61, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x63, 0x6f, 0x72, 0x65, 0x2f, + 0x70, 0x65, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x72, 0x70, 0x63, 0x2f, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb1, 0x01, 0x0a, 0x0b, + 0x57, 0x65, 0x62, 0x48, 0x6f, 0x6f, 0x6b, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x29, 0x0a, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x63, 0x75, 0x6e, 0x69, + 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x34, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, + 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x75, 0x6e, 0x69, + 0x63, 0x75, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, + 0x65, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x25, 0x0a, 0x04, + 0x70, 0x65, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, + 0x69, 0x63, 0x75, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x04, 0x70, + 0x65, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, + 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x42, + 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, + 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x68, 0x6f, 0x6f, + 0x6b, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_feat_hooks_proto_rawDescOnce sync.Once - file_feat_hooks_proto_rawDescData = file_feat_hooks_proto_rawDesc + file_feature_hooks_proto_rawDescOnce sync.Once + file_feature_hooks_proto_rawDescData = file_feature_hooks_proto_rawDesc ) -func file_feat_hooks_proto_rawDescGZIP() []byte { - file_feat_hooks_proto_rawDescOnce.Do(func() { - file_feat_hooks_proto_rawDescData = protoimpl.X.CompressGZIP(file_feat_hooks_proto_rawDescData) +func file_feature_hooks_proto_rawDescGZIP() []byte { + file_feature_hooks_proto_rawDescOnce.Do(func() { + file_feature_hooks_proto_rawDescData = protoimpl.X.CompressGZIP(file_feature_hooks_proto_rawDescData) }) - return file_feat_hooks_proto_rawDescData + return file_feature_hooks_proto_rawDescData } -var file_feat_hooks_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_feat_hooks_proto_goTypes = []interface{}{ +var file_feature_hooks_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_feature_hooks_proto_goTypes = []interface{}{ (*WebHookBody)(nil), // 0: cunicu.hooks.WebHookBody (rpc.EventType)(0), // 1: cunicu.rpc.EventType (*core.Interface)(nil), // 2: cunicu.core.Interface (*core.Peer)(nil), // 3: cunicu.core.Peer } -var file_feat_hooks_proto_depIdxs = []int32{ +var file_feature_hooks_proto_depIdxs = []int32{ 1, // 0: cunicu.hooks.WebHookBody.type:type_name -> cunicu.rpc.EventType 2, // 1: cunicu.hooks.WebHookBody.interface:type_name -> cunicu.core.Interface 3, // 2: cunicu.hooks.WebHookBody.peer:type_name -> cunicu.core.Peer @@ -149,13 +149,13 @@ var file_feat_hooks_proto_depIdxs = []int32{ 0, // [0:3] is the sub-list for field type_name } -func init() { file_feat_hooks_proto_init() } -func file_feat_hooks_proto_init() { - if File_feat_hooks_proto != nil { +func init() { file_feature_hooks_proto_init() } +func file_feature_hooks_proto_init() { + if File_feature_hooks_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_feat_hooks_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_feature_hooks_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*WebHookBody); i { case 0: return &v.state @@ -172,18 +172,18 @@ func file_feat_hooks_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_feat_hooks_proto_rawDesc, + RawDescriptor: file_feature_hooks_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_feat_hooks_proto_goTypes, - DependencyIndexes: file_feat_hooks_proto_depIdxs, - MessageInfos: file_feat_hooks_proto_msgTypes, + GoTypes: file_feature_hooks_proto_goTypes, + DependencyIndexes: file_feature_hooks_proto_depIdxs, + MessageInfos: file_feature_hooks_proto_msgTypes, }.Build() - File_feat_hooks_proto = out.File - file_feat_hooks_proto_rawDesc = nil - file_feat_hooks_proto_goTypes = nil - file_feat_hooks_proto_depIdxs = nil + File_feature_hooks_proto = out.File + file_feature_hooks_proto_rawDesc = nil + file_feature_hooks_proto_goTypes = nil + file_feature_hooks_proto_depIdxs = nil } diff --git a/pkg/proto/feat/pdisc/pdisc.go b/pkg/proto/feature/pdisc/pdisc.go similarity index 100% rename from pkg/proto/feat/pdisc/pdisc.go rename to pkg/proto/feature/pdisc/pdisc.go diff --git a/pkg/proto/feat/pdisc/pdisc.pb.go b/pkg/proto/feature/pdisc/pdisc.pb.go similarity index 55% rename from pkg/proto/feat/pdisc/pdisc.pb.go rename to pkg/proto/feature/pdisc/pdisc.pb.go index 37073b29..9ac7c0f9 100644 --- a/pkg/proto/feat/pdisc/pdisc.pb.go +++ b/pkg/proto/feature/pdisc/pdisc.pb.go @@ -2,7 +2,7 @@ // versions: // protoc-gen-go v1.28.1 // protoc v3.6.1 -// source: feat/pdisc.proto +// source: feature/pdisc.proto package pdisc @@ -54,11 +54,11 @@ func (x PeerDescriptionChange) String() string { } func (PeerDescriptionChange) Descriptor() protoreflect.EnumDescriptor { - return file_feat_pdisc_proto_enumTypes[0].Descriptor() + return file_feature_pdisc_proto_enumTypes[0].Descriptor() } func (PeerDescriptionChange) Type() protoreflect.EnumType { - return &file_feat_pdisc_proto_enumTypes[0] + return &file_feature_pdisc_proto_enumTypes[0] } func (x PeerDescriptionChange) Number() protoreflect.EnumNumber { @@ -67,7 +67,7 @@ func (x PeerDescriptionChange) Number() protoreflect.EnumNumber { // Deprecated: Use PeerDescriptionChange.Descriptor instead. func (PeerDescriptionChange) EnumDescriptor() ([]byte, []int) { - return file_feat_pdisc_proto_rawDescGZIP(), []int{0} + return file_feature_pdisc_proto_rawDescGZIP(), []int{0} } // A PeerDescription is an announcement of a peer which is distributed to @@ -93,7 +93,7 @@ type PeerDescription struct { func (x *PeerDescription) Reset() { *x = PeerDescription{} if protoimpl.UnsafeEnabled { - mi := &file_feat_pdisc_proto_msgTypes[0] + mi := &file_feature_pdisc_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -106,7 +106,7 @@ func (x *PeerDescription) String() string { func (*PeerDescription) ProtoMessage() {} func (x *PeerDescription) ProtoReflect() protoreflect.Message { - mi := &file_feat_pdisc_proto_msgTypes[0] + mi := &file_feature_pdisc_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -119,7 +119,7 @@ func (x *PeerDescription) ProtoReflect() protoreflect.Message { // Deprecated: Use PeerDescription.ProtoReflect.Descriptor instead. func (*PeerDescription) Descriptor() ([]byte, []int) { - return file_feat_pdisc_proto_rawDescGZIP(), []int{0} + return file_feature_pdisc_proto_rawDescGZIP(), []int{0} } func (x *PeerDescription) GetChange() PeerDescriptionChange { @@ -164,59 +164,59 @@ func (x *PeerDescription) GetBuildInfo() *proto.BuildInfo { return nil } -var File_feat_pdisc_proto protoreflect.FileDescriptor +var File_feature_pdisc_proto protoreflect.FileDescriptor -var file_feat_pdisc_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x0c, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x70, 0x64, 0x69, 0x73, 0x63, - 0x1a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x82, - 0x02, 0x0a, 0x0f, 0x50, 0x65, 0x65, 0x72, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x70, 0x64, 0x69, 0x73, - 0x63, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x06, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, - 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, - 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x0e, 0x70, 0x75, - 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6e, 0x65, 0x77, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x4e, 0x65, 0x77, - 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x69, 0x70, 0x73, 0x18, - 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x49, 0x70, - 0x73, 0x12, 0x30, 0x0a, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x42, - 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, - 0x6e, 0x66, 0x6f, 0x2a, 0x47, 0x0a, 0x15, 0x50, 0x65, 0x65, 0x72, 0x44, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x0c, 0x0a, 0x08, - 0x50, 0x45, 0x45, 0x52, 0x5f, 0x41, 0x44, 0x44, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x45, - 0x45, 0x52, 0x5f, 0x52, 0x45, 0x4d, 0x4f, 0x56, 0x45, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x50, - 0x45, 0x45, 0x52, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x02, 0x42, 0x2e, 0x5a, 0x2c, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, - 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x70, 0x64, 0x69, 0x73, 0x63, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, +var file_feature_pdisc_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x70, 0x64, + 0x69, 0x73, 0x63, 0x1a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0x82, 0x02, 0x0a, 0x0f, 0x50, 0x65, 0x65, 0x72, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x70, + 0x64, 0x69, 0x73, 0x63, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x06, 0x63, 0x68, 0x61, 0x6e, + 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, + 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x24, 0x0a, + 0x0e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6e, 0x65, 0x77, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, + 0x4e, 0x65, 0x77, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x69, + 0x70, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, + 0x64, 0x49, 0x70, 0x73, 0x12, 0x30, 0x0a, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x6e, + 0x66, 0x6f, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, + 0x75, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x62, 0x75, 0x69, + 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x2a, 0x47, 0x0a, 0x15, 0x50, 0x65, 0x65, 0x72, 0x44, 0x65, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, + 0x0c, 0x0a, 0x08, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x41, 0x44, 0x44, 0x10, 0x00, 0x12, 0x0f, 0x0a, + 0x0b, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x52, 0x45, 0x4d, 0x4f, 0x56, 0x45, 0x10, 0x01, 0x12, 0x0f, + 0x0a, 0x0b, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x02, 0x42, + 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, + 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x70, 0x64, 0x69, + 0x73, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_feat_pdisc_proto_rawDescOnce sync.Once - file_feat_pdisc_proto_rawDescData = file_feat_pdisc_proto_rawDesc + file_feature_pdisc_proto_rawDescOnce sync.Once + file_feature_pdisc_proto_rawDescData = file_feature_pdisc_proto_rawDesc ) -func file_feat_pdisc_proto_rawDescGZIP() []byte { - file_feat_pdisc_proto_rawDescOnce.Do(func() { - file_feat_pdisc_proto_rawDescData = protoimpl.X.CompressGZIP(file_feat_pdisc_proto_rawDescData) +func file_feature_pdisc_proto_rawDescGZIP() []byte { + file_feature_pdisc_proto_rawDescOnce.Do(func() { + file_feature_pdisc_proto_rawDescData = protoimpl.X.CompressGZIP(file_feature_pdisc_proto_rawDescData) }) - return file_feat_pdisc_proto_rawDescData + return file_feature_pdisc_proto_rawDescData } -var file_feat_pdisc_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_feat_pdisc_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_feat_pdisc_proto_goTypes = []interface{}{ +var file_feature_pdisc_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_feature_pdisc_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_feature_pdisc_proto_goTypes = []interface{}{ (PeerDescriptionChange)(0), // 0: cunicu.pdisc.PeerDescriptionChange (*PeerDescription)(nil), // 1: cunicu.pdisc.PeerDescription (*proto.BuildInfo)(nil), // 2: cunicu.BuildInfo } -var file_feat_pdisc_proto_depIdxs = []int32{ +var file_feature_pdisc_proto_depIdxs = []int32{ 0, // 0: cunicu.pdisc.PeerDescription.change:type_name -> cunicu.pdisc.PeerDescriptionChange 2, // 1: cunicu.pdisc.PeerDescription.build_info:type_name -> cunicu.BuildInfo 2, // [2:2] is the sub-list for method output_type @@ -226,13 +226,13 @@ var file_feat_pdisc_proto_depIdxs = []int32{ 0, // [0:2] is the sub-list for field type_name } -func init() { file_feat_pdisc_proto_init() } -func file_feat_pdisc_proto_init() { - if File_feat_pdisc_proto != nil { +func init() { file_feature_pdisc_proto_init() } +func file_feature_pdisc_proto_init() { + if File_feature_pdisc_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_feat_pdisc_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_feature_pdisc_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PeerDescription); i { case 0: return &v.state @@ -249,19 +249,19 @@ func file_feat_pdisc_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_feat_pdisc_proto_rawDesc, + RawDescriptor: file_feature_pdisc_proto_rawDesc, NumEnums: 1, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_feat_pdisc_proto_goTypes, - DependencyIndexes: file_feat_pdisc_proto_depIdxs, - EnumInfos: file_feat_pdisc_proto_enumTypes, - MessageInfos: file_feat_pdisc_proto_msgTypes, + GoTypes: file_feature_pdisc_proto_goTypes, + DependencyIndexes: file_feature_pdisc_proto_depIdxs, + EnumInfos: file_feature_pdisc_proto_enumTypes, + MessageInfos: file_feature_pdisc_proto_msgTypes, }.Build() - File_feat_pdisc_proto = out.File - file_feat_pdisc_proto_rawDesc = nil - file_feat_pdisc_proto_goTypes = nil - file_feat_pdisc_proto_depIdxs = nil + File_feature_pdisc_proto = out.File + file_feature_pdisc_proto_rawDesc = nil + file_feature_pdisc_proto_goTypes = nil + file_feature_pdisc_proto_depIdxs = nil } diff --git a/pkg/proto/feat/pske/pske.pb.go b/pkg/proto/feature/pske/pske.pb.go similarity index 52% rename from pkg/proto/feat/pske/pske.pb.go rename to pkg/proto/feature/pske/pske.pb.go index 63ec8909..a26921f7 100644 --- a/pkg/proto/feat/pske/pske.pb.go +++ b/pkg/proto/feature/pske/pske.pb.go @@ -2,7 +2,7 @@ // versions: // protoc-gen-go v1.28.1 // protoc v3.6.1 -// source: feat/pske.proto +// source: feature/pske.proto package pske @@ -32,7 +32,7 @@ type PresharedKeyEstablishment struct { func (x *PresharedKeyEstablishment) Reset() { *x = PresharedKeyEstablishment{} if protoimpl.UnsafeEnabled { - mi := &file_feat_pske_proto_msgTypes[0] + mi := &file_feature_pske_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -45,7 +45,7 @@ func (x *PresharedKeyEstablishment) String() string { func (*PresharedKeyEstablishment) ProtoMessage() {} func (x *PresharedKeyEstablishment) ProtoReflect() protoreflect.Message { - mi := &file_feat_pske_proto_msgTypes[0] + mi := &file_feature_pske_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -58,7 +58,7 @@ func (x *PresharedKeyEstablishment) ProtoReflect() protoreflect.Message { // Deprecated: Use PresharedKeyEstablishment.ProtoReflect.Descriptor instead. func (*PresharedKeyEstablishment) Descriptor() ([]byte, []int) { - return file_feat_pske_proto_rawDescGZIP(), []int{0} + return file_feature_pske_proto_rawDescGZIP(), []int{0} } func (x *PresharedKeyEstablishment) GetPublicKey() []byte { @@ -75,40 +75,40 @@ func (x *PresharedKeyEstablishment) GetCipherText() []byte { return nil } -var File_feat_pske_proto protoreflect.FileDescriptor +var File_feature_pske_proto protoreflect.FileDescriptor -var file_feat_pske_proto_rawDesc = []byte{ - 0x0a, 0x0f, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x70, 0x73, 0x6b, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x0b, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x70, 0x73, 0x6b, 0x65, 0x22, 0x5b, - 0x0a, 0x19, 0x50, 0x72, 0x65, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x45, 0x73, - 0x74, 0x61, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, - 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x69, - 0x70, 0x68, 0x65, 0x72, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x0a, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x54, 0x65, 0x78, 0x74, 0x42, 0x2d, 0x5a, 0x2b, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, - 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2f, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x70, 0x73, 0x6b, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, +var file_feature_pske_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x70, 0x73, 0x6b, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x70, 0x73, 0x6b, + 0x65, 0x22, 0x5b, 0x0a, 0x19, 0x50, 0x72, 0x65, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x4b, 0x65, + 0x79, 0x45, 0x73, 0x74, 0x61, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1d, + 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, + 0x0b, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x0a, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x54, 0x65, 0x78, 0x74, 0x42, 0x30, + 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, + 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x70, 0x73, 0x6b, 0x65, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_feat_pske_proto_rawDescOnce sync.Once - file_feat_pske_proto_rawDescData = file_feat_pske_proto_rawDesc + file_feature_pske_proto_rawDescOnce sync.Once + file_feature_pske_proto_rawDescData = file_feature_pske_proto_rawDesc ) -func file_feat_pske_proto_rawDescGZIP() []byte { - file_feat_pske_proto_rawDescOnce.Do(func() { - file_feat_pske_proto_rawDescData = protoimpl.X.CompressGZIP(file_feat_pske_proto_rawDescData) +func file_feature_pske_proto_rawDescGZIP() []byte { + file_feature_pske_proto_rawDescOnce.Do(func() { + file_feature_pske_proto_rawDescData = protoimpl.X.CompressGZIP(file_feature_pske_proto_rawDescData) }) - return file_feat_pske_proto_rawDescData + return file_feature_pske_proto_rawDescData } -var file_feat_pske_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_feat_pske_proto_goTypes = []interface{}{ +var file_feature_pske_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_feature_pske_proto_goTypes = []interface{}{ (*PresharedKeyEstablishment)(nil), // 0: cunicu.pske.PresharedKeyEstablishment } -var file_feat_pske_proto_depIdxs = []int32{ +var file_feature_pske_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name @@ -116,13 +116,13 @@ var file_feat_pske_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { file_feat_pske_proto_init() } -func file_feat_pske_proto_init() { - if File_feat_pske_proto != nil { +func init() { file_feature_pske_proto_init() } +func file_feature_pske_proto_init() { + if File_feature_pske_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_feat_pske_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_feature_pske_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PresharedKeyEstablishment); i { case 0: return &v.state @@ -139,18 +139,18 @@ func file_feat_pske_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_feat_pske_proto_rawDesc, + RawDescriptor: file_feature_pske_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_feat_pske_proto_goTypes, - DependencyIndexes: file_feat_pske_proto_depIdxs, - MessageInfos: file_feat_pske_proto_msgTypes, + GoTypes: file_feature_pske_proto_goTypes, + DependencyIndexes: file_feature_pske_proto_depIdxs, + MessageInfos: file_feature_pske_proto_msgTypes, }.Build() - File_feat_pske_proto = out.File - file_feat_pske_proto_rawDesc = nil - file_feat_pske_proto_goTypes = nil - file_feat_pske_proto_depIdxs = nil + File_feature_pske_proto = out.File + file_feature_pske_proto_rawDesc = nil + file_feature_pske_proto_goTypes = nil + file_feature_pske_proto_depIdxs = nil } diff --git a/pkg/proto/proto.go b/pkg/proto/proto.go index 8fa18d09..76a3ba7c 100644 --- a/pkg/proto/proto.go +++ b/pkg/proto/proto.go @@ -4,8 +4,8 @@ package proto //go:generate protoc --proto_path=../../proto --go_out=. --go_opt=paths=import,module=github.com/stv0g/cunicu/pkg/proto common.proto //go:generate protoc --proto_path=../../proto --go_out=. --go_opt=paths=import,module=github.com/stv0g/cunicu/pkg/proto core/peer.proto core/interface.proto //go:generate protoc --proto_path=../../proto --go_out=. --go_opt=paths=import,module=github.com/stv0g/cunicu/pkg/proto signaling/signaling.proto signaling/relay.proto -//go:generate protoc --proto_path=../../proto --go_out=. --go_opt=paths=import,module=github.com/stv0g/cunicu/pkg/proto rpc/daemon.proto rpc/epdisc.proto rpc/event.proto rpc/signaling.proto -//go:generate protoc --proto_path=../../proto --go_out=. --go_opt=paths=import,module=github.com/stv0g/cunicu/pkg/proto feat/epdisc.proto feat/epdisc_candidate.proto feat/pdisc.proto feat/pske.proto feat/hooks.proto +//go:generate protoc --proto_path=../../proto --go_out=. --go_opt=paths=import,module=github.com/stv0g/cunicu/pkg/proto rpc/daemon.proto rpc/epdisc.proto rpc/event.proto rpc/signaling.proto rpc/invitation.proto +//go:generate protoc --proto_path=../../proto --go_out=. --go_opt=paths=import,module=github.com/stv0g/cunicu/pkg/proto feature/epdisc.proto feature/epdisc_candidate.proto feature/pdisc.proto feature/pske.proto feature/hooks.proto //go:generate protoc --proto_path=../../proto --go-grpc_out=. --go-grpc_opt=paths=import,module=github.com/stv0g/cunicu/pkg/proto rpc/daemon.proto rpc/epdisc.proto rpc/signaling.proto //go:generate protoc --proto_path=../../proto --go-grpc_out=. --go-grpc_opt=paths=import,module=github.com/stv0g/cunicu/pkg/proto signaling/signaling.proto signaling/relay.proto diff --git a/pkg/proto/rpc/daemon.pb.go b/pkg/proto/rpc/daemon.pb.go index 84a01dee..f335be1e 100644 --- a/pkg/proto/rpc/daemon.pb.go +++ b/pkg/proto/rpc/daemon.pb.go @@ -22,16 +22,17 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type StatusResp struct { +type GetStatusParams struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Interfaces []*core.Interface `protobuf:"bytes,1,rep,name=interfaces,proto3" json:"interfaces,omitempty"` + Interface string `protobuf:"bytes,1,opt,name=interface,proto3" json:"interface,omitempty"` + Peer []byte `protobuf:"bytes,2,opt,name=peer,proto3" json:"peer,omitempty"` } -func (x *StatusResp) Reset() { - *x = StatusResp{} +func (x *GetStatusParams) Reset() { + *x = GetStatusParams{} if protoimpl.UnsafeEnabled { mi := &file_rpc_daemon_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -39,13 +40,13 @@ func (x *StatusResp) Reset() { } } -func (x *StatusResp) String() string { +func (x *GetStatusParams) String() string { return protoimpl.X.MessageStringOf(x) } -func (*StatusResp) ProtoMessage() {} +func (*GetStatusParams) ProtoMessage() {} -func (x *StatusResp) ProtoReflect() protoreflect.Message { +func (x *GetStatusParams) ProtoReflect() protoreflect.Message { mi := &file_rpc_daemon_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -57,29 +58,35 @@ func (x *StatusResp) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use StatusResp.ProtoReflect.Descriptor instead. -func (*StatusResp) Descriptor() ([]byte, []int) { +// Deprecated: Use GetStatusParams.ProtoReflect.Descriptor instead. +func (*GetStatusParams) Descriptor() ([]byte, []int) { return file_rpc_daemon_proto_rawDescGZIP(), []int{0} } -func (x *StatusResp) GetInterfaces() []*core.Interface { +func (x *GetStatusParams) GetInterface() string { if x != nil { - return x.Interfaces + return x.Interface + } + return "" +} + +func (x *GetStatusParams) GetPeer() []byte { + if x != nil { + return x.Peer } return nil } -type StatusParams struct { +type GetStatusResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Intf string `protobuf:"bytes,1,opt,name=intf,proto3" json:"intf,omitempty"` - Peer []byte `protobuf:"bytes,2,opt,name=peer,proto3" json:"peer,omitempty"` + Interfaces []*core.Interface `protobuf:"bytes,1,rep,name=interfaces,proto3" json:"interfaces,omitempty"` } -func (x *StatusParams) Reset() { - *x = StatusParams{} +func (x *GetStatusResp) Reset() { + *x = GetStatusResp{} if protoimpl.UnsafeEnabled { mi := &file_rpc_daemon_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -87,13 +94,13 @@ func (x *StatusParams) Reset() { } } -func (x *StatusParams) String() string { +func (x *GetStatusResp) String() string { return protoimpl.X.MessageStringOf(x) } -func (*StatusParams) ProtoMessage() {} +func (*GetStatusResp) ProtoMessage() {} -func (x *StatusParams) ProtoReflect() protoreflect.Message { +func (x *GetStatusResp) ProtoReflect() protoreflect.Message { mi := &file_rpc_daemon_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -105,21 +112,14 @@ func (x *StatusParams) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use StatusParams.ProtoReflect.Descriptor instead. -func (*StatusParams) Descriptor() ([]byte, []int) { +// Deprecated: Use GetStatusResp.ProtoReflect.Descriptor instead. +func (*GetStatusResp) Descriptor() ([]byte, []int) { return file_rpc_daemon_proto_rawDescGZIP(), []int{1} } -func (x *StatusParams) GetIntf() string { +func (x *GetStatusResp) GetInterfaces() []*core.Interface { if x != nil { - return x.Intf - } - return "" -} - -func (x *StatusParams) GetPeer() []byte { - if x != nil { - return x.Peer + return x.Interfaces } return nil } @@ -265,6 +265,124 @@ func (x *GetConfigResp) GetSettings() map[string]string { return nil } +type AddPeerParams struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Interface string `protobuf:"bytes,1,opt,name=interface,proto3" json:"interface,omitempty"` + PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *AddPeerParams) Reset() { + *x = AddPeerParams{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_daemon_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddPeerParams) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddPeerParams) ProtoMessage() {} + +func (x *AddPeerParams) ProtoReflect() protoreflect.Message { + mi := &file_rpc_daemon_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddPeerParams.ProtoReflect.Descriptor instead. +func (*AddPeerParams) Descriptor() ([]byte, []int) { + return file_rpc_daemon_proto_rawDescGZIP(), []int{5} +} + +func (x *AddPeerParams) GetInterface() string { + if x != nil { + return x.Interface + } + return "" +} + +func (x *AddPeerParams) GetPublicKey() []byte { + if x != nil { + return x.PublicKey + } + return nil +} + +func (x *AddPeerParams) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type AddPeerResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Invitation *Invitation `protobuf:"bytes,1,opt,name=invitation,proto3" json:"invitation,omitempty"` + Interface *core.Interface `protobuf:"bytes,2,opt,name=interface,proto3" json:"interface,omitempty"` +} + +func (x *AddPeerResp) Reset() { + *x = AddPeerResp{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_daemon_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddPeerResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddPeerResp) ProtoMessage() {} + +func (x *AddPeerResp) ProtoReflect() protoreflect.Message { + mi := &file_rpc_daemon_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddPeerResp.ProtoReflect.Descriptor instead. +func (*AddPeerResp) Descriptor() ([]byte, []int) { + return file_rpc_daemon_proto_rawDescGZIP(), []int{6} +} + +func (x *AddPeerResp) GetInvitation() *Invitation { + if x != nil { + return x.Invitation + } + return nil +} + +func (x *AddPeerResp) GetInterface() *core.Interface { + if x != nil { + return x.Interface + } + return nil +} + var File_rpc_daemon_proto protoreflect.FileDescriptor var file_rpc_daemon_proto_rawDesc = []byte{ @@ -273,69 +391,93 @@ var file_rpc_daemon_proto_rawDesc = []byte{ 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0x44, 0x0a, 0x0a, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x12, 0x36, 0x0a, 0x0a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x63, - 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x0a, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x22, 0x36, 0x0a, 0x0c, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x6e, 0x74, - 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x6e, 0x74, 0x66, 0x12, 0x12, 0x0a, - 0x04, 0x70, 0x65, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x70, 0x65, 0x65, - 0x72, 0x22, 0x95, 0x01, 0x0a, 0x0f, 0x53, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x45, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, - 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x1a, 0x3b, 0x0a, 0x0d, - 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, - 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, - 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x30, 0x0a, 0x0f, 0x47, 0x65, 0x74, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1d, 0x0a, 0x0a, - 0x6b, 0x65, 0x79, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x6b, 0x65, 0x79, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x22, 0x91, 0x01, 0x0a, 0x0d, - 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x12, 0x43, 0x0a, - 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x27, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, + 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x72, 0x70, 0x63, 0x2f, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x43, 0x0a, 0x0f, 0x47, 0x65, 0x74, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1c, 0x0a, 0x09, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x65, + 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x70, 0x65, 0x65, 0x72, 0x22, 0x47, + 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, + 0x36, 0x0a, 0x0a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x63, 0x6f, 0x72, + 0x65, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x0a, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x22, 0x95, 0x01, 0x0a, 0x0f, 0x53, 0x65, 0x74, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x45, 0x0a, 0x08, 0x73, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, + 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x65, 0x74, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x1a, 0x3b, 0x0a, 0x0d, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, - 0xda, 0x03, 0x0a, 0x06, 0x44, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x0c, 0x47, 0x65, - 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0d, 0x2e, 0x63, 0x75, 0x6e, - 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, - 0x63, 0x75, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x12, 0x34, - 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x0d, - 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x11, 0x2e, - 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x22, 0x00, 0x30, 0x01, 0x12, 0x28, 0x0a, 0x06, 0x55, 0x6e, 0x57, 0x61, 0x69, 0x74, 0x12, 0x0d, - 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, - 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x26, - 0x0a, 0x04, 0x53, 0x74, 0x6f, 0x70, 0x12, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, + 0x30, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6b, 0x65, 0x79, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6b, 0x65, 0x79, 0x46, 0x69, 0x6c, 0x74, 0x65, + 0x72, 0x22, 0x91, 0x01, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, + 0x65, 0x73, 0x70, 0x12, 0x43, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, + 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, + 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, + 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x1a, 0x3b, 0x0a, 0x0d, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x60, 0x0a, 0x0d, 0x41, 0x64, 0x64, 0x50, 0x65, 0x65, 0x72, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, + 0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x66, 0x61, 0x63, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, + 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, + 0x4b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x7b, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x50, 0x65, + 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x36, 0x0a, 0x0a, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x75, 0x6e, + 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x0a, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x34, + 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x66, 0x61, 0x63, 0x65, 0x32, 0xd1, 0x04, 0x0a, 0x06, 0x44, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x12, + 0x32, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, + 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x11, + 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, + 0x6f, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x73, 0x12, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x1a, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, + 0x45, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x30, 0x01, 0x12, 0x28, 0x0a, 0x06, 0x55, 0x6e, 0x57, + 0x61, 0x69, 0x74, 0x12, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x22, 0x00, 0x12, 0x26, 0x0a, 0x04, 0x53, 0x74, 0x6f, 0x70, 0x12, 0x0d, 0x2e, 0x63, 0x75, + 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x63, 0x75, 0x6e, + 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x29, 0x0a, 0x07, 0x52, + 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x29, 0x0a, 0x07, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, - 0x74, 0x12, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x1a, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, - 0x00, 0x12, 0x26, 0x0a, 0x04, 0x53, 0x79, 0x6e, 0x63, 0x12, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, - 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, - 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x3f, 0x0a, 0x09, 0x47, 0x65, 0x74, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, - 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, - 0x1a, 0x16, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x09, 0x53, 0x65, - 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1b, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, - 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, + 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x26, 0x0a, 0x04, 0x53, 0x79, 0x6e, 0x63, 0x12, 0x0d, + 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, + 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x45, + 0x0a, 0x09, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x2e, 0x63, 0x75, + 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x19, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, + 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x09, 0x53, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1b, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, - 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, - 0x19, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x27, 0x5a, 0x25, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, - 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x53, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, + 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, + 0x12, 0x45, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1b, 0x2e, + 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x19, 0x2e, 0x63, 0x75, 0x6e, + 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x2e, 0x0a, 0x0c, 0x52, 0x65, 0x6c, 0x6f, 0x61, + 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x3f, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x50, 0x65, + 0x65, 0x72, 0x12, 0x19, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, + 0x41, 0x64, 0x64, 0x50, 0x65, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x17, 0x2e, + 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x65, + 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, + 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x70, + 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -350,47 +492,56 @@ func file_rpc_daemon_proto_rawDescGZIP() []byte { return file_rpc_daemon_proto_rawDescData } -var file_rpc_daemon_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_rpc_daemon_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_rpc_daemon_proto_goTypes = []interface{}{ - (*StatusResp)(nil), // 0: cunicu.rpc.StatusResp - (*StatusParams)(nil), // 1: cunicu.rpc.StatusParams + (*GetStatusParams)(nil), // 0: cunicu.rpc.GetStatusParams + (*GetStatusResp)(nil), // 1: cunicu.rpc.GetStatusResp (*SetConfigParams)(nil), // 2: cunicu.rpc.SetConfigParams (*GetConfigParams)(nil), // 3: cunicu.rpc.GetConfigParams (*GetConfigResp)(nil), // 4: cunicu.rpc.GetConfigResp - nil, // 5: cunicu.rpc.SetConfigParams.SettingsEntry - nil, // 6: cunicu.rpc.GetConfigResp.SettingsEntry - (*core.Interface)(nil), // 7: cunicu.core.Interface - (*proto.Empty)(nil), // 8: cunicu.Empty - (*proto.BuildInfo)(nil), // 9: cunicu.BuildInfo - (*Event)(nil), // 10: cunicu.rpc.Event + (*AddPeerParams)(nil), // 5: cunicu.rpc.AddPeerParams + (*AddPeerResp)(nil), // 6: cunicu.rpc.AddPeerResp + nil, // 7: cunicu.rpc.SetConfigParams.SettingsEntry + nil, // 8: cunicu.rpc.GetConfigResp.SettingsEntry + (*core.Interface)(nil), // 9: cunicu.core.Interface + (*Invitation)(nil), // 10: cunicu.rpc.Invitation + (*proto.Empty)(nil), // 11: cunicu.Empty + (*proto.BuildInfo)(nil), // 12: cunicu.BuildInfo + (*Event)(nil), // 13: cunicu.rpc.Event } var file_rpc_daemon_proto_depIdxs = []int32{ - 7, // 0: cunicu.rpc.StatusResp.interfaces:type_name -> cunicu.core.Interface - 5, // 1: cunicu.rpc.SetConfigParams.settings:type_name -> cunicu.rpc.SetConfigParams.SettingsEntry - 6, // 2: cunicu.rpc.GetConfigResp.settings:type_name -> cunicu.rpc.GetConfigResp.SettingsEntry - 8, // 3: cunicu.rpc.Daemon.GetBuildInfo:input_type -> cunicu.Empty - 8, // 4: cunicu.rpc.Daemon.StreamEvents:input_type -> cunicu.Empty - 8, // 5: cunicu.rpc.Daemon.UnWait:input_type -> cunicu.Empty - 8, // 6: cunicu.rpc.Daemon.Stop:input_type -> cunicu.Empty - 8, // 7: cunicu.rpc.Daemon.Restart:input_type -> cunicu.Empty - 8, // 8: cunicu.rpc.Daemon.Sync:input_type -> cunicu.Empty - 1, // 9: cunicu.rpc.Daemon.GetStatus:input_type -> cunicu.rpc.StatusParams - 2, // 10: cunicu.rpc.Daemon.SetConfig:input_type -> cunicu.rpc.SetConfigParams - 3, // 11: cunicu.rpc.Daemon.GetConfig:input_type -> cunicu.rpc.GetConfigParams - 9, // 12: cunicu.rpc.Daemon.GetBuildInfo:output_type -> cunicu.BuildInfo - 10, // 13: cunicu.rpc.Daemon.StreamEvents:output_type -> cunicu.rpc.Event - 8, // 14: cunicu.rpc.Daemon.UnWait:output_type -> cunicu.Empty - 8, // 15: cunicu.rpc.Daemon.Stop:output_type -> cunicu.Empty - 8, // 16: cunicu.rpc.Daemon.Restart:output_type -> cunicu.Empty - 8, // 17: cunicu.rpc.Daemon.Sync:output_type -> cunicu.Empty - 0, // 18: cunicu.rpc.Daemon.GetStatus:output_type -> cunicu.rpc.StatusResp - 8, // 19: cunicu.rpc.Daemon.SetConfig:output_type -> cunicu.Empty - 4, // 20: cunicu.rpc.Daemon.GetConfig:output_type -> cunicu.rpc.GetConfigResp - 12, // [12:21] is the sub-list for method output_type - 3, // [3:12] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 9, // 0: cunicu.rpc.GetStatusResp.interfaces:type_name -> cunicu.core.Interface + 7, // 1: cunicu.rpc.SetConfigParams.settings:type_name -> cunicu.rpc.SetConfigParams.SettingsEntry + 8, // 2: cunicu.rpc.GetConfigResp.settings:type_name -> cunicu.rpc.GetConfigResp.SettingsEntry + 10, // 3: cunicu.rpc.AddPeerResp.invitation:type_name -> cunicu.rpc.Invitation + 9, // 4: cunicu.rpc.AddPeerResp.interface:type_name -> cunicu.core.Interface + 11, // 5: cunicu.rpc.Daemon.GetBuildInfo:input_type -> cunicu.Empty + 11, // 6: cunicu.rpc.Daemon.StreamEvents:input_type -> cunicu.Empty + 11, // 7: cunicu.rpc.Daemon.UnWait:input_type -> cunicu.Empty + 11, // 8: cunicu.rpc.Daemon.Stop:input_type -> cunicu.Empty + 11, // 9: cunicu.rpc.Daemon.Restart:input_type -> cunicu.Empty + 11, // 10: cunicu.rpc.Daemon.Sync:input_type -> cunicu.Empty + 0, // 11: cunicu.rpc.Daemon.GetStatus:input_type -> cunicu.rpc.GetStatusParams + 2, // 12: cunicu.rpc.Daemon.SetConfig:input_type -> cunicu.rpc.SetConfigParams + 3, // 13: cunicu.rpc.Daemon.GetConfig:input_type -> cunicu.rpc.GetConfigParams + 11, // 14: cunicu.rpc.Daemon.ReloadConfig:input_type -> cunicu.Empty + 5, // 15: cunicu.rpc.Daemon.AddPeer:input_type -> cunicu.rpc.AddPeerParams + 12, // 16: cunicu.rpc.Daemon.GetBuildInfo:output_type -> cunicu.BuildInfo + 13, // 17: cunicu.rpc.Daemon.StreamEvents:output_type -> cunicu.rpc.Event + 11, // 18: cunicu.rpc.Daemon.UnWait:output_type -> cunicu.Empty + 11, // 19: cunicu.rpc.Daemon.Stop:output_type -> cunicu.Empty + 11, // 20: cunicu.rpc.Daemon.Restart:output_type -> cunicu.Empty + 11, // 21: cunicu.rpc.Daemon.Sync:output_type -> cunicu.Empty + 1, // 22: cunicu.rpc.Daemon.GetStatus:output_type -> cunicu.rpc.GetStatusResp + 11, // 23: cunicu.rpc.Daemon.SetConfig:output_type -> cunicu.Empty + 4, // 24: cunicu.rpc.Daemon.GetConfig:output_type -> cunicu.rpc.GetConfigResp + 11, // 25: cunicu.rpc.Daemon.ReloadConfig:output_type -> cunicu.Empty + 6, // 26: cunicu.rpc.Daemon.AddPeer:output_type -> cunicu.rpc.AddPeerResp + 16, // [16:27] is the sub-list for method output_type + 5, // [5:16] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_rpc_daemon_proto_init() } @@ -399,9 +550,10 @@ func file_rpc_daemon_proto_init() { return } file_rpc_event_proto_init() + file_rpc_invitation_proto_init() if !protoimpl.UnsafeEnabled { file_rpc_daemon_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StatusResp); i { + switch v := v.(*GetStatusParams); i { case 0: return &v.state case 1: @@ -413,7 +565,7 @@ func file_rpc_daemon_proto_init() { } } file_rpc_daemon_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StatusParams); i { + switch v := v.(*GetStatusResp); i { case 0: return &v.state case 1: @@ -460,6 +612,30 @@ func file_rpc_daemon_proto_init() { return nil } } + file_rpc_daemon_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddPeerParams); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_daemon_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddPeerResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -467,7 +643,7 @@ func file_rpc_daemon_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_rpc_daemon_proto_rawDesc, NumEnums: 0, - NumMessages: 7, + NumMessages: 9, NumExtensions: 0, NumServices: 1, }, diff --git a/pkg/proto/rpc/daemon_grpc.pb.go b/pkg/proto/rpc/daemon_grpc.pb.go index f8ac19bd..81c3b431 100644 --- a/pkg/proto/rpc/daemon_grpc.pb.go +++ b/pkg/proto/rpc/daemon_grpc.pb.go @@ -29,9 +29,11 @@ type DaemonClient interface { Stop(ctx context.Context, in *proto.Empty, opts ...grpc.CallOption) (*proto.Empty, error) Restart(ctx context.Context, in *proto.Empty, opts ...grpc.CallOption) (*proto.Empty, error) Sync(ctx context.Context, in *proto.Empty, opts ...grpc.CallOption) (*proto.Empty, error) - GetStatus(ctx context.Context, in *StatusParams, opts ...grpc.CallOption) (*StatusResp, error) + GetStatus(ctx context.Context, in *GetStatusParams, opts ...grpc.CallOption) (*GetStatusResp, error) SetConfig(ctx context.Context, in *SetConfigParams, opts ...grpc.CallOption) (*proto.Empty, error) GetConfig(ctx context.Context, in *GetConfigParams, opts ...grpc.CallOption) (*GetConfigResp, error) + ReloadConfig(ctx context.Context, in *proto.Empty, opts ...grpc.CallOption) (*proto.Empty, error) + AddPeer(ctx context.Context, in *AddPeerParams, opts ...grpc.CallOption) (*AddPeerResp, error) } type daemonClient struct { @@ -119,8 +121,8 @@ func (c *daemonClient) Sync(ctx context.Context, in *proto.Empty, opts ...grpc.C return out, nil } -func (c *daemonClient) GetStatus(ctx context.Context, in *StatusParams, opts ...grpc.CallOption) (*StatusResp, error) { - out := new(StatusResp) +func (c *daemonClient) GetStatus(ctx context.Context, in *GetStatusParams, opts ...grpc.CallOption) (*GetStatusResp, error) { + out := new(GetStatusResp) err := c.cc.Invoke(ctx, "/cunicu.rpc.Daemon/GetStatus", in, out, opts...) if err != nil { return nil, err @@ -146,6 +148,24 @@ func (c *daemonClient) GetConfig(ctx context.Context, in *GetConfigParams, opts return out, nil } +func (c *daemonClient) ReloadConfig(ctx context.Context, in *proto.Empty, opts ...grpc.CallOption) (*proto.Empty, error) { + out := new(proto.Empty) + err := c.cc.Invoke(ctx, "/cunicu.rpc.Daemon/ReloadConfig", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *daemonClient) AddPeer(ctx context.Context, in *AddPeerParams, opts ...grpc.CallOption) (*AddPeerResp, error) { + out := new(AddPeerResp) + err := c.cc.Invoke(ctx, "/cunicu.rpc.Daemon/AddPeer", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // DaemonServer is the server API for Daemon service. // All implementations must embed UnimplementedDaemonServer // for forward compatibility @@ -156,9 +176,11 @@ type DaemonServer interface { Stop(context.Context, *proto.Empty) (*proto.Empty, error) Restart(context.Context, *proto.Empty) (*proto.Empty, error) Sync(context.Context, *proto.Empty) (*proto.Empty, error) - GetStatus(context.Context, *StatusParams) (*StatusResp, error) + GetStatus(context.Context, *GetStatusParams) (*GetStatusResp, error) SetConfig(context.Context, *SetConfigParams) (*proto.Empty, error) GetConfig(context.Context, *GetConfigParams) (*GetConfigResp, error) + ReloadConfig(context.Context, *proto.Empty) (*proto.Empty, error) + AddPeer(context.Context, *AddPeerParams) (*AddPeerResp, error) mustEmbedUnimplementedDaemonServer() } @@ -184,7 +206,7 @@ func (UnimplementedDaemonServer) Restart(context.Context, *proto.Empty) (*proto. func (UnimplementedDaemonServer) Sync(context.Context, *proto.Empty) (*proto.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Sync not implemented") } -func (UnimplementedDaemonServer) GetStatus(context.Context, *StatusParams) (*StatusResp, error) { +func (UnimplementedDaemonServer) GetStatus(context.Context, *GetStatusParams) (*GetStatusResp, error) { return nil, status.Errorf(codes.Unimplemented, "method GetStatus not implemented") } func (UnimplementedDaemonServer) SetConfig(context.Context, *SetConfigParams) (*proto.Empty, error) { @@ -193,6 +215,12 @@ func (UnimplementedDaemonServer) SetConfig(context.Context, *SetConfigParams) (* func (UnimplementedDaemonServer) GetConfig(context.Context, *GetConfigParams) (*GetConfigResp, error) { return nil, status.Errorf(codes.Unimplemented, "method GetConfig not implemented") } +func (UnimplementedDaemonServer) ReloadConfig(context.Context, *proto.Empty) (*proto.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method ReloadConfig not implemented") +} +func (UnimplementedDaemonServer) AddPeer(context.Context, *AddPeerParams) (*AddPeerResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddPeer not implemented") +} func (UnimplementedDaemonServer) mustEmbedUnimplementedDaemonServer() {} // UnsafeDaemonServer may be embedded to opt out of forward compatibility for this service. @@ -318,7 +346,7 @@ func _Daemon_Sync_Handler(srv interface{}, ctx context.Context, dec func(interfa } func _Daemon_GetStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(StatusParams) + in := new(GetStatusParams) if err := dec(in); err != nil { return nil, err } @@ -330,7 +358,7 @@ func _Daemon_GetStatus_Handler(srv interface{}, ctx context.Context, dec func(in FullMethod: "/cunicu.rpc.Daemon/GetStatus", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DaemonServer).GetStatus(ctx, req.(*StatusParams)) + return srv.(DaemonServer).GetStatus(ctx, req.(*GetStatusParams)) } return interceptor(ctx, in, info, handler) } @@ -371,6 +399,42 @@ func _Daemon_GetConfig_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Daemon_ReloadConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(proto.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DaemonServer).ReloadConfig(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cunicu.rpc.Daemon/ReloadConfig", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DaemonServer).ReloadConfig(ctx, req.(*proto.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _Daemon_AddPeer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddPeerParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DaemonServer).AddPeer(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cunicu.rpc.Daemon/AddPeer", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DaemonServer).AddPeer(ctx, req.(*AddPeerParams)) + } + return interceptor(ctx, in, info, handler) +} + // Daemon_ServiceDesc is the grpc.ServiceDesc for Daemon service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -410,6 +474,14 @@ var Daemon_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetConfig", Handler: _Daemon_GetConfig_Handler, }, + { + MethodName: "ReloadConfig", + Handler: _Daemon_ReloadConfig_Handler, + }, + { + MethodName: "AddPeer", + Handler: _Daemon_AddPeer_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/pkg/proto/rpc/event.pb.go b/pkg/proto/rpc/event.pb.go index 5811d9fe..2c39b0e7 100644 --- a/pkg/proto/rpc/event.pb.go +++ b/pkg/proto/rpc/event.pb.go @@ -8,7 +8,7 @@ package rpc import ( proto "github.com/stv0g/cunicu/pkg/proto" - epdisc "github.com/stv0g/cunicu/pkg/proto/feat/epdisc" + epdisc "github.com/stv0g/cunicu/pkg/proto/feature/epdisc" signaling "github.com/stv0g/cunicu/pkg/proto/signaling" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -442,78 +442,78 @@ var file_rpc_event_proto_rawDesc = []byte{ 0x6f, 0x12, 0x0a, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x1a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x11, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x65, 0x70, 0x64, - 0x69, 0x73, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xed, 0x03, 0x0a, 0x05, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x12, 0x29, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x15, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x25, - 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, - 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, - 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x65, 0x65, 0x72, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x04, 0x70, 0x65, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x4d, 0x0a, 0x0d, 0x62, 0x61, 0x63, 0x6b, 0x65, - 0x6e, 0x64, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x64, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, - 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x69, 0x67, 0x6e, - 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x61, 0x64, - 0x79, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0c, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, - 0x64, 0x52, 0x65, 0x61, 0x64, 0x79, 0x12, 0x6d, 0x0a, 0x1c, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x63, - 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, - 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x79, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, - 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x43, 0x6f, - 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, - 0x6e, 0x67, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x19, 0x70, 0x65, 0x65, 0x72, - 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, - 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x44, 0x0a, 0x0d, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x6d, 0x6f, - 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, 0x7a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, - 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x6f, - 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0c, 0x70, - 0x65, 0x65, 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x12, 0x53, 0x0a, 0x12, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, - 0x64, 0x18, 0x7b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, - 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x4d, 0x6f, - 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x11, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, - 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x2f, 0x0a, 0x11, 0x50, 0x65, 0x65, - 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1a, - 0x0a, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x22, 0x34, 0x0a, 0x16, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, - 0x22, 0x9c, 0x01, 0x0a, 0x1e, 0x50, 0x65, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x12, 0x3b, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, - 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x12, 0x3d, 0x0a, 0x0a, 0x70, 0x72, 0x65, 0x76, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, - 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x52, 0x09, 0x70, 0x72, 0x65, 0x76, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, - 0x4f, 0x0a, 0x1a, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x42, 0x61, 0x63, 0x6b, - 0x65, 0x6e, 0x64, 0x52, 0x65, 0x61, 0x64, 0x79, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x31, 0x0a, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x63, 0x75, - 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x42, - 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x2a, 0xde, 0x01, 0x0a, 0x09, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, - 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x42, - 0x41, 0x43, 0x4b, 0x45, 0x4e, 0x44, 0x5f, 0x52, 0x45, 0x41, 0x44, 0x59, 0x10, 0x0a, 0x12, 0x15, - 0x0a, 0x11, 0x53, 0x49, 0x47, 0x4e, 0x41, 0x4c, 0x49, 0x4e, 0x47, 0x5f, 0x4d, 0x45, 0x53, 0x53, - 0x41, 0x47, 0x45, 0x10, 0x0b, 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x41, 0x44, - 0x44, 0x45, 0x44, 0x10, 0x14, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x52, 0x45, - 0x4d, 0x4f, 0x56, 0x45, 0x44, 0x10, 0x15, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x45, 0x45, 0x52, 0x5f, - 0x4d, 0x4f, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x16, 0x12, 0x13, 0x0a, 0x0f, 0x49, 0x4e, - 0x54, 0x45, 0x52, 0x46, 0x41, 0x43, 0x45, 0x5f, 0x41, 0x44, 0x44, 0x45, 0x44, 0x10, 0x1e, 0x12, - 0x15, 0x0a, 0x11, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x46, 0x41, 0x43, 0x45, 0x5f, 0x52, 0x45, 0x4d, - 0x4f, 0x56, 0x45, 0x44, 0x10, 0x1f, 0x12, 0x16, 0x0a, 0x12, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x46, - 0x41, 0x43, 0x45, 0x5f, 0x4d, 0x4f, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x20, 0x12, 0x21, - 0x0a, 0x1d, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x49, 0x4f, - 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x44, 0x10, - 0x28, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, + 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xed, 0x03, 0x0a, + 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x29, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x12, 0x25, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x65, 0x65, 0x72, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x70, 0x65, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x4d, 0x0a, 0x0d, 0x62, 0x61, + 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x64, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, + 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x52, + 0x65, 0x61, 0x64, 0x79, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0c, 0x62, 0x61, 0x63, + 0x6b, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x61, 0x64, 0x79, 0x12, 0x6d, 0x0a, 0x1c, 0x70, 0x65, 0x65, + 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x79, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2a, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x65, 0x65, + 0x72, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x19, 0x70, + 0x65, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x44, 0x0a, 0x0d, 0x70, 0x65, 0x65, 0x72, + 0x5f, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, 0x7a, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x65, 0x65, + 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, + 0x52, 0x0c, 0x70, 0x65, 0x65, 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x12, 0x53, + 0x0a, 0x12, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x6d, 0x6f, 0x64, 0x69, + 0x66, 0x69, 0x65, 0x64, 0x18, 0x7b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x75, 0x6e, + 0x69, 0x63, 0x75, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, + 0x65, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, + 0x52, 0x11, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x4d, 0x6f, 0x64, 0x69, 0x66, + 0x69, 0x65, 0x64, 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x2f, 0x0a, 0x11, + 0x50, 0x65, 0x65, 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x22, 0x34, 0x0a, + 0x16, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, + 0x65, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, + 0x69, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, + 0x69, 0x65, 0x64, 0x22, 0x9c, 0x01, 0x0a, 0x1e, 0x50, 0x65, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, + 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x3b, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x75, 0x6e, 0x69, + 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x12, 0x3d, 0x0a, 0x0a, 0x70, 0x72, 0x65, 0x76, 0x5f, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, + 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x09, 0x70, 0x72, 0x65, 0x76, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x22, 0x4f, 0x0a, 0x1a, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x42, + 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x61, 0x64, 0x79, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x12, 0x31, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, + 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, + 0x67, 0x2e, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x2a, 0xde, 0x01, 0x0a, 0x09, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x11, + 0x0a, 0x0d, 0x42, 0x41, 0x43, 0x4b, 0x45, 0x4e, 0x44, 0x5f, 0x52, 0x45, 0x41, 0x44, 0x59, 0x10, + 0x0a, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x49, 0x47, 0x4e, 0x41, 0x4c, 0x49, 0x4e, 0x47, 0x5f, 0x4d, + 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x10, 0x0b, 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x45, 0x45, 0x52, + 0x5f, 0x41, 0x44, 0x44, 0x45, 0x44, 0x10, 0x14, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x45, 0x45, 0x52, + 0x5f, 0x52, 0x45, 0x4d, 0x4f, 0x56, 0x45, 0x44, 0x10, 0x15, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x45, + 0x45, 0x52, 0x5f, 0x4d, 0x4f, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x16, 0x12, 0x13, 0x0a, + 0x0f, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x46, 0x41, 0x43, 0x45, 0x5f, 0x41, 0x44, 0x44, 0x45, 0x44, + 0x10, 0x1e, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x46, 0x41, 0x43, 0x45, 0x5f, + 0x52, 0x45, 0x4d, 0x4f, 0x56, 0x45, 0x44, 0x10, 0x1f, 0x12, 0x16, 0x0a, 0x12, 0x49, 0x4e, 0x54, + 0x45, 0x52, 0x46, 0x41, 0x43, 0x45, 0x5f, 0x4d, 0x4f, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, + 0x20, 0x12, 0x21, 0x0a, 0x1d, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, + 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x43, 0x48, 0x41, 0x4e, 0x47, + 0x45, 0x44, 0x10, 0x28, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, + 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/proto/rpc/invitation.pb.go b/pkg/proto/rpc/invitation.pb.go new file mode 100644 index 00000000..eca8a5f3 --- /dev/null +++ b/pkg/proto/rpc/invitation.pb.go @@ -0,0 +1,156 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.6.1 +// source: rpc/invitation.proto + +package rpc + +import ( + _ "github.com/stv0g/cunicu/pkg/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Invitation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Community []byte `protobuf:"bytes,1,opt,name=community,proto3" json:"community,omitempty"` + Endpoint string `protobuf:"bytes,2,opt,name=endpoint,proto3" json:"endpoint,omitempty"` +} + +func (x *Invitation) Reset() { + *x = Invitation{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_invitation_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Invitation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Invitation) ProtoMessage() {} + +func (x *Invitation) ProtoReflect() protoreflect.Message { + mi := &file_rpc_invitation_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Invitation.ProtoReflect.Descriptor instead. +func (*Invitation) Descriptor() ([]byte, []int) { + return file_rpc_invitation_proto_rawDescGZIP(), []int{0} +} + +func (x *Invitation) GetCommunity() []byte { + if x != nil { + return x.Community + } + return nil +} + +func (x *Invitation) GetEndpoint() string { + if x != nil { + return x.Endpoint + } + return "" +} + +var File_rpc_invitation_proto protoreflect.FileDescriptor + +var file_rpc_invitation_proto_rawDesc = []byte{ + 0x0a, 0x14, 0x72, 0x70, 0x63, 0x2f, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x72, + 0x70, 0x63, 0x1a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x46, 0x0a, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, + 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x12, 0x1a, 0x0a, 0x08, + 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, + 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x70, + 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_rpc_invitation_proto_rawDescOnce sync.Once + file_rpc_invitation_proto_rawDescData = file_rpc_invitation_proto_rawDesc +) + +func file_rpc_invitation_proto_rawDescGZIP() []byte { + file_rpc_invitation_proto_rawDescOnce.Do(func() { + file_rpc_invitation_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpc_invitation_proto_rawDescData) + }) + return file_rpc_invitation_proto_rawDescData +} + +var file_rpc_invitation_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_rpc_invitation_proto_goTypes = []interface{}{ + (*Invitation)(nil), // 0: cunicu.rpc.Invitation +} +var file_rpc_invitation_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_rpc_invitation_proto_init() } +func file_rpc_invitation_proto_init() { + if File_rpc_invitation_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_rpc_invitation_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Invitation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_rpc_invitation_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_rpc_invitation_proto_goTypes, + DependencyIndexes: file_rpc_invitation_proto_depIdxs, + MessageInfos: file_rpc_invitation_proto_msgTypes, + }.Build() + File_rpc_invitation_proto = out.File + file_rpc_invitation_proto_rawDesc = nil + file_rpc_invitation_proto_goTypes = nil + file_rpc_invitation_proto_depIdxs = nil +} diff --git a/pkg/proto/rpc/rpc.go b/pkg/proto/rpc/rpc.go index e2200e94..c0fefb2b 100644 --- a/pkg/proto/rpc/rpc.go +++ b/pkg/proto/rpc/rpc.go @@ -5,7 +5,7 @@ import ( "io" ) -func (s *StatusResp) Dump(wr io.Writer, verbosity int) error { +func (s *GetStatusResp) Dump(wr io.Writer, verbosity int) error { for k, i := range s.Interfaces { if k > 0 { if _, err := fmt.Fprintln(wr); err != nil { diff --git a/pkg/proto/signaling/signaling.pb.go b/pkg/proto/signaling/signaling.pb.go index 16858855..12e4a616 100644 --- a/pkg/proto/signaling/signaling.pb.go +++ b/pkg/proto/signaling/signaling.pb.go @@ -8,9 +8,9 @@ package signaling import ( proto "github.com/stv0g/cunicu/pkg/proto" - epdisc "github.com/stv0g/cunicu/pkg/proto/feat/epdisc" - pdisc "github.com/stv0g/cunicu/pkg/proto/feat/pdisc" - pske "github.com/stv0g/cunicu/pkg/proto/feat/pske" + epdisc "github.com/stv0g/cunicu/pkg/proto/feature/epdisc" + pdisc "github.com/stv0g/cunicu/pkg/proto/feature/pdisc" + pske "github.com/stv0g/cunicu/pkg/proto/feature/pske" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -322,62 +322,63 @@ var file_signaling_signaling_proto_rawDesc = []byte{ 0x0a, 0x19, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x1a, 0x0c, 0x63, - 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x10, 0x66, 0x65, 0x61, - 0x74, 0x2f, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x66, - 0x65, 0x61, 0x74, 0x2f, 0x70, 0x73, 0x6b, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x11, - 0x66, 0x65, 0x61, 0x74, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x1b, 0x66, 0x65, 0x61, 0x74, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x5f, 0x63, - 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x80, - 0x01, 0x0a, 0x08, 0x45, 0x6e, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, - 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x65, 0x6e, - 0x64, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, - 0x74, 0x12, 0x3e, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, - 0x73, 0x22, 0xee, 0x01, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3c, 0x0a, - 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, - 0x73, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x52, 0x0b, - 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x12, 0x36, 0x0a, 0x09, 0x63, - 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, + 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x13, 0x66, 0x65, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x2f, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x12, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x70, 0x73, 0x6b, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x65, 0x70, + 0x64, 0x69, 0x73, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x66, 0x65, 0x61, 0x74, + 0x75, 0x72, 0x65, 0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x5f, 0x63, 0x61, 0x6e, 0x64, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x80, 0x01, 0x0a, 0x08, 0x45, + 0x6e, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, + 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x09, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x3e, 0x0a, + 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x22, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, + 0x6e, 0x67, 0x2e, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xee, 0x01, + 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, - 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x09, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x12, 0x31, 0x0a, 0x04, 0x70, 0x65, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x70, 0x64, 0x69, 0x73, 0x63, - 0x2e, 0x50, 0x65, 0x65, 0x72, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x04, 0x70, 0x65, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x04, 0x70, 0x73, 0x6b, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x70, 0x73, - 0x6b, 0x65, 0x2e, 0x50, 0x72, 0x65, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x45, - 0x73, 0x74, 0x61, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x04, 0x70, 0x73, - 0x6b, 0x65, 0x22, 0x3c, 0x0a, 0x10, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, - 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, - 0x22, 0x23, 0x0a, 0x0f, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x50, 0x61, 0x72, - 0x61, 0x6d, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x2a, 0x43, 0x0a, 0x0b, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x4d, 0x55, 0x4c, 0x54, 0x49, 0x10, 0x00, 0x12, - 0x07, 0x0a, 0x03, 0x50, 0x32, 0x50, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x4b, 0x38, 0x53, 0x10, - 0x02, 0x12, 0x08, 0x0a, 0x04, 0x47, 0x52, 0x50, 0x43, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x49, - 0x4e, 0x50, 0x52, 0x4f, 0x43, 0x45, 0x53, 0x53, 0x10, 0x04, 0x32, 0xc7, 0x01, 0x0a, 0x09, 0x53, - 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x32, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x42, - 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, - 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, - 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x12, 0x4e, 0x0a, 0x09, - 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x21, 0x2e, 0x63, 0x75, 0x6e, 0x69, - 0x63, 0x75, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x75, 0x62, - 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x1a, 0x2e, 0x63, - 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x2e, - 0x45, 0x6e, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x36, 0x0a, 0x07, - 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x12, 0x1a, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, - 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x45, 0x6e, 0x76, 0x65, 0x6c, - 0x6f, 0x70, 0x65, 0x1a, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x22, 0x00, 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, - 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, - 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x12, 0x36, 0x0a, 0x09, 0x63, 0x61, 0x6e, 0x64, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x75, 0x6e, + 0x69, 0x63, 0x75, 0x2e, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x52, 0x09, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x12, + 0x31, 0x0a, 0x04, 0x70, 0x65, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, + 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x70, 0x64, 0x69, 0x73, 0x63, 0x2e, 0x50, 0x65, 0x65, + 0x72, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x04, 0x70, 0x65, + 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x04, 0x70, 0x73, 0x6b, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x26, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x70, 0x73, 0x6b, 0x65, 0x2e, 0x50, + 0x72, 0x65, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x45, 0x73, 0x74, 0x61, 0x62, + 0x6c, 0x69, 0x73, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x04, 0x70, 0x73, 0x6b, 0x65, 0x22, 0x3c, + 0x0a, 0x10, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x22, 0x23, 0x0a, 0x0f, + 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x2a, 0x43, 0x0a, 0x0b, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x09, 0x0a, 0x05, 0x4d, 0x55, 0x4c, 0x54, 0x49, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x50, + 0x32, 0x50, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x4b, 0x38, 0x53, 0x10, 0x02, 0x12, 0x08, 0x0a, + 0x04, 0x47, 0x52, 0x50, 0x43, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x49, 0x4e, 0x50, 0x52, 0x4f, + 0x43, 0x45, 0x53, 0x53, 0x10, 0x04, 0x32, 0xc7, 0x01, 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, + 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x32, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, + 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x1a, 0x11, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x42, 0x75, 0x69, + 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x12, 0x4e, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, + 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x21, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, + 0x62, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x1a, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, + 0x75, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x45, 0x6e, 0x76, 0x65, + 0x6c, 0x6f, 0x70, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x36, 0x0a, 0x07, 0x50, 0x75, 0x62, 0x6c, + 0x69, 0x73, 0x68, 0x12, 0x1a, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x45, 0x6e, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x1a, + 0x0d, 0x2e, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, + 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, + 0x74, 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/proto/signaling/signaling_test.go b/pkg/proto/signaling/signaling_test.go index f6f64c08..de7faa54 100644 --- a/pkg/proto/signaling/signaling_test.go +++ b/pkg/proto/signaling/signaling_test.go @@ -8,7 +8,7 @@ import ( "github.com/stv0g/cunicu/pkg/crypto" "github.com/stv0g/cunicu/test" - protoepdisc "github.com/stv0g/cunicu/pkg/proto/feat/epdisc" + protoepdisc "github.com/stv0g/cunicu/pkg/proto/feature/epdisc" signalingproto "github.com/stv0g/cunicu/pkg/proto/signaling" ) diff --git a/pkg/rpc/server.go b/pkg/rpc/server.go index 29e442c4..3f4fd71e 100644 --- a/pkg/rpc/server.go +++ b/pkg/rpc/server.go @@ -1,6 +1,7 @@ package rpc import ( + "context" "fmt" "net" "os" @@ -9,9 +10,9 @@ import ( "go.uber.org/zap" "google.golang.org/grpc" + "github.com/stv0g/cunicu/pkg/daemon" "github.com/stv0g/cunicu/pkg/util" - cunicu "github.com/stv0g/cunicu/pkg" rpcproto "github.com/stv0g/cunicu/pkg/proto/rpc" ) @@ -30,7 +31,7 @@ type Server struct { logger *zap.Logger } -func NewServer(d *cunicu.Daemon, socket string) (*Server, error) { +func NewServer(d *daemon.Daemon, socket string) (*Server, error) { s := &Server{ events: util.NewFanOut[*rpcproto.Event](1), logger: zap.L().Named("rpc.server"), @@ -38,15 +39,12 @@ func NewServer(d *cunicu.Daemon, socket string) (*Server, error) { s.waitGroup.Add(1) - s.grpc = grpc.NewServer() + s.grpc = grpc.NewServer(grpc.UnaryInterceptor(s.unaryInterceptor)) // Register services s.daemon = NewDaemonServer(s, d) s.signaling = NewSignalingServer(s, d.Backend) - - if d.EndpointDiscovery != nil { - s.epdisc = NewEndpointDiscoveryServer(s, d.EndpointDiscovery) - } + s.epdisc = NewEndpointDiscoveryServer(s) // Remove old unix sockets if err := os.RemoveAll(socket); err != nil { @@ -77,3 +75,22 @@ func (s *Server) Close() error { return nil } + +func (s *Server) unaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { + resp, err = handler(ctx, req) + if err != nil { + s.logger.Error("Failed to handle RPC request", + zap.Error(err), + zap.String("method", info.FullMethod), + zap.Any("request", req), + ) + } else { + s.logger.Debug("Handling RPC request", + zap.String("method", info.FullMethod), + zap.Any("request", req), + zap.Any("response", resp), + ) + } + + return +} diff --git a/pkg/rpc/server_daemon.go b/pkg/rpc/server_daemon.go index 5c3c468f..aaa5321b 100644 --- a/pkg/rpc/server_daemon.go +++ b/pkg/rpc/server_daemon.go @@ -2,23 +2,31 @@ package rpc import ( "context" + "encoding" + "errors" "fmt" "io" + "net" + "reflect" + "regexp" "strconv" "strings" + "go.uber.org/zap" "go.uber.org/zap/zapcore" + "golang.zx2c4.com/wireguard/wgctrl/wgtypes" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "github.com/stv0g/cunicu/pkg/core" "github.com/stv0g/cunicu/pkg/crypto" + "github.com/stv0g/cunicu/pkg/daemon" + "github.com/stv0g/cunicu/pkg/daemon/feature/epdisc" "github.com/stv0g/cunicu/pkg/log" + "github.com/stv0g/cunicu/pkg/proto" "github.com/stv0g/cunicu/pkg/util" "github.com/stv0g/cunicu/pkg/util/buildinfo" - cunicu "github.com/stv0g/cunicu/pkg" - proto "github.com/stv0g/cunicu/pkg/proto" coreproto "github.com/stv0g/cunicu/pkg/proto/core" rpcproto "github.com/stv0g/cunicu/pkg/proto/rpc" ) @@ -27,10 +35,10 @@ type DaemonServer struct { rpcproto.UnimplementedDaemonServer *Server - *cunicu.Daemon + *daemon.Daemon } -func NewDaemonServer(s *Server, d *cunicu.Daemon) *DaemonServer { +func NewDaemonServer(s *Server, d *daemon.Daemon) *DaemonServer { ds := &DaemonServer{ Server: s, Daemon: d, @@ -102,7 +110,7 @@ func (s *DaemonServer) Restart(ctx context.Context, params *proto.Empty) (*proto func (s *DaemonServer) Sync(ctx context.Context, params *proto.Empty) (*proto.Empty, error) { if err := s.Daemon.Sync(); err != nil { - return &proto.Empty{}, status.Errorf(codes.Unknown, "failed to sync: %s", err) + return nil, status.Errorf(codes.Unknown, "failed to sync: %s", err) } return &proto.Empty{}, nil @@ -119,21 +127,31 @@ func (s *DaemonServer) GetStatus(ctx context.Context, p *rpcproto.GetStatusParam } qis := []*coreproto.Interface{} - s.daemon.ForEachInterface(func(ci *core.Interface) error { - if p.Intf == "" || ci.Name() == p.Intf { - qis = append(qis, ci.MarshalWithPeers(func(cp *core.Peer) *coreproto.Peer { + s.daemon.ForEachInterface(func(i *daemon.Interface) error { + epi := s.epdisc.InterfaceByCore(i.Interface) + + if p.Interface == "" || i.Name() == p.Interface { + qi := i.MarshalWithPeers(func(cp *core.Peer) *coreproto.Peer { if pk.IsSet() && pk != cp.PublicKey() { return nil } qp := cp.Marshal() - if s.epdisc != nil { - qp.Ice = s.epdisc.PeerStatus(cp) + if epi != nil { + if epp, ok := epi.Peers[cp]; ok { + qp.Ice = epp.Marshal() + } } return qp - })) + }) + + if epi != nil { + qi.Ice = epi.Marshal() + } + + qis = append(qis, qi) } return nil @@ -182,12 +200,19 @@ func (s *DaemonServer) SetConfig(ctx context.Context, p *rpcproto.SetConfigParam log.Severity.SetLevel(level) default: - settings[key] = value + if value == "" { // Unset value + settings[key] = nil + } else { + settings[key] = value + } } } - if err := s.Config.Update(settings); err != nil { + changes, err := s.Config.Update(settings) + if err != nil { errs = append(errs, err) + } else if len(changes) == 0 { + errs = append(errs, errors.New("no setting was changed")) } if len(errs) > 0 { @@ -199,6 +224,10 @@ func (s *DaemonServer) SetConfig(ctx context.Context, p *rpcproto.SetConfigParam return nil, status.Error(codes.InvalidArgument, strings.Join(errstrs, ", ")) } + if err := s.Config.SaveRuntime(); err != nil { + return nil, status.Errorf(codes.InvalidArgument, "Failed to save runtime configuration: %s", err) + } + return &proto.Empty{}, nil } @@ -219,7 +248,11 @@ func (s *DaemonServer) GetConfig(ctx context.Context, p *rpcproto.GetConfigParam for key, value := range s.Config.All() { if match(key) { - settings[key] = fmt.Sprintf("%v", value) + if str, err := settingToString(value); err != nil { + return nil, status.Errorf(codes.Internal, "Failed to marshal: %s", err) + } else { + settings[key] = str + } } } @@ -229,9 +262,93 @@ func (s *DaemonServer) GetConfig(ctx context.Context, p *rpcproto.GetConfigParam } func (s *DaemonServer) ReloadConfig(ctx context.Context, params *proto.Empty) (*proto.Empty, error) { - if err := s.Config.Reload(); err != nil { + if _, err := s.Config.Reload(); err != nil { return nil, status.Errorf(codes.InvalidArgument, "failed to reload configuration: %s", err) } return &proto.Empty{}, nil } + +func (s *DaemonServer) AddPeer(ctx context.Context, params *rpcproto.AddPeerParams) (*rpcproto.AddPeerResp, error) { + i := s.InterfaceByName(params.Interface) + if i == nil { + return nil, status.Errorf(codes.NotFound, "Interface %s does not exist", params.Interface) + } + + // Add peer to running daemon + pk, err := crypto.ParseKeyBytes(params.PublicKey) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "Invalid public key") + } + + if err := i.AddPeer(&wgtypes.PeerConfig{ + PublicKey: wgtypes.Key(pk), + }); err != nil { + return nil, status.Errorf(codes.Internal, "Failed to add peer: %s", err) + } + + // TODO: Persist new peer in runtime config + + // Create response + resp := &rpcproto.AddPeerResp{ + Invitation: &rpcproto.Invitation{}, + Interface: i.Marshal(), + } + + if community := crypto.Key(i.Settings.PeerDisc.Community); community.IsSet() { + resp.Invitation.Community = community.Bytes() + } + + // Detect our own endpoint + if f, ok := i.Features["epdisc"]; ok { + epi := f.(*epdisc.Interface) + + if ep, err := epi.Endpoint(); err != nil { + s.logger.Warn("Failed to determine our own endpoint address", zap.Error(err)) + } else if ep != nil { + resp.Invitation.Endpoint = ep.String() + + // Perform reverse lookup of our own endpoint + if names, err := net.LookupAddr(resp.Invitation.Endpoint); err == nil && len(names) >= 1 { + epName := names[0] + + // Do not use auto-generated IPv4 rDNS names + if match, _ := regexp.MatchString(`\d{1,3}-\d{1,3}-\d{1,3}-\d{1,3}`, epName); !match { + resp.Invitation.Endpoint = fmt.Sprintf("%s:%d", epName, ep.Port) + } + } + } + } + + return resp, nil +} + +func settingToString(value any) (string, error) { + v := reflect.ValueOf(value) + switch { + case v.Kind() == reflect.Slice: + s := []string{} + for i := 0; i < v.Len(); i++ { + e := v.Index(i) + in := e.Interface() + + if tm, ok := in.(encoding.TextMarshaler); ok { + if b, err := tm.MarshalText(); err != nil { + return "", err + } else { + s = append(s, string(b)) + } + } else { + s = append(s, fmt.Sprint(in)) + } + } + + return strings.Join(s, ","), nil + + case value == nil: + return "", nil + + default: + return fmt.Sprintf("%v", value), nil + } +} diff --git a/pkg/rpc/server_epdisc.go b/pkg/rpc/server_epdisc.go new file mode 100644 index 00000000..b255c5ed --- /dev/null +++ b/pkg/rpc/server_epdisc.go @@ -0,0 +1,127 @@ +package rpc + +import ( + "context" + "io" + + "go.uber.org/zap" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/stv0g/cunicu/pkg/core" + "github.com/stv0g/cunicu/pkg/crypto" + "github.com/stv0g/cunicu/pkg/daemon" + "github.com/stv0g/cunicu/pkg/daemon/feature/epdisc" + "github.com/stv0g/cunicu/pkg/proto" + + icex "github.com/stv0g/cunicu/pkg/ice" + protoepdisc "github.com/stv0g/cunicu/pkg/proto/feature/epdisc" + rpcproto "github.com/stv0g/cunicu/pkg/proto/rpc" +) + +type EndpointDiscoveryServer struct { + rpcproto.UnimplementedEndpointDiscoverySocketServer + + *Server +} + +func NewEndpointDiscoveryServer(s *Server) *EndpointDiscoveryServer { + eps := &EndpointDiscoveryServer{ + Server: s, + } + + rpcproto.RegisterEndpointDiscoverySocketServer(s.grpc, eps) + + s.daemon.OnInterface(eps) + + return eps +} + +func (s *EndpointDiscoveryServer) InterfaceByCore(ci *core.Interface) *epdisc.Interface { + if i := s.daemon.InterfaceByCore(ci); i != nil { + if f, ok := i.Features["epdisc"]; ok { + if ep, ok := f.(*epdisc.Interface); ok { + return ep + } + } + } + + return nil +} + +func (s *EndpointDiscoveryServer) OnInterfaceAdded(ci *core.Interface) { + if ep := s.InterfaceByCore(ci); ep != nil { + ep.OnConnectionStateChange(s) + } +} + +func (s *EndpointDiscoveryServer) RestartPeer(ctx context.Context, params *rpcproto.RestartPeerParams) (*proto.Empty, error) { + di := s.daemon.InterfaceByName(params.Intf) + if di == nil { + return nil, status.Errorf(codes.NotFound, "unknown interface %s", params.Intf) + } + + i := s.InterfaceByCore(di.Interface) + if i == nil { + return nil, status.Errorf(codes.NotFound, "interface %s has endpoint discovery not enabled", params.Intf) + } + + pk, err := crypto.ParseKeyBytes(params.Peer) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "failed to parse peer public key: %s", err) + } + + p := i.PeerByPublicKey(pk) + if p == nil { + return nil, status.Errorf(codes.NotFound, "unknown peer %s/%s", params.Intf, pk) + } + + if err = p.Restart(); err != nil { + return &proto.Empty{}, status.Errorf(codes.Unknown, "failed to restart peer session: %s", err) + } + + return &proto.Empty{}, nil +} + +func (s *EndpointDiscoveryServer) SendConnectionStates(stream rpcproto.Daemon_StreamEventsServer) { + s.daemon.ForEachInterface(func(di *daemon.Interface) error { + i := s.InterfaceByCore(di.Interface) + + for _, p := range i.Peers { + e := &rpcproto.Event{ + Type: rpcproto.EventType_PEER_CONNECTION_STATE_CHANGED, + Interface: p.Interface.Name(), + Peer: p.Peer.PublicKey().Bytes(), + Event: &rpcproto.Event_PeerConnectionStateChange{ + PeerConnectionStateChange: &rpcproto.PeerConnectionStateChangeEvent{ + NewState: protoepdisc.NewConnectionState(p.ConnectionState()), + }, + }, + } + + if err := stream.Send(e); err == io.EOF { + continue + } else if err != nil { + s.logger.Error("Failed to send", zap.Error(err)) + } + } + + return nil + }) +} + +func (s *EndpointDiscoveryServer) OnConnectionStateChange(p *epdisc.Peer, new, prev icex.ConnectionState) { + s.events.Send(&rpcproto.Event{ + Type: rpcproto.EventType_PEER_CONNECTION_STATE_CHANGED, + + Interface: p.Interface.Name(), + Peer: p.PublicKey().Bytes(), + + Event: &rpcproto.Event_PeerConnectionStateChange{ + PeerConnectionStateChange: &rpcproto.PeerConnectionStateChangeEvent{ + NewState: protoepdisc.NewConnectionState(new), + PrevState: protoepdisc.NewConnectionState(prev), + }, + }, + }) +} diff --git a/pkg/rpc/server_epice.go b/pkg/rpc/server_epice.go deleted file mode 100644 index a9e679e3..00000000 --- a/pkg/rpc/server_epice.go +++ /dev/null @@ -1,117 +0,0 @@ -package rpc - -import ( - "context" - "io" - - "github.com/stv0g/cunicu/pkg/core" - "github.com/stv0g/cunicu/pkg/crypto" - "github.com/stv0g/cunicu/pkg/feat/epdisc" - icex "github.com/stv0g/cunicu/pkg/feat/epdisc/ice" - "github.com/stv0g/cunicu/pkg/proto" - protoepdisc "github.com/stv0g/cunicu/pkg/proto/feat/epdisc" - rpcproto "github.com/stv0g/cunicu/pkg/proto/rpc" - "go.uber.org/zap" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -type EndpointDiscoveryServer struct { - rpcproto.UnimplementedEndpointDiscoverySocketServer - - *Server - *epdisc.EndpointDiscovery -} - -func NewEndpointDiscoveryServer(s *Server, ep *epdisc.EndpointDiscovery) *EndpointDiscoveryServer { - eps := &EndpointDiscoveryServer{ - Server: s, - EndpointDiscovery: ep, - } - - rpcproto.RegisterEndpointDiscoverySocketServer(s.grpc, eps) - - ep.OnConnectionStateChange(eps) - - return eps -} - -func (s *EndpointDiscoveryServer) RestartPeer(ctx context.Context, params *rpcproto.RestartPeerParams) (*proto.Empty, error) { - pk, err := crypto.ParseKeyBytes(params.Peer) - if err != nil { - return &proto.Empty{}, status.Errorf(codes.InvalidArgument, "failed to parse key: %s", err) - } - - p := s.daemon.Peer(params.Intf, &pk) - if p == nil { - return &proto.Empty{}, status.Errorf(codes.NotFound, "unknown peer %s/%s", params.Intf, pk) - } - - ip := s.Peers[p] - if ip == nil { - return &proto.Empty{}, status.Errorf(codes.NotFound, "unknown peer %s/%s", params.Intf, pk) - } - - err = ip.Restart() - if err != nil { - return &proto.Empty{}, status.Errorf(codes.Unknown, "failed to restart peer session: %s", err) - } - - return &proto.Empty{}, nil -} - -func (s *EndpointDiscoveryServer) SendConnectionStates(stream rpcproto.Daemon_StreamEventsServer) { - for _, p := range s.Peers { - e := &rpcproto.Event{ - Type: rpcproto.EventType_PEER_CONNECTION_STATE_CHANGED, - Interface: p.Interface.Name(), - Peer: p.Peer.PublicKey().Bytes(), - Event: &rpcproto.Event_PeerConnectionStateChange{ - PeerConnectionStateChange: &rpcproto.PeerConnectionStateChangeEvent{ - NewState: protoepdisc.NewConnectionState(p.ConnectionState()), - }, - }, - } - - if err := stream.Send(e); err == io.EOF { - continue - } else if err != nil { - s.logger.Error("Failed to send", zap.Error(err)) - } - } -} - -func (s *EndpointDiscoveryServer) OnConnectionStateChange(p *epdisc.Peer, new, prev icex.ConnectionState) { - s.events.Send(&rpcproto.Event{ - Type: rpcproto.EventType_PEER_CONNECTION_STATE_CHANGED, - - Interface: p.Interface.Name(), - Peer: p.PublicKey().Bytes(), - - Event: &rpcproto.Event_PeerConnectionStateChange{ - PeerConnectionStateChange: &rpcproto.PeerConnectionStateChangeEvent{ - NewState: protoepdisc.NewConnectionState(new), - PrevState: protoepdisc.NewConnectionState(prev), - }, - }, - }) -} - -func (s *EndpointDiscoveryServer) InterfaceStatus(ci *core.Interface) *protoepdisc.Interface { - i, ok := s.Interfaces[ci] - if !ok { - return nil - } - - return i.Marshal() -} - -func (s *EndpointDiscoveryServer) PeerStatus(cp *core.Peer) *protoepdisc.Peer { - p, ok := s.Peers[cp] - if !ok { - s.logger.Error("Failed to find peer for", zap.Any("cp", cp.PublicKey())) - return nil - } - - return p.Marshal() -} diff --git a/pkg/signaling/grpc/backend_test.go b/pkg/signaling/grpc/backend_test.go index 2d605e2d..2256ce8f 100644 --- a/pkg/signaling/grpc/backend_test.go +++ b/pkg/signaling/grpc/backend_test.go @@ -31,7 +31,7 @@ var _ = Describe("gRPC backend", func() { Expect(err).To(Succeed(), "Failed to listen: %s", err) // Start local dummy gRPC server - svr = grpc.NewSignalingServer(nil) + svr = grpc.NewSignalingServer() go svr.Serve(l) u = url.URL{ diff --git a/pkg/signaling/grpc/server_relay_test.go b/pkg/signaling/grpc/server_relay_test.go index 6cb88065..a31ab3d2 100644 --- a/pkg/signaling/grpc/server_relay_test.go +++ b/pkg/signaling/grpc/server_relay_test.go @@ -1,6 +1,8 @@ package grpc_test import ( + "time" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/stv0g/cunicu/pkg/signaling/grpc" @@ -15,15 +17,22 @@ var _ = Context("relay server", func() { }, Entry("simple", "stun:stun.cunicu.li", grpc.RelayInfo{ URL: "stun:stun.cunicu.li:3478", + TTL: grpc.DefaultRelayTTL, }), Entry("turn with secret", "turn:turn.cunicu.li?secret=mysecret", grpc.RelayInfo{ URL: "turn:turn.cunicu.li:3478?transport=udp", Secret: "mysecret", + TTL: grpc.DefaultRelayTTL, }), Entry("turn with user + pass", "turn:user1:pass1@turn.cunicu.li", grpc.RelayInfo{ URL: "turn:turn.cunicu.li:3478?transport=udp", Username: "user1", Password: "pass1", + TTL: grpc.DefaultRelayTTL, + }), + Entry("turn with user + pass", "turn:turn.cunicu.li?ttl=2h", grpc.RelayInfo{ + URL: "turn:turn.cunicu.li:3478?transport=udp", + TTL: 2 * time.Hour, }), ) }) diff --git a/pkg/signaling/subscriptions.go b/pkg/signaling/subscriptions.go index fc327c8d..af1cba98 100644 --- a/pkg/signaling/subscriptions.go +++ b/pkg/signaling/subscriptions.go @@ -163,7 +163,7 @@ func (s *Subscription) RemoveOnMessages(pk *crypto.Key, h MessageHandler) { s.mu.Lock() defer s.mu.Unlock() - s.onMessages[*pk] = util.FilterSlice(s.onMessages[*pk], func(j MessageHandler) bool { + s.onMessages[*pk] = util.SliceFilter(s.onMessages[*pk], func(j MessageHandler) bool { return h != j }) } diff --git a/pkg/watcher/register.go b/pkg/watcher/register.go index 58fbbb50..8fe0f9f0 100644 --- a/pkg/watcher/register.go +++ b/pkg/watcher/register.go @@ -42,17 +42,7 @@ func (h *peerHandler) OnInterfaceAdded(i *core.Interface) { i.OnPeer(h) } -func (h *peerHandler) OnInterfaceRemoved(i *core.Interface) { -} - -func (h *peerHandler) OnInterfaceModified(i *core.Interface, old *wg.Device, m core.InterfaceModifier) { -} - -func (h *peerHandler) OnPeerAdded(p *core.Peer) { - p.OnModified(h) - - h.PeerHandler.OnPeerAdded(p) -} +func (h *peerHandler) OnInterfaceRemoved(i *core.Interface) {} // OnAll adds a new handler to all the events observed by the watcher. func (w *Watcher) OnAll(h core.AllHandler) { diff --git a/pkg/watcher/watcher.go b/pkg/watcher/watcher.go index fbc183b0..aeeb8119 100644 --- a/pkg/watcher/watcher.go +++ b/pkg/watcher/watcher.go @@ -9,6 +9,7 @@ import ( "github.com/stv0g/cunicu/pkg/core" "github.com/stv0g/cunicu/pkg/crypto" + "github.com/stv0g/cunicu/pkg/log" "github.com/stv0g/cunicu/pkg/util" "go.uber.org/zap" "golang.zx2c4.com/wireguard/wgctrl" @@ -111,20 +112,22 @@ func (w *Watcher) Watch() { defer ticker.Stop() } + logger := w.logger.WithOptions(log.WithVerbose(10)) + out: for { select { // We still a need periodic sync we can not (yet) monitor WireGuard interfaces // for changes via a netlink socket (patch is pending) case <-ticker.C: - w.logger.Debug("Started periodic interface synchronization") + logger.Debug("Started periodic interface synchronization") if err := w.Sync(); err != nil { w.logger.Error("Synchronization failed", zap.Error(err)) } - w.logger.Debug("Completed periodic interface synchronization") + logger.Debug("Completed periodic interface synchronization") case event := <-w.events: - w.logger.Debug("Received interface event", zap.Any("event", event)) + logger.Debug("Received interface event", zap.Any("event", event)) if err := w.Sync(); err != nil { w.logger.Error("Synchronization failed", zap.Error(err)) } @@ -151,12 +154,12 @@ func (w *Watcher) Sync() error { } // Ignore devices which do not match the filter - new = util.FilterSlice(new, func(d *wgtypes.Device) bool { + new = util.SliceFilter(new, func(d *wgtypes.Device) bool { return w.filter == nil || w.filter(d.Name) }) - added, removed, kept := util.DiffSliceFunc(old, new, func(a, b **wgtypes.Device) int { - return strings.Compare((*a).Name, (*b).Name) + added, removed, kept := util.SliceDiffFunc(old, new, func(a, b *wgtypes.Device) int { + return strings.Compare(a.Name, b.Name) }) w.mu.Unlock() diff --git a/pkg/wg/device.go b/pkg/wg/device.go index 2bb8121f..ebdbbf97 100644 --- a/pkg/wg/device.go +++ b/pkg/wg/device.go @@ -38,7 +38,7 @@ func (d *Device) DumpEnv(wr io.Writer) error { case "auto": fallthrough default: - color = util.IsATTY(os.Stdout) + color = t.IsATTY(os.Stdout) } if !color { @@ -60,7 +60,7 @@ func (d *Device) DumpEnv(wr io.Writer) error { func (d *Device) Dump(wr io.Writer, hideKeys bool) error { wri := t.NewIndenter(wr, " ") - fmt.Fprintf(wr, t.Color("interface", t.Bold, t.FgGreen)+": "+t.Color("%s", t.FgGreen)+"\n", d.Name) + fmt.Fprintf(wr, t.Mods("interface", t.Bold, t.FgGreen)+": "+t.Mods("%s", t.FgGreen)+"\n", d.Name) if crypto.Key(d.PrivateKey).IsSet() { t.FprintKV(wri, "public key", d.PublicKey) @@ -84,7 +84,7 @@ func (d *Device) Dump(wr io.Writer, hideKeys bool) error { }) for _, p := range d.Peers { - fmt.Fprintf(wr, "\n"+t.Color("peer", t.Bold, t.FgYellow)+": "+t.Color("%s", t.FgYellow)+"\n", p.PublicKey) + fmt.Fprintf(wr, "\n"+t.Mods("peer", t.Bold, t.FgYellow)+": "+t.Mods("%s", t.FgYellow)+"\n", p.PublicKey) if crypto.Key(p.PresharedKey).IsSet() { if hideKeys { diff --git a/pkg/wg/device_config.go b/pkg/wg/device_config.go index 7916b0ea..91d28d86 100644 --- a/pkg/wg/device_config.go +++ b/pkg/wg/device_config.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "net" + "strings" "time" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" @@ -13,7 +14,8 @@ import ( type Config struct { wgtypes.Config - PeerEndpoints []*string + PeerEndpoints []string + PeerNames []string Address []net.IPNet DNS []net.IPAddr @@ -126,7 +128,7 @@ func (cfg *Config) Dump(wr io.Writer) error { } } - for _, peer := range cfg.Peers { + for i, peer := range cfg.Peers { iniPeer := peerConfig{ PublicKey: peer.PublicKey.String(), } @@ -136,7 +138,9 @@ func (cfg *Config) Dump(wr io.Writer) error { iniPeer.PresharedKey = &psk } - if peer.Endpoint != nil { + if cfg.PeerEndpoints[i] != "" { + iniPeer.Endpoint = &cfg.PeerEndpoints[i] + } else if peer.Endpoint != nil { ep := peer.Endpoint.String() iniPeer.Endpoint = &ep } @@ -197,7 +201,24 @@ func ParseConfig(data []byte) (*Config, error) { iniCfg.Peers = nil } - return iniCfg.Config() + peerSects, err := iniFile.SectionsByName("Peer") + if err != nil { + return nil, err + } + + cfg, err := iniCfg.Config() + if err != nil { + return nil, err + } + + for _, peerSect := range peerSects { + peerName := strings.TrimPrefix(peerSect.Comment, "#") + peerName = strings.TrimSpace(peerName) + + cfg.PeerNames = append(cfg.PeerNames, peerName) + } + + return cfg, nil } func (c *config) Config() (*Config, error) { @@ -247,7 +268,12 @@ func (c *config) Config() (*Config, error) { } cfg.Peers = append(cfg.Peers, *peerCfg) - cfg.PeerEndpoints = append(cfg.PeerEndpoints, pSection.Endpoint) + + if pSection.Endpoint != nil { + cfg.PeerEndpoints = append(cfg.PeerEndpoints, *pSection.Endpoint) + } else { + cfg.PeerEndpoints = append(cfg.PeerEndpoints, "") + } } return cfg, nil diff --git a/pkg/wg/wg.go b/pkg/wg/wg.go index 1a89d0b7..3c8d4a2a 100644 --- a/pkg/wg/wg.go +++ b/pkg/wg/wg.go @@ -7,4 +7,6 @@ const ( DefaultPort = 51820 TunnelOverhead = 80 // Byte + DefaultMTU = 1500 - TunnelOverhead + MinimalMTU = 1280 // Byte for minimal IPv6 MTU ) diff --git a/proto/core/interface.proto b/proto/core/interface.proto index 54111428..e3b1c8d1 100644 --- a/proto/core/interface.proto +++ b/proto/core/interface.proto @@ -5,7 +5,7 @@ option go_package = "github.com/stv0g/cunicu/pkg/proto/core"; import "common.proto"; import "core/peer.proto"; -import "feat/epdisc.proto"; +import "feature/epdisc.proto"; // Type of the WireGuard interface impelementation enum InterfaceType { diff --git a/proto/core/peer.proto b/proto/core/peer.proto index 43d0128d..c8f2d583 100644 --- a/proto/core/peer.proto +++ b/proto/core/peer.proto @@ -4,7 +4,7 @@ package cunicu.core; option go_package = "github.com/stv0g/cunicu/pkg/proto/core"; import "common.proto"; -import "feat/epdisc.proto"; +import "feature/epdisc.proto"; message Peer { // Public WireGuard X25519 key diff --git a/proto/feat/epdisc.proto b/proto/feature/epdisc.proto similarity index 95% rename from proto/feat/epdisc.proto rename to proto/feature/epdisc.proto index 900d06a4..c8400ca1 100644 --- a/proto/feat/epdisc.proto +++ b/proto/feature/epdisc.proto @@ -1,10 +1,10 @@ syntax = "proto3"; package cunicu.epdisc; -option go_package = "github.com/stv0g/cunicu/pkg/proto/feat/epdisc"; +option go_package = "github.com/stv0g/cunicu/pkg/proto/feature/epdisc"; import "common.proto"; -import "feat/epdisc_candidate.proto"; +import "feature/epdisc_candidate.proto"; enum ConnectionState { // ICE Connection state from pion/ice/ice.go diff --git a/proto/feat/epdisc_candidate.proto b/proto/feature/epdisc_candidate.proto similarity index 99% rename from proto/feat/epdisc_candidate.proto rename to proto/feature/epdisc_candidate.proto index e390ee5e..da4fa4df 100644 --- a/proto/feat/epdisc_candidate.proto +++ b/proto/feature/epdisc_candidate.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package cunicu.epdisc; -option go_package = "github.com/stv0g/cunicu/pkg/proto/feat/epdisc"; +option go_package = "github.com/stv0g/cunicu/pkg/proto/feature/epdisc"; import "common.proto"; diff --git a/proto/feat/hooks.proto b/proto/feature/hooks.proto similarity index 79% rename from proto/feat/hooks.proto rename to proto/feature/hooks.proto index cd5bcb0b..1b66e609 100644 --- a/proto/feat/hooks.proto +++ b/proto/feature/hooks.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package cunicu.hooks; -option go_package = "github.com/stv0g/cunicu/pkg/proto/feat/hooks"; +option go_package = "github.com/stv0g/cunicu/pkg/proto/feature/hooks"; import "core/interface.proto"; import "core/peer.proto"; diff --git a/proto/feat/pdisc.proto b/proto/feature/pdisc.proto similarity index 90% rename from proto/feat/pdisc.proto rename to proto/feature/pdisc.proto index ebe95aef..10ceb221 100644 --- a/proto/feat/pdisc.proto +++ b/proto/feature/pdisc.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package cunicu.pdisc; -option go_package = "github.com/stv0g/cunicu/pkg/proto/feat/pdisc"; +option go_package = "github.com/stv0g/cunicu/pkg/proto/feature/pdisc"; import "common.proto"; diff --git a/proto/feat/pske.proto b/proto/feature/pske.proto similarity index 65% rename from proto/feat/pske.proto rename to proto/feature/pske.proto index 098b06d1..7b322e77 100644 --- a/proto/feat/pske.proto +++ b/proto/feature/pske.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package cunicu.pske; -option go_package = "github.com/stv0g/cunicu/pkg/proto/feat/pske"; +option go_package = "github.com/stv0g/cunicu/pkg/proto/feature/pske"; message PresharedKeyEstablishment { bytes public_key = 1; diff --git a/proto/rpc/daemon.proto b/proto/rpc/daemon.proto index 5bcae11c..a0d15903 100644 --- a/proto/rpc/daemon.proto +++ b/proto/rpc/daemon.proto @@ -6,6 +6,7 @@ option go_package = "github.com/stv0g/cunicu/pkg/proto/rpc"; import "core/interface.proto"; import "common.proto"; import "rpc/event.proto"; +import "rpc/invitation.proto"; message GetStatusParams { string interface = 1; @@ -28,6 +29,17 @@ message GetConfigResp { map settings = 1; } +message AddPeerParams { + string interface = 1; + bytes public_key = 2; + string name = 3; +} + +message AddPeerResp { + Invitation invitation = 1; + core.Interface interface = 2; +} + service Daemon { rpc GetBuildInfo(Empty) returns (BuildInfo) {} rpc StreamEvents(Empty) returns (stream Event) {} @@ -40,4 +52,6 @@ service Daemon { rpc SetConfig(SetConfigParams) returns (Empty) {} rpc GetConfig(GetConfigParams) returns (GetConfigResp) {} rpc ReloadConfig(Empty) returns (Empty) {} + + rpc AddPeer(AddPeerParams) returns (AddPeerResp) {} } \ No newline at end of file diff --git a/proto/rpc/event.proto b/proto/rpc/event.proto index 66756437..b06f426d 100644 --- a/proto/rpc/event.proto +++ b/proto/rpc/event.proto @@ -5,7 +5,7 @@ option go_package = "github.com/stv0g/cunicu/pkg/proto/rpc"; import "common.proto"; import "signaling/signaling.proto"; -import "feat/epdisc.proto"; +import "feature/epdisc.proto"; enum EventType { UNKNOWN = 0; diff --git a/proto/rpc/invitation.proto b/proto/rpc/invitation.proto new file mode 100644 index 00000000..0ef3b45a --- /dev/null +++ b/proto/rpc/invitation.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package cunicu.rpc; +option go_package = "github.com/stv0g/cunicu/pkg/proto/rpc"; + +import "common.proto"; + +message Invitation { + bytes community = 1; + string endpoint = 2; +} \ No newline at end of file diff --git a/proto/signaling/signaling.proto b/proto/signaling/signaling.proto index 0bb55068..ade86622 100644 --- a/proto/signaling/signaling.proto +++ b/proto/signaling/signaling.proto @@ -4,10 +4,10 @@ package cunicu.signaling; option go_package = "github.com/stv0g/cunicu/pkg/proto/signaling"; import "common.proto"; -import "feat/pdisc.proto"; -import "feat/pske.proto"; -import "feat/epdisc.proto"; -import "feat/epdisc_candidate.proto"; +import "feature/pdisc.proto"; +import "feature/pske.proto"; +import "feature/epdisc.proto"; +import "feature/epdisc_candidate.proto"; enum BackendType { MULTI = 0;