implement wicectl client to control the daemon via gRPC

Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
Steffen Vogel
2022-01-06 15:10:27 +01:00
parent 8d0f18e910
commit 18e45d0a56
35 changed files with 3096 additions and 1181 deletions

View File

@@ -1,51 +1,43 @@
package main package main
import ( import (
"flag" "fmt"
"os"
"github.com/spf13/cobra"
"go.uber.org/zap" "go.uber.org/zap"
"riasc.eu/wice/internal" "riasc.eu/wice/internal"
"riasc.eu/wice/pkg/socket" "riasc.eu/wice/pkg/socket"
) )
var sockPath = flag.String("socket", "/var/run/wice.go", "Unix control and monitoring socket") var client *socket.Client = nil
var logger *zap.Logger
func pre(cmd *cobra.Command, args []string) error {
var err error
internal.SetupRand()
logger = internal.SetupLogging()
if client, err = socket.Connect(sockPath); err != nil {
return fmt.Errorf("failed to connect to control socket: %w", err)
}
return nil
}
func post(cmd *cobra.Command, args []string) error {
if err := client.Close(); err != nil {
return err
}
if err := logger.Sync(); err != nil {
return err
}
return nil
}
func main() { func main() {
internal.SetupRand() rootCmd.Execute()
signals := internal.SetupSignals()
logger := internal.SetupLogging()
defer logger.Sync()
flag.Parse()
subCommand := flag.Arg(0)
switch subCommand {
case "monitor":
monitor(signals)
default:
logger.Fatal("Unknown subcommand", zap.String("command", subCommand))
}
}
func monitor(signals chan os.Signal) {
logger := zap.L().Named("events")
sock, err := socket.Connect(*sockPath)
if err != nil {
logger.Fatal("Failed to connect to control socket", zap.Error(err))
}
for {
select {
case sig := <-signals:
logger.Info("Received signal", zap.Any("signal", sig))
os.Exit(0)
case evt := <-sock.Events:
evt.Log(logger, "Event")
}
}
} }

35
cmd/wicectl/monitor.go Normal file
View File

@@ -0,0 +1,35 @@
package main
import (
"github.com/spf13/cobra"
"go.uber.org/zap"
"riasc.eu/wice/internal"
)
var monitorCmd = &cobra.Command{
Use: "monitor",
Short: "Monitor the WICE daemon for events",
RunE: monitor,
PersistentPreRunE: pre,
PersistentPostRunE: post,
}
func monitor(cmd *cobra.Command, args []string) error {
signals := internal.SetupSignals()
logger := zap.L().Named("events")
out:
for {
select {
case sig := <-signals:
logger.Info("Received signal", zap.Any("signal", sig))
break out
case evt := <-client.Events:
evt.Log(logger, "Event")
}
}
return nil
}

66
cmd/wicectl/root.go Normal file
View File

@@ -0,0 +1,66 @@
package main
import (
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.uber.org/zap"
"riasc.eu/wice/internal"
"riasc.eu/wice/internal/cli"
)
var (
// Used for flags.
cfgFile string
sockPath string
rootCmd = &cobra.Command{
Use: "wicectl",
Short: "A client tool to control the WICE daemon",
}
)
func init() {
cobra.OnInitialize(
internal.SetupRand,
setupLogging,
setupConfig,
)
pf := rootCmd.PersistentFlags()
pf.StringVar(&sockPath, "socket", "/var/run/wice.sock", "Unix control and monitoring socket")
pf.StringVar(&cfgFile, "config", "", "Path to config file (default $HOME/.wice.yaml)")
viper.BindPFlag("socket", pf.Lookup("socket"))
rootCmd.AddCommand(shutdownCmd)
rootCmd.AddCommand(monitorCmd)
rootCmd.AddCommand(syncCmd)
rootCmd.AddCommand(cli.NewDocsCommand(rootCmd))
}
func setupLogging() {
logger = internal.SetupLogging()
}
func setupConfig() {
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
} else {
home, err := os.UserHomeDir()
cobra.CheckErr(err)
viper.AddConfigPath(home)
viper.SetConfigType("yaml")
viper.SetConfigName(".wice.yaml")
}
viper.AutomaticEnv()
if err := viper.ReadInConfig(); err == nil {
logger.Debug("Using config file", zap.String("file", viper.ConfigFileUsed()))
}
}

28
cmd/wicectl/shutdown.go Normal file
View File

@@ -0,0 +1,28 @@
package main
import (
"context"
"fmt"
"github.com/spf13/cobra"
"riasc.eu/wice/pkg/pb"
)
var shutdownCmd = &cobra.Command{
Use: "shutdown",
Short: "Shutdown the WICE daemon",
RunE: shutdown,
PersistentPreRunE: pre,
PersistentPostRunE: post,
}
func shutdown(cmd *cobra.Command, args []string) error {
rerr, err := client.Shutdown(context.Background(), &pb.ShutdownParams{})
if err != nil {
return fmt.Errorf("failed RPC request: %w", err)
} else if !rerr.Ok() {
return fmt.Errorf("received RPC error: %w", rerr)
}
return nil
}

54
cmd/wicectl/sync.go Normal file
View File

@@ -0,0 +1,54 @@
package main
import (
"context"
"fmt"
"github.com/spf13/cobra"
"riasc.eu/wice/pkg/pb"
)
var (
syncCmd = &cobra.Command{
Use: "sync",
PersistentPreRunE: pre,
PersistentPostRunE: post,
}
syncConfigCmd = &cobra.Command{
Use: "config",
RunE: syncConfig,
}
syncInterfacesCmd = &cobra.Command{
Use: "interfaces",
RunE: syncInterfaces,
}
)
func init() {
syncCmd.AddCommand(syncConfigCmd)
syncCmd.AddCommand(syncInterfacesCmd)
}
func syncConfig(cmd *cobra.Command, args []string) error {
rerr, err := client.SyncConfig(context.Background(), &pb.SyncConfigParams{})
if err != nil {
return fmt.Errorf("failed RPC request: %w", err)
} else if !rerr.Ok() {
return fmt.Errorf("received RPC error: %w", rerr)
}
return nil
}
func syncInterfaces(cmd *cobra.Command, args []string) error {
rerr, err := client.SyncInterfaces(context.Background(), &pb.SyncInterfaceParams{})
if err != nil {
return fmt.Errorf("failed RPC request: %w", err)
} else if !rerr.Ok() {
return fmt.Errorf("received RPC error: %w", rerr)
}
return nil
}

87
internal/cli/docs.go Normal file
View File

@@ -0,0 +1,87 @@
package cli
import (
"fmt"
"log"
"os"
"path/filepath"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
type runEfunc func(cmd *cobra.Command, args []string) error
var (
outputDir string = "./"
)
func NewDocsCommand(rootCmd *cobra.Command) *cobra.Command {
cmd := &cobra.Command{
Use: "docs",
Short: "Generate documentation for the wice commands",
// Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
if err := docsMarkdown(rootCmd); err != nil {
return err
}
if err := docsManpage(rootCmd); err != nil {
return err
}
return nil
},
}
cmd.AddCommand(&cobra.Command{
Use: "markdown",
Short: "Generate markdown docs",
RunE: func(cmd *cobra.Command, args []string) error {
return docsMarkdown(rootCmd)
},
})
cmd.AddCommand(&cobra.Command{
Use: "man",
Short: "Generate manpages",
RunE: func(cmd *cobra.Command, args []string) error {
return docsManpage(rootCmd)
},
})
pf := cmd.PersistentFlags()
pf.StringVar(&outputDir, "output-dir", "./docs", "Output directory of generated documenation")
return cmd
}
func docsMarkdown(rootCmd *cobra.Command) error {
dir := filepath.Join(outputDir, "md")
if err := os.MkdirAll(dir, 0755); err != nil {
return fmt.Errorf("failed to create directory: %w", err)
}
if err := doc.GenMarkdownTree(rootCmd, dir); err != nil {
log.Fatal(err)
}
return nil
}
func docsManpage(rootCmd *cobra.Command) error {
dir := filepath.Join(outputDir, "man")
if err := os.MkdirAll(dir, 0755); err != nil {
return fmt.Errorf("failed to create directory: %w", err)
}
header := &doc.GenManHeader{
Title: "MINE",
Section: "3",
}
if err := doc.GenManTree(rootCmd, header, dir); err != nil {
log.Fatal(err)
}
return nil
}

308
internal/config/config.go Normal file
View File

@@ -0,0 +1,308 @@
package config
import (
"flag"
"fmt"
"io"
"net/url"
"os"
"path/filepath"
"regexp"
"strconv"
"time"
"go.uber.org/zap"
"riasc.eu/wice/pkg/proxy"
"riasc.eu/wice/pkg/signaling"
"github.com/pion/ice/v2"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)
// Copied from pion/ice/agent_config.go
const (
// defaultCheckInterval is the interval at which the agent performs candidate checks in the connecting phase
defaultCheckInterval = 200 * time.Millisecond
// keepaliveInterval used to keep candidates alive
defaultKeepaliveInterval = 2 * time.Second
// defaultDisconnectedTimeout is the default time till an Agent transitions disconnected
defaultDisconnectedTimeout = 5 * time.Second
// defaultFailedTimeout is the default time till an Agent transitions to failed after disconnected
defaultFailedTimeout = 25 * time.Second
// max binding request before considering a pair failed
defaultMaxBindingRequests = 7
)
var (
defaultICEUrls = []*ice.URL{
{
Scheme: ice.SchemeTypeSTUN,
Host: "stun.l.google.com",
Port: 19302,
Username: "",
Password: "",
Proto: ice.ProtoTypeUDP,
},
}
defaultBackendURLs = []*url.URL{
{
Scheme: "p2p",
},
}
)
type Config struct {
File string
LogLevel logLevel
Socket string
SocketWait bool
Backends backendURLList
User bool
ProxyType proxyType
ConfigSync bool
ConfigPath string
WatchInterval time.Duration
RestartInterval time.Duration
Interfaces []string
InterfaceFilter regex
InterfaceFilterICE regex
// for ice.AgentConfig
iceURLs iceURLList
iceNat1to1IPs arrayFlags
iceInsecureSkipVerify bool
iceCandidateTypes candidateTypeList
iceNetworkTypes networkTypeList
iceDisconnectedTimeout time.Duration
iceFailedTimeout time.Duration
iceKeepaliveInterval time.Duration
iceCheckInterval time.Duration
iceUsername string
icePassword string
icePortMin uint16
icePortMax uint16
iceMdns bool
iceLite bool
iceMaxBindingRequests uint16
viper *viper.Viper
logger *zap.Logger
}
func ShowUsage() {
fmt.Fprintf(os.Stderr, "usage: %s [OPTIONS] [IFACES ...]\n", os.Args[0])
fmt.Println()
fmt.Println(" IFACES is a list of Wireguard interfaces")
fmt.Println(" (defaults to all available Wireguard interfaces)")
fmt.Println("")
fmt.Println(("Available OPTIONS are:"))
flag.PrintDefaults()
fmt.Println()
fmt.Println(" (**) These options can be specified multiple times")
fmt.Println()
fmt.Println("Available backends types are:")
for name, plugin := range signaling.Backends {
fmt.Printf(" %-7s %s\n", name, plugin.Description)
}
}
func NewConfig(flags *pflag.FlagSet) *Config {
matchAll, _ := regexp.Compile(".*")
// Default arguments
cfg := &Config{
Backends: backendURLList{},
iceCandidateTypes: candidateTypeList{},
InterfaceFilterICE: regex{matchAll},
iceNat1to1IPs: arrayFlags{},
iceNetworkTypes: networkTypeList{},
iceURLs: iceURLList{},
InterfaceFilter: regex{matchAll},
Interfaces: []string{},
LogLevel: logLevel{zap.NewAtomicLevel()},
ProxyType: proxyType{proxy.TypeAuto},
viper: viper.New(),
logger: zap.L().Named("config"),
}
flags.StringVarP(&cfg.File, "config", "c", "", "Path of configuration file")
flags.VarP(&cfg.LogLevel, "log-level", "d", "log level (one of \"panic\", \"fatal\", \"error\", \"warn\", \"info\", \"debug\", \"trace\")")
flags.VarP(&cfg.Backends, "backend", "b", "backend types / URLs")
flags.VarP(&cfg.ProxyType, "proxy", "p", "proxy type to use")
flags.VarP(&cfg.InterfaceFilter, "interface-filter", "f", "regex for filtering Wireguard interfaces (e.g. \"wg-.*\")")
flags.DurationVarP(&cfg.WatchInterval, "watch-interval", "i", time.Second, "interval at which we are polling the kernel for updates on the Wireguard interfaces")
flags.BoolVarP(&cfg.User, "wg-user", "u", false, "start userspace Wireguard daemon")
flags.BoolVarP(&cfg.ConfigSync, "wg-config-sync", "s", false, "sync Wireguard interface with configuration file (see \"wg synconf\"")
flags.StringVarP(&cfg.ConfigPath, "wg-config-path", "w", "/etc/wireguard", "base path to search for Wireguard configuration files")
// ice.AgentConfig fields
flags.VarP(&cfg.iceURLs, "url", "a", "STUN and/or TURN server address (**)")
flags.Var(&cfg.iceCandidateTypes, "ice-candidate-type", "usable candidate types (**, one of \"host\", \"srflx\", \"prflx\", \"relay\")")
flags.Var(&cfg.iceNetworkTypes, "ice-network-type", "usable network types (**, select from \"udp4\", \"udp6\", \"tcp4\", \"tcp6\")")
flags.Var(&cfg.iceNat1to1IPs, "ice-nat-1to1-ip", "list of IP addresses which will be added as local server reflexive candidates (**)")
flags.Uint16Var(&cfg.icePortMin, "ice-port-min", 0, "minimum port for allocation policy (range: 0-65535)")
flags.Uint16Var(&cfg.icePortMax, "ice-port-max", 0, "maximum port for allocation policy (range: 0-65535)")
flags.BoolVarP(&cfg.iceLite, "ice-lite", "l", false, "lite agents do not perform connectivity check and only provide host candidates")
flags.BoolVarP(&cfg.iceMdns, "ice-mdns", "m", false, "enable local Multicast DNS discovery")
flags.Uint16Var(&cfg.iceMaxBindingRequests, "ice-max-binding-requests", defaultMaxBindingRequests, "maximum number of binding request before considering a pair failed")
flags.BoolVarP(&cfg.iceInsecureSkipVerify, "ice-insecure-skip-verify", "k", false, "skip verification of TLS certificates for secure STUN/TURN servers")
flags.Var(&cfg.InterfaceFilterICE, "ice-interface-filter", "regex for filtering local interfaces for ICE candidate gathering (e.g. \"eth[0-9]+\")")
flags.DurationVar(&cfg.iceDisconnectedTimeout, "ice-disconnected-timout", defaultDisconnectedTimeout, "time till an Agent transitions disconnected")
flags.DurationVar(&cfg.iceFailedTimeout, "ice-failed-timeout", defaultFailedTimeout, "time until an Agent transitions to failed after disconnected")
flags.DurationVar(&cfg.iceKeepaliveInterval, "ice-keepalive-interval", defaultKeepaliveInterval, "interval netween STUN keepalives")
flags.DurationVar(&cfg.iceCheckInterval, "ice-check-interval", defaultCheckInterval, "interval at which the agent performs candidate checks in the connecting phase")
flags.DurationVar(&cfg.RestartInterval, "ice-restart-interval", defaultDisconnectedTimeout, "time to wait before ICE restart")
flags.StringVarP(&cfg.iceUsername, "ice-user", "U", "", "username for STUN/TURN credentials")
flags.StringVarP(&cfg.icePassword, "ice-pass", "P", "", "password for STUN/TURN credentials")
// iceMaxBindingRequestTimeout := flag.Duration("ice-max-binding-request-timeout", maxBindingRequestTimeout, "wait time before binding requests can be deleted")
flags.StringVar(&cfg.Socket, "socket", "/var/run/wice.sock", "Unix control and monitoring socket")
flags.BoolVar(&cfg.SocketWait, "socket-wait", false, "wait until first client connected to control socket before continuing start")
cfg.viper.BindPFlags(flags)
return cfg
}
func (c *Config) Setup() {
// Find best proxy method
if c.ProxyType.ProxyType == proxy.TypeAuto {
c.ProxyType.ProxyType = proxy.AutoProxy()
}
// Add default backend
if len(c.Backends) == 0 {
c.Backends = defaultBackendURLs
}
if c.File != "" {
// Use config file from the flag.
viper.SetConfigFile(c.File)
} else {
home, err := os.UserHomeDir()
if err != nil {
c.logger.Warn("Failed to determine home directory", zap.Error(err))
} else {
viper.AddConfigPath(filepath.Join(home, ".config", "wice"))
}
viper.AddConfigPath("/etc/wice")
viper.SetConfigType("ini")
viper.SetConfigName("wicerc")
}
c.viper.AutomaticEnv()
if err := viper.ReadInConfig(); err == nil {
c.logger.Debug("Using config file", zap.String("file", viper.ConfigFileUsed()))
}
}
func (a *Config) AgentConfig() (*ice.AgentConfig, error) {
cfg := &ice.AgentConfig{
InsecureSkipVerify: a.iceInsecureSkipVerify,
NetworkTypes: a.iceNetworkTypes,
CandidateTypes: a.iceCandidateTypes,
Urls: a.iceURLs,
}
// Add default STUN/TURN servers
if len(cfg.Urls) == 0 {
cfg.Urls = defaultICEUrls
} else {
// Set ICE credentials
for _, u := range cfg.Urls {
if a.iceUsername != "" {
u.Username = a.iceUsername
}
if a.icePassword != "" {
u.Password = a.icePassword
}
}
}
if a.iceMaxBindingRequests > 0 {
cfg.MaxBindingRequests = &a.iceMaxBindingRequests
}
if a.iceMdns {
cfg.MulticastDNSMode = ice.MulticastDNSModeQueryAndGather
}
if a.iceDisconnectedTimeout > 0 {
cfg.DisconnectedTimeout = &a.iceDisconnectedTimeout
}
if a.iceFailedTimeout > 0 {
cfg.FailedTimeout = &a.iceFailedTimeout
}
if a.iceKeepaliveInterval > 0 {
cfg.KeepaliveInterval = &a.iceKeepaliveInterval
}
if a.iceCheckInterval > 0 {
cfg.CheckInterval = &a.iceCheckInterval
}
if len(a.iceNat1to1IPs) > 0 {
cfg.NAT1To1IPCandidateType = ice.CandidateTypeServerReflexive
cfg.NAT1To1IPs = a.iceNat1to1IPs
}
// Default network types
if len(a.iceNetworkTypes) == 0 {
cfg.NetworkTypes = append(cfg.NetworkTypes,
ice.NetworkTypeUDP4,
ice.NetworkTypeUDP6,
)
}
return cfg, nil
}
func (c *Config) Dump(wr io.Writer) {
cfg, _ := c.AgentConfig()
fmt.Fprintln(wr, "Options:")
fmt.Fprintln(wr, " URLs:")
for _, u := range cfg.Urls {
fmt.Fprintf(wr, " %s\n", u.String())
}
fmt.Fprintln(wr, " Interfaces:")
for _, d := range c.Interfaces {
fmt.Fprintf(wr, " %s\n", d)
}
fmt.Fprintf(wr, " User: %s\n", strconv.FormatBool(c.User))
fmt.Fprintf(wr, " ProxyType: %s\n", c.ProxyType.String())
fmt.Fprintf(wr, " Signalling Backends:\n")
for _, b := range c.Backends {
fmt.Fprintf(wr, " %s\n", b)
}
}

View File

@@ -1,14 +1,14 @@
package args_test package config_test
import ( import (
"testing" "testing"
"github.com/pion/ice/v2" "github.com/pion/ice/v2"
"riasc.eu/wice/pkg/args" "riasc.eu/wice/internal/config"
) )
func TestParseArgsUser(t *testing.T) { func TestParseArgsUser(t *testing.T) {
config, err := args.Parse("prog", []string{"-user"}) config, err := config.Parse("prog", []string{"-user"})
if err != nil { if err != nil {
t.Errorf("err got %v, want nil", err) t.Errorf("err got %v, want nil", err)
} }
@@ -19,7 +19,7 @@ func TestParseArgsUser(t *testing.T) {
} }
func TestParseArgsBackend(t *testing.T) { func TestParseArgsBackend(t *testing.T) {
config, err := args.Parse("prog", []string{"-backend", "k8s"}) config, err := config.Parse("prog", []string{"-backend", "k8s"})
if err != nil { if err != nil {
t.Errorf("err got %v, want nil", err) t.Errorf("err got %v, want nil", err)
} }
@@ -30,7 +30,7 @@ func TestParseArgsBackend(t *testing.T) {
} }
func TestParseArgsUrls(t *testing.T) { func TestParseArgsUrls(t *testing.T) {
config, err := args.Parse("prog", []string{"-url", "stun:stun.riasc.eu", "-url", "turn:turn.riasc.eu"}) config, err := config.Parse("prog", []string{"-url", "stun:stun.riasc.eu", "-url", "turn:turn.riasc.eu"})
if err != nil { if err != nil {
t.Errorf("err got %v, want nil", err) t.Errorf("err got %v, want nil", err)
} }
@@ -57,7 +57,7 @@ func TestParseArgsUrls(t *testing.T) {
} }
func TestParseArgsCandidateTypes(t *testing.T) { func TestParseArgsCandidateTypes(t *testing.T) {
config, err := args.Parse("prog", []string{"-ice-candidate-type", "host", "-ice-candidate-type", "relay"}) config, err := config.Parse("prog", []string{"-ice-candidate-type", "host", "-ice-candidate-type", "relay"})
if err != nil { if err != nil {
t.Errorf("err got %v, want nil", err) t.Errorf("err got %v, want nil", err)
} }
@@ -76,7 +76,7 @@ func TestParseArgsCandidateTypes(t *testing.T) {
} }
func TestParseArgsInterfaceFilter(t *testing.T) { func TestParseArgsInterfaceFilter(t *testing.T) {
config, err := args.Parse("prog", []string{"-interface-filter", "eth\\d+"}) config, err := config.Parse("prog", []string{"-interface-filter", "eth\\d+"})
if err != nil { if err != nil {
t.Errorf("err got %v, want nil", err) t.Errorf("err got %v, want nil", err)
} }
@@ -91,14 +91,14 @@ func TestParseArgsInterfaceFilter(t *testing.T) {
} }
func TestParseArgsInterfaceFilterFail(t *testing.T) { func TestParseArgsInterfaceFilterFail(t *testing.T) {
_, err := args.Parse("prog", []string{"-interface-filter", "eth("}) _, err := config.Parse("prog", []string{"-interface-filter", "eth("})
if err == nil { if err == nil {
t.Fail() t.Fail()
} }
} }
func TestParseArgsDefault(t *testing.T) { func TestParseArgsDefault(t *testing.T) {
config, err := args.Parse("prog", []string{}) config, err := config.Parse("prog", []string{})
if err != nil { if err != nil {
t.Fail() t.Fail()
} }

37
internal/config/ice.go Normal file
View File

@@ -0,0 +1,37 @@
package config
import (
"fmt"
"github.com/pion/ice/v2"
)
func candidateTypeFromString(t string) (ice.CandidateType, error) {
switch t {
case "host":
return ice.CandidateTypeHost, nil
case "srflx":
return ice.CandidateTypeServerReflexive, nil
case "prflx":
return ice.CandidateTypePeerReflexive, nil
case "relay":
return ice.CandidateTypeRelay, nil
default:
return ice.CandidateTypeUnspecified, fmt.Errorf("unknown candidate type: %s", t)
}
}
func networkTypeFromString(t string) (ice.NetworkType, error) {
switch t {
case "udp4":
return ice.NetworkTypeUDP4, nil
case "udp6":
return ice.NetworkTypeUDP6, nil
case "tcp4":
return ice.NetworkTypeTCP4, nil
case "tcp6":
return ice.NetworkTypeTCP6, nil
default:
return ice.NetworkTypeTCP4, fmt.Errorf("unknown network type: %s", t)
}
}

180
internal/config/types.go Normal file
View File

@@ -0,0 +1,180 @@
package config
import (
"fmt"
"net/url"
"regexp"
"strings"
"github.com/pion/ice/v2"
"go.uber.org/zap"
"riasc.eu/wice/pkg/proxy"
)
type backendURLList []*url.URL
func (i *backendURLList) Type() string {
return "stringSlice"
}
func (i *backendURLList) String() string {
s := []string{}
for _, u := range *i {
s = append(s, u.String())
}
return strings.Join(s, ",")
}
func (i *backendURLList) Set(value string) error {
// Allow the user to specify just the backend type as a valid url.
// E.g. "p2p" instead of "p2p:"
if !strings.Contains(value, ":") {
value += ":"
}
uri, err := url.Parse(value)
if err != nil {
return fmt.Errorf("invalid backend URI: %w", err)
}
*i = append(*i, uri)
return nil
}
type arrayFlags []string
func (i *arrayFlags) String() string {
return strings.Join(*i, ",")
}
func (i *arrayFlags) Set(value string) error {
*i = append(*i, value)
return nil
}
func (i *arrayFlags) Type() string {
return "stringSlice"
}
type iceURLList []*ice.URL
func (ul *iceURLList) Type() string {
return "stringSlice"
}
func (ul *iceURLList) Set(value string) error {
u, err := ice.ParseURL(value)
if err != nil {
return err
}
*ul = append(*ul, u)
return nil
}
func (ul *iceURLList) String() string {
l := []string{}
for _, u := range *ul {
l = append(l, u.String())
}
return strings.Join(l, ",")
}
type candidateTypeList []ice.CandidateType
func (cl *candidateTypeList) Type() string {
return "stringSlice"
}
func (cl *candidateTypeList) Set(value string) error {
ct, err := candidateTypeFromString(value)
if err != nil {
return err
}
*cl = append(*cl, ct)
return nil
}
func (cl *candidateTypeList) String() string {
l := []string{}
for _, c := range *cl {
l = append(l, c.String())
}
return strings.Join(l, ",")
}
type networkTypeList []ice.NetworkType
func (nl *networkTypeList) Type() string {
return "stringSlice"
}
func (nl *networkTypeList) Set(value string) error {
ct, err := networkTypeFromString(value)
if err != nil {
return err
}
*nl = append(*nl, ct)
return nil
}
func (nl *networkTypeList) String() string {
l := []string{}
for _, c := range *nl {
l = append(l, c.String())
}
return strings.Join(l, ",")
}
type proxyType struct{ proxy.ProxyType }
func (pt *proxyType) Type() string {
return "string"
}
func (pt *proxyType) Set(value string) error {
var err error
pt.ProxyType, err = proxy.ProxyTypeFromString(value)
return err
}
type logLevel struct{ zap.AtomicLevel }
func (ll *logLevel) Type() string {
return "string"
}
func (ll *logLevel) Set(value string) error {
return ll.UnmarshalText([]byte(value))
}
type regex struct{ *regexp.Regexp }
func (re *regex) Type() string {
return "string"
}
func (re *regex) Set(value string) error {
r, err := regexp.Compile(value)
if err != nil {
return fmt.Errorf("failed to compile regex: %w", err)
}
re.Regexp = r
return nil
}

View File

@@ -1,373 +0,0 @@
package args
import (
"flag"
"fmt"
"io"
"net/url"
"os"
"regexp"
"strconv"
"strings"
"time"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
pice "riasc.eu/wice/internal/ice"
"riasc.eu/wice/pkg/proxy"
"riasc.eu/wice/pkg/signaling"
"github.com/pion/ice/v2"
)
// Copied from pion/ice/agent_config.go
const (
// defaultCheckInterval is the interval at which the agent performs candidate checks in the connecting phase
defaultCheckInterval = 200 * time.Millisecond
// keepaliveInterval used to keep candidates alive
defaultKeepaliveInterval = 2 * time.Second
// defaultDisconnectedTimeout is the default time till an Agent transitions disconnected
defaultDisconnectedTimeout = 5 * time.Second
// defaultFailedTimeout is the default time till an Agent transitions to failed after disconnected
defaultFailedTimeout = 25 * time.Second
// max binding request before considering a pair failed
defaultMaxBindingRequests = 7
)
var (
defaultICEUrls = []*ice.URL{
{
Scheme: ice.SchemeTypeSTUN,
Host: "stun.l.google.com",
Port: 19302,
Username: "",
Password: "",
Proto: ice.ProtoTypeUDP,
},
}
)
type backendURLList []*url.URL
func (i *backendURLList) String() string {
s := []string{}
for _, u := range *i {
s = append(s, u.String())
}
return strings.Join(s, ",")
}
func (i *backendURLList) Set(value string) error {
// Allow the user to specify just the backend type as a valid url.
// E.g. "p2p" instead of "p2p:"
if !strings.Contains(value, ":") {
value += ":"
}
uri, err := url.Parse(value)
if err != nil {
return fmt.Errorf("invalid backend URI: %w", err)
}
*i = append(*i, uri)
return nil
}
type iceURLList []*ice.URL
func (i *iceURLList) String() string {
s := []string{}
for _, u := range *i {
s = append(s, u.String())
}
return strings.Join(s, ",")
}
func (i *iceURLList) Set(value string) error {
iceUrl, err := ice.ParseURL(value)
if err != nil {
return fmt.Errorf("failed to parse ICE url %s: %w", value, err)
}
*i = append(*i, iceUrl)
return nil
}
type arrayFlags []string
func (i *arrayFlags) String() string {
return strings.Join(*i, ",")
}
func (i *arrayFlags) Set(value string) error {
*i = append(*i, value)
return nil
}
type Args struct {
Backends []*url.URL
User bool
ProxyType proxy.Type
ConfigSync bool
ConfigPath string
WatchInterval time.Duration
RestartInterval time.Duration
InterfaceRegex *regexp.Regexp
IceInterfaceRegex *regexp.Regexp
AgentConfig ice.AgentConfig
Socket string
SocketWait bool
Interfaces []string
}
func showUsage() {
fmt.Fprintf(os.Stderr, "usage: %s [OPTIONS] [IFACES ...]\n", os.Args[0])
fmt.Println()
fmt.Println(" IFACES is a list of Wireguard interfaces")
fmt.Println(" (defaults to all available Wireguard interfaces)")
fmt.Println("")
fmt.Println(("Available OPTIONS are:"))
flag.PrintDefaults()
fmt.Println()
fmt.Println(" (**) These options can be specified multiple times")
fmt.Println()
fmt.Println("Available backends types are:")
for name, plugin := range signaling.Backends {
fmt.Printf(" %-7s %s\n", name, plugin.Description)
}
}
func (a *Args) DumpConfig(wr io.Writer) {
fmt.Fprintln(wr, "Options:")
fmt.Fprintln(wr, " URLs:")
for _, u := range a.AgentConfig.Urls {
fmt.Fprintf(wr, " %s\n", u.String())
}
fmt.Fprintln(wr, " Interfaces:")
for _, d := range a.Interfaces {
fmt.Fprintf(wr, " %s\n", d)
}
fmt.Fprintf(wr, " User: %s\n", strconv.FormatBool(a.User))
fmt.Fprintf(wr, " ProxyType: %s\n", a.ProxyType.String())
fmt.Fprintf(wr, " Signalling Backends:\n")
for _, b := range a.Backends {
fmt.Fprintf(wr, " %s\n", b)
}
}
func candidateTypeFromString(t string) (ice.CandidateType, error) {
switch t {
case "host":
return ice.CandidateTypeHost, nil
case "srflx":
return ice.CandidateTypeServerReflexive, nil
case "prflx":
return ice.CandidateTypePeerReflexive, nil
case "relay":
return ice.CandidateTypeRelay, nil
default:
return ice.CandidateTypeUnspecified, fmt.Errorf("unknown candidate type: %s", t)
}
}
func networkTypeFromString(t string) (ice.NetworkType, error) {
switch t {
case "udp4":
return ice.NetworkTypeUDP4, nil
case "udp6":
return ice.NetworkTypeUDP6, nil
case "tcp4":
return ice.NetworkTypeTCP4, nil
case "tcp6":
return ice.NetworkTypeTCP6, nil
default:
return ice.NetworkTypeTCP4, fmt.Errorf("unknown network type: %s", t)
}
}
func Parse(progname string, argv []string) (*Args, error) {
var err error
var iceURLs, iceCandidateTypes, iceNetworkTypes, iceNat1to1IPs arrayFlags
var backendURLs backendURLList
var logLevel zapcore.Level
flags := flag.NewFlagSet(progname, flag.ContinueOnError)
flags.Usage = showUsage
flags.Var(&logLevel, "log-level", "log level (one of \"panic\", \"fatal\", \"error\", \"warn\", \"info\", \"debug\", \"trace\")")
flags.Var(&backendURLs, "backend", "backend type / URL")
user := flags.Bool("user", false, "start userspace Wireguard daemon")
proxyType := flags.String("proxy", "auto", "proxy type to use")
interfaceFilter := flags.String("interface-filter", ".*", "regex for filtering Wireguard interfaces (e.g. \"wg-.*\")")
configSync := flags.Bool("config-sync", false, "sync Wireguard interface with configuration file (see \"wg synconf\"")
configPath := flags.String("config-path", "/etc/wireguard", "base path to search for Wireguard configuration files")
watchInterval := flags.Duration("watch-interval", time.Second, "interval at which we are polling the kernel for updates on the Wireguard interfaces")
// ice.AgentConfig fields
flags.Var(&iceURLs, "url", "STUN and/or TURN server address (**)")
flags.Var(&iceCandidateTypes, "ice-candidate-type", "usable candidate types (**, one of \"host\", \"srflx\", \"prflx\", \"relay\")")
flags.Var(&iceNetworkTypes, "ice-network-type", "usable network types (**, select from \"udp4\", \"udp6\", \"tcp4\", \"tcp6\")")
flags.Var(&iceNat1to1IPs, "ice-nat-1to1-ip", "list of IP addresses which will be added as local server reflexive candidates (**)")
icePortMin := flags.Uint("ice-port-min", 0, "minimum port for allocation policy (range: 0-65535)")
icePortMax := flags.Uint("ice-port-max", 0, "maximum port for allocation policy (range: 0-65535)")
iceLite := flags.Bool("ice-lite", false, "lite agents do not perform connectivity check and only provide host candidates")
iceMdns := flags.Bool("ice-mdns", false, "enable local Multicast DNS discovery")
iceMaxBindingRequests := flags.Int("ice-max-binding-requests", defaultMaxBindingRequests, "maximum number of binding request before considering a pair failed")
iceInsecureSkipVerify := flags.Bool("ice-insecure-skip-verify", false, "skip verification of TLS certificates for secure STUN/TURN servers")
iceInterfaceFilter := flags.String("ice-interface-filter", ".*", "regex for filtering local interfaces for ICE candidate gathering (e.g. \"eth[0-9]+\")")
iceDisconnectedTimeout := flags.Duration("ice-disconnected-timout", defaultDisconnectedTimeout, "time till an Agent transitions disconnected")
iceFailedTimeout := flags.Duration("ice-failed-timeout", defaultFailedTimeout, "time until an Agent transitions to failed after disconnected")
iceKeepaliveInterval := flags.Duration("ice-keepalive-interval", defaultKeepaliveInterval, "interval netween STUN keepalives")
iceCheckInterval := flags.Duration("ice-check-interval", defaultCheckInterval, "interval at which the agent performs candidate checks in the connecting phase")
iceRestartInterval := flags.Duration("ice-restart-interval", defaultDisconnectedTimeout, "time to wait before ICE restart")
iceUsername := flags.String("ice-user", "", "username for STUN/TURN credentials")
icePassword := flags.String("ice-pass", "", "password for STUN/TURN credentials")
// iceMaxBindingRequestTimeout := flag.Duration("ice-max-binding-request-timeout", maxBindingRequestTimeout, "wait time before binding requests can be deleted")
socket := flags.String("socket", "/var/run/wice.sock", "Unix control and monitoring socket")
socketWait := flags.Bool("socket-wait", false, "wait until first client connected to control socket before continuing start")
if err := flags.Parse(argv); err != nil {
return nil, fmt.Errorf("failed to parse args: %w", err)
}
logger := zap.L().Named("args")
logger.Info("Setting debug level", zap.Any("level", logLevel))
// logger.SetLevel(logLevel.Level)
args := &Args{
User: *user,
Backends: backendURLs,
ProxyType: proxy.ProxyTypeFromString(*proxyType),
// Discover: *discover,
ConfigSync: *configSync,
ConfigPath: *configPath,
WatchInterval: *watchInterval,
RestartInterval: *iceRestartInterval,
Socket: *socket,
SocketWait: *socketWait,
Interfaces: flag.Args(),
AgentConfig: ice.AgentConfig{
PortMin: uint16(*icePortMin),
PortMax: uint16(*icePortMax),
Lite: *iceLite,
InsecureSkipVerify: *iceInsecureSkipVerify,
Urls: []*ice.URL{},
},
}
// Find best proxy method
if args.ProxyType == proxy.TypeAuto {
args.ProxyType = proxy.AutoProxy()
}
// Check proxy type
if args.ProxyType == proxy.TypeInvalid {
return nil, fmt.Errorf("invalid proxy type: %s", *proxyType)
}
// Compile interface regex
args.InterfaceRegex, err = regexp.Compile(*interfaceFilter)
if err != nil {
return nil, fmt.Errorf("invalid interface filter: %w", err)
}
if *iceMaxBindingRequests >= 0 {
maxBindingReqs := uint16(*iceMaxBindingRequests)
args.AgentConfig.MaxBindingRequests = &maxBindingReqs
}
if *iceMdns {
args.AgentConfig.MulticastDNSMode = ice.MulticastDNSModeQueryAndGather
}
if *iceDisconnectedTimeout > 0 {
args.AgentConfig.DisconnectedTimeout = iceDisconnectedTimeout
}
if *iceFailedTimeout > 0 {
args.AgentConfig.FailedTimeout = iceFailedTimeout
}
if *iceKeepaliveInterval > 0 {
args.AgentConfig.KeepaliveInterval = iceKeepaliveInterval
}
if *iceCheckInterval > 0 {
args.AgentConfig.CheckInterval = iceCheckInterval
}
if len(iceNat1to1IPs) > 0 {
args.AgentConfig.NAT1To1IPCandidateType = ice.CandidateTypeServerReflexive
args.AgentConfig.NAT1To1IPs = iceNat1to1IPs
}
args.IceInterfaceRegex, err = regexp.Compile(*iceInterfaceFilter)
if err != nil {
return nil, fmt.Errorf("failed to compile interface regex: %w", err)
}
// Parse candidate types
for _, c := range iceCandidateTypes {
candType, err := candidateTypeFromString(c)
if err != nil {
return nil, err
}
args.AgentConfig.CandidateTypes = append(args.AgentConfig.CandidateTypes, candType)
}
// Parse network types
if len(iceNetworkTypes) == 0 {
args.AgentConfig.NetworkTypes = []ice.NetworkType{
ice.NetworkTypeUDP4,
ice.NetworkTypeUDP6,
}
} else {
for _, n := range iceNetworkTypes {
netType, err := networkTypeFromString(n)
if err != nil {
return nil, err
}
args.AgentConfig.NetworkTypes = append(args.AgentConfig.NetworkTypes, netType)
}
}
// Add default backend
if len(args.Backends) == 0 {
args.Backends = append(args.Backends, &url.URL{
Scheme: "p2p",
})
}
// Add default STUN/TURN servers
if len(args.AgentConfig.Urls) == 0 {
args.AgentConfig.Urls = defaultICEUrls
} else {
// Set ICE credentials
for _, u := range args.AgentConfig.Urls {
if *iceUsername != "" {
u.Username = *iceUsername
}
if *icePassword != "" {
u.Password = *icePassword
}
}
}
args.AgentConfig.LoggerFactory = &pice.LoggerFactory{}
return args, nil
}

98
pkg/pb/candidate.go Normal file
View File

@@ -0,0 +1,98 @@
package pb
import (
"fmt"
"strings"
"github.com/pion/ice/v2"
)
func NewCandidate(ic ice.Candidate) *Candidate {
c := &Candidate{
Type: Candidate_Type(ic.Type()),
Foundation: ic.Foundation(),
Component: int32(ic.Component()),
NetworkType: Candidate_NetworkType(ic.NetworkType()),
Priority: int32(ic.Priority()),
Address: ic.Address(),
Port: int32(ic.Port()),
TcpType: Candidate_TCPType(ic.TCPType()),
}
if r := c.RelatedAddress; r != nil {
c.RelatedAddress = &RelatedAddress{
Address: r.Address,
Port: r.Port,
}
}
return c
}
func (c *Candidate) ICECandidate() (ice.Candidate, error) {
var err error
var relAddr = ""
var relPort = 0
if c.RelatedAddress != nil {
relAddr = c.RelatedAddress.Address
relPort = int(c.RelatedAddress.Port)
}
var ic ice.Candidate
switch c.Type {
case Candidate_TYPE_HOST:
ic, err = ice.NewCandidateHost(&ice.CandidateHostConfig{
CandidateID: "",
Network: strings.ToLower(c.NetworkType.String()),
Address: c.Address,
Port: int(c.Port),
Component: uint16(c.Component),
Priority: uint32(c.Priority),
Foundation: c.Foundation,
TCPType: ice.TCPType(c.TcpType),
})
case Candidate_TYPE_SERVER_REFLEXIVE:
ic, err = ice.NewCandidateServerReflexive(&ice.CandidateServerReflexiveConfig{
CandidateID: "",
Network: strings.ToLower(c.NetworkType.String()),
Address: c.Address,
Port: int(c.Port),
Component: uint16(c.Component),
Priority: uint32(c.Priority),
Foundation: c.Foundation,
RelAddr: relAddr,
RelPort: relPort,
})
case Candidate_TYPE_PEER_REFLEXIVE:
ic, err = ice.NewCandidatePeerReflexive(&ice.CandidatePeerReflexiveConfig{
CandidateID: "",
Network: strings.ToLower(c.NetworkType.String()),
Address: c.Address,
Port: int(c.Port),
Component: uint16(c.Component),
Priority: uint32(c.Priority),
Foundation: c.Foundation,
RelAddr: relAddr,
RelPort: relPort,
})
case Candidate_TYPE_RELAY:
ic, err = ice.NewCandidateRelay(&ice.CandidateRelayConfig{
CandidateID: "",
Network: strings.ToLower(c.NetworkType.String()),
Address: c.Address,
Port: int(c.Port),
Component: uint16(c.Component),
Priority: uint32(c.Priority),
Foundation: c.Foundation,
RelAddr: relAddr,
RelPort: relPort,
})
default:
err = fmt.Errorf("unknown candidate type: %s", c.Type)
}
return ic, err
}

483
pkg/pb/candidate.pb.go Normal file
View File

@@ -0,0 +1,483 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.14.0
// source: candidate.proto
package pb
import (
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 Candidate_Type int32
const (
Candidate_TYPE_UNSPECIFIED Candidate_Type = 0
Candidate_TYPE_HOST Candidate_Type = 1
Candidate_TYPE_SERVER_REFLEXIVE Candidate_Type = 2
Candidate_TYPE_PEER_REFLEXIVE Candidate_Type = 3
Candidate_TYPE_RELAY Candidate_Type = 4
)
// Enum value maps for Candidate_Type.
var (
Candidate_Type_name = map[int32]string{
0: "TYPE_UNSPECIFIED",
1: "TYPE_HOST",
2: "TYPE_SERVER_REFLEXIVE",
3: "TYPE_PEER_REFLEXIVE",
4: "TYPE_RELAY",
}
Candidate_Type_value = map[string]int32{
"TYPE_UNSPECIFIED": 0,
"TYPE_HOST": 1,
"TYPE_SERVER_REFLEXIVE": 2,
"TYPE_PEER_REFLEXIVE": 3,
"TYPE_RELAY": 4,
}
)
func (x Candidate_Type) Enum() *Candidate_Type {
p := new(Candidate_Type)
*p = x
return p
}
func (x Candidate_Type) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Candidate_Type) Descriptor() protoreflect.EnumDescriptor {
return file_candidate_proto_enumTypes[0].Descriptor()
}
func (Candidate_Type) Type() protoreflect.EnumType {
return &file_candidate_proto_enumTypes[0]
}
func (x Candidate_Type) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Candidate_Type.Descriptor instead.
func (Candidate_Type) EnumDescriptor() ([]byte, []int) {
return file_candidate_proto_rawDescGZIP(), []int{1, 0}
}
type Candidate_NetworkType int32
const (
Candidate_UDP4 Candidate_NetworkType = 0
Candidate_UDP6 Candidate_NetworkType = 1
Candidate_TCP4 Candidate_NetworkType = 2
Candidate_TCP6 Candidate_NetworkType = 3
)
// Enum value maps for Candidate_NetworkType.
var (
Candidate_NetworkType_name = map[int32]string{
0: "UDP4",
1: "UDP6",
2: "TCP4",
3: "TCP6",
}
Candidate_NetworkType_value = map[string]int32{
"UDP4": 0,
"UDP6": 1,
"TCP4": 2,
"TCP6": 3,
}
)
func (x Candidate_NetworkType) Enum() *Candidate_NetworkType {
p := new(Candidate_NetworkType)
*p = x
return p
}
func (x Candidate_NetworkType) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Candidate_NetworkType) Descriptor() protoreflect.EnumDescriptor {
return file_candidate_proto_enumTypes[1].Descriptor()
}
func (Candidate_NetworkType) Type() protoreflect.EnumType {
return &file_candidate_proto_enumTypes[1]
}
func (x Candidate_NetworkType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Candidate_NetworkType.Descriptor instead.
func (Candidate_NetworkType) EnumDescriptor() ([]byte, []int) {
return file_candidate_proto_rawDescGZIP(), []int{1, 1}
}
type Candidate_TCPType int32
const (
Candidate_TCP_TYPE_UNSPECIFIED Candidate_TCPType = 0
Candidate_TCP_TYPE_ACTIVE Candidate_TCPType = 1
Candidate_TCP_TYPE_PASSIVE Candidate_TCPType = 2
Candidate_TCP_TYPE_SIMULTANEOUS_OPEN Candidate_TCPType = 3
)
// Enum value maps for Candidate_TCPType.
var (
Candidate_TCPType_name = map[int32]string{
0: "TCP_TYPE_UNSPECIFIED",
1: "TCP_TYPE_ACTIVE",
2: "TCP_TYPE_PASSIVE",
3: "TCP_TYPE_SIMULTANEOUS_OPEN",
}
Candidate_TCPType_value = map[string]int32{
"TCP_TYPE_UNSPECIFIED": 0,
"TCP_TYPE_ACTIVE": 1,
"TCP_TYPE_PASSIVE": 2,
"TCP_TYPE_SIMULTANEOUS_OPEN": 3,
}
)
func (x Candidate_TCPType) Enum() *Candidate_TCPType {
p := new(Candidate_TCPType)
*p = x
return p
}
func (x Candidate_TCPType) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Candidate_TCPType) Descriptor() protoreflect.EnumDescriptor {
return file_candidate_proto_enumTypes[2].Descriptor()
}
func (Candidate_TCPType) Type() protoreflect.EnumType {
return &file_candidate_proto_enumTypes[2]
}
func (x Candidate_TCPType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Candidate_TCPType.Descriptor instead.
func (Candidate_TCPType) EnumDescriptor() ([]byte, []int) {
return file_candidate_proto_rawDescGZIP(), []int{1, 2}
}
type RelatedAddress struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"`
}
func (x *RelatedAddress) Reset() {
*x = RelatedAddress{}
if protoimpl.UnsafeEnabled {
mi := &file_candidate_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RelatedAddress) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RelatedAddress) ProtoMessage() {}
func (x *RelatedAddress) ProtoReflect() protoreflect.Message {
mi := &file_candidate_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 RelatedAddress.ProtoReflect.Descriptor instead.
func (*RelatedAddress) Descriptor() ([]byte, []int) {
return file_candidate_proto_rawDescGZIP(), []int{0}
}
func (x *RelatedAddress) GetAddress() string {
if x != nil {
return x.Address
}
return ""
}
func (x *RelatedAddress) GetPort() int32 {
if x != nil {
return x.Port
}
return 0
}
type Candidate struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Type Candidate_Type `protobuf:"varint,1,opt,name=type,proto3,enum=Candidate_Type" json:"type,omitempty"`
Foundation string `protobuf:"bytes,2,opt,name=foundation,proto3" json:"foundation,omitempty"`
Component int32 `protobuf:"varint,3,opt,name=component,proto3" json:"component,omitempty"`
NetworkType Candidate_NetworkType `protobuf:"varint,4,opt,name=network_type,json=networkType,proto3,enum=Candidate_NetworkType" json:"network_type,omitempty"`
Priority int32 `protobuf:"varint,5,opt,name=priority,proto3" json:"priority,omitempty"`
Address string `protobuf:"bytes,6,opt,name=address,proto3" json:"address,omitempty"`
Port int32 `protobuf:"varint,7,opt,name=port,proto3" json:"port,omitempty"`
TcpType Candidate_TCPType `protobuf:"varint,8,opt,name=tcp_type,json=tcpType,proto3,enum=Candidate_TCPType" json:"tcp_type,omitempty"`
RelatedAddress *RelatedAddress `protobuf:"bytes,9,opt,name=related_address,json=relatedAddress,proto3" json:"related_address,omitempty"`
}
func (x *Candidate) Reset() {
*x = Candidate{}
if protoimpl.UnsafeEnabled {
mi := &file_candidate_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Candidate) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Candidate) ProtoMessage() {}
func (x *Candidate) ProtoReflect() protoreflect.Message {
mi := &file_candidate_proto_msgTypes[1]
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 Candidate.ProtoReflect.Descriptor instead.
func (*Candidate) Descriptor() ([]byte, []int) {
return file_candidate_proto_rawDescGZIP(), []int{1}
}
func (x *Candidate) GetType() Candidate_Type {
if x != nil {
return x.Type
}
return Candidate_TYPE_UNSPECIFIED
}
func (x *Candidate) GetFoundation() string {
if x != nil {
return x.Foundation
}
return ""
}
func (x *Candidate) GetComponent() int32 {
if x != nil {
return x.Component
}
return 0
}
func (x *Candidate) GetNetworkType() Candidate_NetworkType {
if x != nil {
return x.NetworkType
}
return Candidate_UDP4
}
func (x *Candidate) GetPriority() int32 {
if x != nil {
return x.Priority
}
return 0
}
func (x *Candidate) GetAddress() string {
if x != nil {
return x.Address
}
return ""
}
func (x *Candidate) GetPort() int32 {
if x != nil {
return x.Port
}
return 0
}
func (x *Candidate) GetTcpType() Candidate_TCPType {
if x != nil {
return x.TcpType
}
return Candidate_TCP_TYPE_UNSPECIFIED
}
func (x *Candidate) GetRelatedAddress() *RelatedAddress {
if x != nil {
return x.RelatedAddress
}
return nil
}
var File_candidate_proto protoreflect.FileDescriptor
var file_candidate_proto_rawDesc = []byte{
0x0a, 0x0f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 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, 0xf4, 0x04, 0x0a, 0x09, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x12,
0x23, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e,
0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04,
0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x18, 0x02, 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, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65,
0x6e, 0x74, 0x12, 0x39, 0x0a, 0x0c, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x74, 0x79,
0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69,
0x64, 0x61, 0x74, 0x65, 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, 0x1a, 0x0a,
0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x05, 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, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72,
0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28,
0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x2d, 0x0a, 0x08, 0x74, 0x63, 0x70, 0x5f, 0x74,
0x79, 0x70, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x43, 0x61, 0x6e, 0x64,
0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x43, 0x50, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x74,
0x63, 0x70, 0x54, 0x79, 0x70, 0x65, 0x12, 0x38, 0x0a, 0x0f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x65,
0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x0f, 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, 0x6f, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x59, 0x50, 0x45,
0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0d,
0x0a, 0x09, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x48, 0x4f, 0x53, 0x54, 0x10, 0x01, 0x12, 0x19, 0x0a,
0x15, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x5f, 0x52, 0x45, 0x46,
0x4c, 0x45, 0x58, 0x49, 0x56, 0x45, 0x10, 0x02, 0x12, 0x17, 0x0a, 0x13, 0x54, 0x59, 0x50, 0x45,
0x5f, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x52, 0x45, 0x46, 0x4c, 0x45, 0x58, 0x49, 0x56, 0x45, 0x10,
0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x45, 0x4c, 0x41, 0x59, 0x10,
0x04, 0x22, 0x35, 0x0a, 0x0b, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65,
0x12, 0x08, 0x0a, 0x04, 0x55, 0x44, 0x50, 0x34, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x55, 0x44,
0x50, 0x36, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x54, 0x43, 0x50, 0x34, 0x10, 0x02, 0x12, 0x08,
0x0a, 0x04, 0x54, 0x43, 0x50, 0x36, 0x10, 0x03, 0x22, 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, 0x16, 0x5a, 0x14, 0x72, 0x69, 0x61, 0x73,
0x63, 0x2e, 0x65, 0x75, 0x2f, 0x77, 0x69, 0x63, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_candidate_proto_rawDescOnce sync.Once
file_candidate_proto_rawDescData = file_candidate_proto_rawDesc
)
func file_candidate_proto_rawDescGZIP() []byte {
file_candidate_proto_rawDescOnce.Do(func() {
file_candidate_proto_rawDescData = protoimpl.X.CompressGZIP(file_candidate_proto_rawDescData)
})
return file_candidate_proto_rawDescData
}
var file_candidate_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
var file_candidate_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_candidate_proto_goTypes = []interface{}{
(Candidate_Type)(0), // 0: Candidate.Type
(Candidate_NetworkType)(0), // 1: Candidate.NetworkType
(Candidate_TCPType)(0), // 2: Candidate.TCPType
(*RelatedAddress)(nil), // 3: RelatedAddress
(*Candidate)(nil), // 4: Candidate
}
var file_candidate_proto_depIdxs = []int32{
0, // 0: Candidate.type:type_name -> Candidate.Type
1, // 1: Candidate.network_type:type_name -> Candidate.NetworkType
2, // 2: Candidate.tcp_type:type_name -> Candidate.TCPType
3, // 3: Candidate.related_address:type_name -> RelatedAddress
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_candidate_proto_init() }
func file_candidate_proto_init() {
if File_candidate_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_candidate_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RelatedAddress); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_candidate_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Candidate); 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_candidate_proto_rawDesc,
NumEnums: 3,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_candidate_proto_goTypes,
DependencyIndexes: file_candidate_proto_depIdxs,
EnumInfos: file_candidate_proto_enumTypes,
MessageInfos: file_candidate_proto_msgTypes,
}.Build()
File_candidate_proto = out.File
file_candidate_proto_rawDesc = nil
file_candidate_proto_goTypes = nil
file_candidate_proto_depIdxs = nil
}

42
pkg/pb/candidate.proto Normal file
View File

@@ -0,0 +1,42 @@
syntax = "proto3";
option go_package = "riasc.eu/wice/pkg/pb";
message RelatedAddress {
string address = 1;
int32 port = 2;
}
message Candidate {
enum Type {
TYPE_UNSPECIFIED = 0;
TYPE_HOST = 1;
TYPE_SERVER_REFLEXIVE = 2;
TYPE_PEER_REFLEXIVE = 3;
TYPE_RELAY = 4;
}
enum NetworkType {
UDP4 = 0;
UDP6 = 1;
TCP4 = 2;
TCP6 = 3;
}
enum TCPType {
TCP_TYPE_UNSPECIFIED = 0;
TCP_TYPE_ACTIVE = 1;
TCP_TYPE_PASSIVE = 2;
TCP_TYPE_SIMULTANEOUS_OPEN = 3;
}
Type type = 1;
string foundation = 2;
int32 component = 3;
NetworkType network_type = 4;
int32 priority = 5;
string address = 6;
int32 port = 7;
TCPType tcp_type = 8;
RelatedAddress related_address = 9;
}

View File

@@ -1,14 +1,28 @@
package pb package pb
import "time" import (
"time"
)
var Ok = Error{ var Success = &Error{
Ok: true, Code: Error_SUCCESS,
}
func (e *Error) Error() string {
return e.Message
}
func (e *Error) Ok() bool {
return e.Code == Error_SUCCESS
} }
func TimeNow() *Timestamp { func TimeNow() *Timestamp {
return Time(time.Now())
}
func Time(s time.Time) *Timestamp {
t := &Timestamp{} t := &Timestamp{}
t.Set(time.Now()) t.Set(s)
return t return t
} }

View File

@@ -20,59 +20,125 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
type Interface_Type int32 // from pion/ice/ice.go
type ConnectionState int32
const ( const (
Interface_UNKNOWN Interface_Type = 0 ConnectionState_NEW ConnectionState = 0 // ConnectionStateNew ICE agent is gathering addresses
Interface_LINUX_KERNEL Interface_Type = 1 ConnectionState_CHECKING ConnectionState = 1 // ConnectionStateChecking ICE agent has been given local and remote candidates, and is attempting to find a match
Interface_OPENBSD_KERNEL Interface_Type = 2 ConnectionState_CONNECTED ConnectionState = 2 // ConnectionStateConnected ICE agent has a pairing, but is still checking other pairs
Interface_WINDOWS_KERNEL Interface_Type = 3 ConnectionState_COMPLETED ConnectionState = 3 // ConnectionStateCompleted ICE agent has finished
Interface_USERSPACE Interface_Type = 4 ConnectionState_FAILED ConnectionState = 4 // ConnectionStateFailed ICE agent never could successfully connect
ConnectionState_DISCONNECTED ConnectionState = 5 // ConnectionStateDisconnected ICE agent connected successfully, but has entered a failed state
ConnectionState_CLOSED ConnectionState = 6 // ConnectionStateClosed ICE agent has finished and is no longer handling requests
) )
// Enum value maps for Interface_Type. // Enum value maps for ConnectionState.
var ( var (
Interface_Type_name = map[int32]string{ ConnectionState_name = map[int32]string{
0: "UNKNOWN", 0: "NEW",
1: "LINUX_KERNEL", 1: "CHECKING",
2: "OPENBSD_KERNEL", 2: "CONNECTED",
3: "WINDOWS_KERNEL", 3: "COMPLETED",
4: "USERSPACE", 4: "FAILED",
5: "DISCONNECTED",
6: "CLOSED",
} }
Interface_Type_value = map[string]int32{ ConnectionState_value = map[string]int32{
"UNKNOWN": 0, "NEW": 0,
"LINUX_KERNEL": 1, "CHECKING": 1,
"OPENBSD_KERNEL": 2, "CONNECTED": 2,
"WINDOWS_KERNEL": 3, "COMPLETED": 3,
"USERSPACE": 4, "FAILED": 4,
"DISCONNECTED": 5,
"CLOSED": 6,
} }
) )
func (x Interface_Type) Enum() *Interface_Type { func (x ConnectionState) Enum() *ConnectionState {
p := new(Interface_Type) p := new(ConnectionState)
*p = x *p = x
return p return p
} }
func (x Interface_Type) String() string { func (x ConnectionState) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
} }
func (Interface_Type) Descriptor() protoreflect.EnumDescriptor { func (ConnectionState) Descriptor() protoreflect.EnumDescriptor {
return file_common_proto_enumTypes[0].Descriptor() return file_common_proto_enumTypes[0].Descriptor()
} }
func (Interface_Type) Type() protoreflect.EnumType { func (ConnectionState) Type() protoreflect.EnumType {
return &file_common_proto_enumTypes[0] return &file_common_proto_enumTypes[0]
} }
func (x Interface_Type) Number() protoreflect.EnumNumber { func (x ConnectionState) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x) return protoreflect.EnumNumber(x)
} }
// Deprecated: Use Interface_Type.Descriptor instead. // Deprecated: Use ConnectionState.Descriptor instead.
func (Interface_Type) EnumDescriptor() ([]byte, []int) { func (ConnectionState) EnumDescriptor() ([]byte, []int) {
return file_common_proto_rawDescGZIP(), []int{4, 0} return file_common_proto_rawDescGZIP(), []int{0}
}
// https://pubs.opengroup.org/onlinepubs/009696899/functions/xsh_chap02_03.html
type Error_Code int32
const (
Error_SUCCESS Error_Code = 0
Error_EPERM Error_Code = 1
Error_ENOENT Error_Code = 2
Error_EEXIST Error_Code = 17
Error_EALREADY Error_Code = 18
Error_ENOTSUP Error_Code = 10
)
// Enum value maps for Error_Code.
var (
Error_Code_name = map[int32]string{
0: "SUCCESS",
1: "EPERM",
2: "ENOENT",
17: "EEXIST",
18: "EALREADY",
10: "ENOTSUP",
}
Error_Code_value = map[string]int32{
"SUCCESS": 0,
"EPERM": 1,
"ENOENT": 2,
"EEXIST": 17,
"EALREADY": 18,
"ENOTSUP": 10,
}
)
func (x Error_Code) Enum() *Error_Code {
p := new(Error_Code)
*p = x
return p
}
func (x Error_Code) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Error_Code) Descriptor() protoreflect.EnumDescriptor {
return file_common_proto_enumTypes[1].Descriptor()
}
func (Error_Code) Type() protoreflect.EnumType {
return &file_common_proto_enumTypes[1]
}
func (x Error_Code) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Error_Code.Descriptor instead.
func (Error_Code) EnumDescriptor() ([]byte, []int) {
return file_common_proto_rawDescGZIP(), []int{2, 0}
} }
type Void struct { type Void struct {
@@ -168,66 +234,19 @@ func (x *Timestamp) GetNanos() int32 {
return 0 return 0
} }
type Status struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Interfaces []*Interface `protobuf:"bytes,1,rep,name=interfaces,proto3" json:"interfaces,omitempty"`
}
func (x *Status) Reset() {
*x = Status{}
if protoimpl.UnsafeEnabled {
mi := &file_common_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Status) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Status) ProtoMessage() {}
func (x *Status) ProtoReflect() protoreflect.Message {
mi := &file_common_proto_msgTypes[2]
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 Status.ProtoReflect.Descriptor instead.
func (*Status) Descriptor() ([]byte, []int) {
return file_common_proto_rawDescGZIP(), []int{2}
}
func (x *Status) GetInterfaces() []*Interface {
if x != nil {
return x.Interfaces
}
return nil
}
type Error struct { type Error struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Ok bool `protobuf:"varint,1,opt,name=ok,proto3" json:"ok,omitempty"` Code Error_Code `protobuf:"varint,1,opt,name=code,proto3,enum=Error_Code" json:"code,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
} }
func (x *Error) Reset() { func (x *Error) Reset() {
*x = Error{} *x = Error{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_common_proto_msgTypes[3] mi := &file_common_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -240,7 +259,7 @@ func (x *Error) String() string {
func (*Error) ProtoMessage() {} func (*Error) ProtoMessage() {}
func (x *Error) ProtoReflect() protoreflect.Message { func (x *Error) ProtoReflect() protoreflect.Message {
mi := &file_common_proto_msgTypes[3] mi := &file_common_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -253,221 +272,23 @@ func (x *Error) ProtoReflect() protoreflect.Message {
// Deprecated: Use Error.ProtoReflect.Descriptor instead. // Deprecated: Use Error.ProtoReflect.Descriptor instead.
func (*Error) Descriptor() ([]byte, []int) { func (*Error) Descriptor() ([]byte, []int) {
return file_common_proto_rawDescGZIP(), []int{3} return file_common_proto_rawDescGZIP(), []int{2}
} }
func (x *Error) GetOk() bool { func (x *Error) GetCode() Error_Code {
if x != nil { if x != nil {
return x.Ok return x.Code
} }
return false return Error_SUCCESS
} }
func (x *Error) GetError() string { func (x *Error) GetMessage() string {
if x != nil { if x != nil {
return x.Error return x.Message
} }
return "" return ""
} }
type Interface struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Type Interface_Type `protobuf:"varint,2,opt,name=type,proto3,enum=Interface_Type" json:"type,omitempty"`
PrivateKey []byte `protobuf:"bytes,3,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"`
PublicKey []byte `protobuf:"bytes,4,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
ListenPort uint32 `protobuf:"varint,5,opt,name=listen_port,json=listenPort,proto3" json:"listen_port,omitempty"`
FirewallMark uint32 `protobuf:"varint,6,opt,name=firewall_mark,json=firewallMark,proto3" json:"firewall_mark,omitempty"`
Peers []*Peer `protobuf:"bytes,7,rep,name=peers,proto3" json:"peers,omitempty"`
}
func (x *Interface) Reset() {
*x = Interface{}
if protoimpl.UnsafeEnabled {
mi := &file_common_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Interface) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Interface) ProtoMessage() {}
func (x *Interface) ProtoReflect() protoreflect.Message {
mi := &file_common_proto_msgTypes[4]
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 Interface.ProtoReflect.Descriptor instead.
func (*Interface) Descriptor() ([]byte, []int) {
return file_common_proto_rawDescGZIP(), []int{4}
}
func (x *Interface) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Interface) GetType() Interface_Type {
if x != nil {
return x.Type
}
return Interface_UNKNOWN
}
func (x *Interface) GetPrivateKey() []byte {
if x != nil {
return x.PrivateKey
}
return nil
}
func (x *Interface) GetPublicKey() []byte {
if x != nil {
return x.PublicKey
}
return nil
}
func (x *Interface) GetListenPort() uint32 {
if x != nil {
return x.ListenPort
}
return 0
}
func (x *Interface) GetFirewallMark() uint32 {
if x != nil {
return x.FirewallMark
}
return 0
}
func (x *Interface) GetPeers() []*Peer {
if x != nil {
return x.Peers
}
return nil
}
type Peer struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
Endpoint []string `protobuf:"bytes,2,rep,name=Endpoint,proto3" json:"Endpoint,omitempty"`
PersistentKeepaliveInterval uint32 `protobuf:"varint,3,opt,name=persistent_keepalive_interval,json=persistentKeepaliveInterval,proto3" json:"persistent_keepalive_interval,omitempty"`
LastHandshake *Timestamp `protobuf:"bytes,4,opt,name=last_handshake,json=lastHandshake,proto3" json:"last_handshake,omitempty"`
TransmitBytes int64 `protobuf:"varint,5,opt,name=transmit_bytes,json=transmitBytes,proto3" json:"transmit_bytes,omitempty"`
ReceiveBytes int64 `protobuf:"varint,6,opt,name=receive_bytes,json=receiveBytes,proto3" json:"receive_bytes,omitempty"`
AllowedIps []string `protobuf:"bytes,7,rep,name=allowed_ips,json=allowedIps,proto3" json:"allowed_ips,omitempty"`
ProtocolVersion uint32 `protobuf:"varint,8,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"`
}
func (x *Peer) Reset() {
*x = Peer{}
if protoimpl.UnsafeEnabled {
mi := &file_common_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Peer) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Peer) ProtoMessage() {}
func (x *Peer) ProtoReflect() protoreflect.Message {
mi := &file_common_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 Peer.ProtoReflect.Descriptor instead.
func (*Peer) Descriptor() ([]byte, []int) {
return file_common_proto_rawDescGZIP(), []int{5}
}
func (x *Peer) GetPublicKey() []byte {
if x != nil {
return x.PublicKey
}
return nil
}
func (x *Peer) GetEndpoint() []string {
if x != nil {
return x.Endpoint
}
return nil
}
func (x *Peer) GetPersistentKeepaliveInterval() uint32 {
if x != nil {
return x.PersistentKeepaliveInterval
}
return 0
}
func (x *Peer) GetLastHandshake() *Timestamp {
if x != nil {
return x.LastHandshake
}
return nil
}
func (x *Peer) GetTransmitBytes() int64 {
if x != nil {
return x.TransmitBytes
}
return 0
}
func (x *Peer) GetReceiveBytes() int64 {
if x != nil {
return x.ReceiveBytes
}
return 0
}
func (x *Peer) GetAllowedIps() []string {
if x != nil {
return x.AllowedIps
}
return nil
}
func (x *Peer) GetProtocolVersion() uint32 {
if x != nil {
return x.ProtocolVersion
}
return 0
}
var File_common_proto protoreflect.FileDescriptor var File_common_proto protoreflect.FileDescriptor
var file_common_proto_rawDesc = []byte{ var file_common_proto_rawDesc = []byte{
@@ -476,57 +297,25 @@ var file_common_proto_rawDesc = []byte{
0x61, 0x6d, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x61, 0x6d, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x01,
0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x14, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x14, 0x0a,
0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x61, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x61,
0x6e, 0x6f, 0x73, 0x22, 0x34, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2a, 0x0a, 0x6e, 0x6f, 0x73, 0x22, 0x95, 0x01, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x1f, 0x0a,
0x0a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x45, 0x72,
0x0b, 0x32, 0x0a, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x0a, 0x69, 0x72, 0x6f, 0x72, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18,
0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x22, 0x2d, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x6f, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x51, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65,
0x6f, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x00, 0x12, 0x09, 0x0a,
0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xc5, 0x02, 0x0a, 0x09, 0x49, 0x6e, 0x74, 0x05, 0x45, 0x50, 0x45, 0x52, 0x4d, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x45, 0x4e, 0x4f, 0x45,
0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x4e, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x45, 0x45, 0x58, 0x49, 0x53, 0x54, 0x10, 0x11,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x74, 0x79, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x41, 0x4c, 0x52, 0x45, 0x41, 0x44, 0x59, 0x10, 0x12, 0x12, 0x0b,
0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x0a, 0x07, 0x45, 0x4e, 0x4f, 0x54, 0x53, 0x55, 0x50, 0x10, 0x0a, 0x2a, 0x70, 0x0a, 0x0f, 0x43,
0x66, 0x61, 0x63, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x07,
0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x0a, 0x03, 0x4e, 0x45, 0x57, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x48, 0x45, 0x43, 0x4b,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54,
0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4d, 0x50, 0x4c, 0x45, 0x54, 0x45,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x44, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x04, 0x12,
0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x10, 0x0a, 0x0c, 0x44, 0x49, 0x53, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10,
0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x50, 0x6f, 0x72, 0x74, 0x05, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x06, 0x42, 0x16, 0x5a,
0x12, 0x23, 0x0a, 0x0d, 0x66, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x5f, 0x6d, 0x61, 0x72, 0x14, 0x72, 0x69, 0x61, 0x73, 0x63, 0x2e, 0x65, 0x75, 0x2f, 0x77, 0x69, 0x63, 0x65, 0x2f, 0x70,
0x6b, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x66, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6c, 0x4d, 0x61, 0x72, 0x6b, 0x12, 0x1b, 0x0a, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x18, 0x07,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x05, 0x70, 0x65, 0x65,
0x72, 0x73, 0x22, 0x5c, 0x0a, 0x04, 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,
0x22, 0xd0, 0x02, 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, 0x1a, 0x0a, 0x08, 0x45, 0x6e, 0x64, 0x70,
0x6f, 0x69, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x45, 0x6e, 0x64, 0x70,
0x6f, 0x69, 0x6e, 0x74, 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, 0x03, 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, 0x31, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74,
0x5f, 0x68, 0x61, 0x6e, 0x64, 0x73, 0x68, 0x61, 0x6b, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x0a, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0d, 0x6c, 0x61,
0x73, 0x74, 0x48, 0x61, 0x6e, 0x64, 0x73, 0x68, 0x61, 0x6b, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x74,
0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, 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, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69,
0x76, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77,
0x65, 0x64, 0x5f, 0x69, 0x70, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x6c,
0x6c, 0x6f, 0x77, 0x65, 0x64, 0x49, 0x70, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01,
0x28, 0x0d, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, 0x65, 0x72, 0x73,
0x69, 0x6f, 0x6e, 0x42, 0x16, 0x5a, 0x14, 0x72, 0x69, 0x61, 0x73, 0x63, 0x2e, 0x65, 0x75, 0x2f,
0x77, 0x69, 0x63, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
} }
var ( var (
@@ -541,27 +330,22 @@ func file_common_proto_rawDescGZIP() []byte {
return file_common_proto_rawDescData return file_common_proto_rawDescData
} }
var file_common_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_common_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_common_proto_goTypes = []interface{}{ var file_common_proto_goTypes = []interface{}{
(Interface_Type)(0), // 0: Interface.Type (ConnectionState)(0), // 0: ConnectionState
(*Void)(nil), // 1: Void (Error_Code)(0), // 1: Error.Code
(*Timestamp)(nil), // 2: Timestamp (*Void)(nil), // 2: Void
(*Status)(nil), // 3: Status (*Timestamp)(nil), // 3: Timestamp
(*Error)(nil), // 4: Error (*Error)(nil), // 4: Error
(*Interface)(nil), // 5: Interface
(*Peer)(nil), // 6: Peer
} }
var file_common_proto_depIdxs = []int32{ var file_common_proto_depIdxs = []int32{
5, // 0: Status.interfaces:type_name -> Interface 1, // 0: Error.code:type_name -> Error.Code
0, // 1: Interface.type:type_name -> Interface.Type 1, // [1:1] is the sub-list for method output_type
6, // 2: Interface.peers:type_name -> Peer 1, // [1:1] is the sub-list for method input_type
2, // 3: Peer.last_handshake:type_name -> Timestamp 1, // [1:1] is the sub-list for extension type_name
4, // [4:4] is the sub-list for method output_type 1, // [1:1] is the sub-list for extension extendee
4, // [4:4] is the sub-list for method input_type 0, // [0:1] is the sub-list for field type_name
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
} }
func init() { file_common_proto_init() } func init() { file_common_proto_init() }
@@ -595,18 +379,6 @@ func file_common_proto_init() {
} }
} }
file_common_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_common_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Status); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_common_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Error); i { switch v := v.(*Error); i {
case 0: case 0:
return &v.state return &v.state
@@ -618,38 +390,14 @@ func file_common_proto_init() {
return nil return nil
} }
} }
file_common_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Interface); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_common_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Peer); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_common_proto_rawDesc, RawDescriptor: file_common_proto_rawDesc,
NumEnums: 1, NumEnums: 2,
NumMessages: 6, NumMessages: 3,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@@ -4,51 +4,33 @@ option go_package = "riasc.eu/wice/pkg/pb";
message Void {} message Void {}
message Timestamp { // from pion/ice/ice.go
int64 seconds = 1; enum ConnectionState {
int32 nanos = 2; NEW = 0; // ConnectionStateNew ICE agent is gathering addresses
CHECKING = 1; // ConnectionStateChecking ICE agent has been given local and remote candidates, and is attempting to find a match
CONNECTED = 2; // ConnectionStateConnected ICE agent has a pairing, but is still checking other pairs
COMPLETED = 3; // ConnectionStateCompleted ICE agent has finished
FAILED = 4; // ConnectionStateFailed ICE agent never could successfully connect
DISCONNECTED = 5; // ConnectionStateDisconnected ICE agent connected successfully, but has entered a failed state
CLOSED = 6; // ConnectionStateClosed ICE agent has finished and is no longer handling requests
} }
message Status { message Timestamp {
repeated Interface interfaces = 1; int64 seconds = 1;
int32 nanos = 2;
} }
message Error { message Error {
bool ok = 1; // https://pubs.opengroup.org/onlinepubs/009696899/functions/xsh_chap02_03.html
string error = 2; enum Code {
} SUCCESS = 0;
EPERM = 1;
message Interface { ENOENT = 2;
enum Type { EEXIST = 17;
UNKNOWN = 0; EALREADY = 18;
LINUX_KERNEL = 1; ENOTSUP = 10;
OPENBSD_KERNEL = 2; }
WINDOWS_KERNEL = 3;
USERSPACE = 4; Code code = 1;
} string message = 2;
string name = 1;
Type type = 2;
bytes private_key = 3;
bytes public_key = 4;
uint32 listen_port = 5;
uint32 firewall_mark = 6;
repeated Peer peers = 7;
}
message Peer {
bytes public_key = 1;
repeated string Endpoint = 2;
uint32 persistent_keepalive_interval = 3;
Timestamp last_handshake = 4;
int64 transmit_bytes = 5;
int64 receive_bytes = 6;
repeated string allowed_ips = 7;
uint32 protocol_version = 8;
} }

View File

@@ -8,6 +8,7 @@ func (e *Event) Log(l *zap.Logger, msg string, fields ...zap.Field) {
fields = append(fields, fields = append(fields,
zap.String("type", e.Type), zap.String("type", e.Type),
zap.String("state", e.State), zap.String("state", e.State),
zap.Any("event", e.Event),
) )
if e.Time != nil { if e.Time != nil {

View File

@@ -186,7 +186,8 @@ type PeerEvent struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Peer *Peer `protobuf:"bytes,1,opt,name=peer,proto3" json:"peer,omitempty"` Peer *Peer `protobuf:"bytes,1,opt,name=peer,proto3" json:"peer,omitempty"`
Modified []string `protobuf:"bytes,2,rep,name=modified,proto3" json:"modified,omitempty"`
} }
func (x *PeerEvent) Reset() { func (x *PeerEvent) Reset() {
@@ -228,6 +229,13 @@ func (x *PeerEvent) GetPeer() *Peer {
return nil return nil
} }
func (x *PeerEvent) GetModified() []string {
if x != nil {
return x.Modified
}
return nil
}
type InterfaceEvent struct { type InterfaceEvent struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@@ -342,37 +350,40 @@ var File_event_proto protoreflect.FileDescriptor
var file_event_proto_rawDesc = []byte{ var file_event_proto_rawDesc = []byte{
0x0a, 0x0b, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0c, 0x63, 0x0a, 0x0b, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0c, 0x63,
0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xce, 0x01, 0x0a, 0x05, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x70, 0x65, 0x65,
0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61,
0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xce, 0x01, 0x0a, 0x05, 0x45, 0x76, 0x65,
0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x32, 0x0a, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69,
0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x20, 0x0a, 0x04, 0x70, 0x65, 0x65, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18,
0x50, 0x65, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x04, 0x70, 0x65, 0x65, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x04,
0x72, 0x12, 0x25, 0x0a, 0x04, 0x69, 0x6e, 0x74, 0x66, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x70, 0x65, 0x65, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x50, 0x65, 0x65,
0x0f, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x04, 0x70, 0x65, 0x65, 0x72, 0x12, 0x25,
0x48, 0x00, 0x52, 0x04, 0x69, 0x6e, 0x74, 0x66, 0x12, 0x29, 0x0a, 0x07, 0x62, 0x61, 0x63, 0x6b, 0x0a, 0x04, 0x69, 0x6e, 0x74, 0x66, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x49,
0x65, 0x6e, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x63, 0x6b, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52,
0x65, 0x6e, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x62, 0x61, 0x63, 0x6b, 0x04, 0x69, 0x6e, 0x74, 0x66, 0x12, 0x29, 0x0a, 0x07, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64,
0x65, 0x6e, 0x64, 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x26, 0x0a, 0x09, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64,
0x50, 0x65, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x19, 0x0a, 0x04, 0x70, 0x65, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64,
0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x04, 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x42, 0x0a, 0x09, 0x50, 0x65, 0x65,
0x70, 0x65, 0x65, 0x72, 0x22, 0x3a, 0x0a, 0x0e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x19, 0x0a, 0x04, 0x70, 0x65, 0x65, 0x72, 0x18, 0x01,
0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x04, 0x70, 0x65, 0x65,
0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, 0x02, 0x20,
0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x03, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x22, 0x3a, 0x0a,
0x22, 0x84, 0x01, 0x0a, 0x0c, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x0e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12,
0x74, 0x12, 0x26, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x28, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01,
0x12, 0x2e, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x54, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x09,
0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x22, 0x84, 0x01, 0x0a, 0x0c, 0x42, 0x61,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x29, 0x0a, 0x10, 0x6c, 0x69, 0x73, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x04, 0x74, 0x79,
0x74, 0x65, 0x6e, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x18, 0x03, 0x20, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x42, 0x61, 0x63, 0x6b, 0x65,
0x03, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x6e, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79,
0x73, 0x73, 0x65, 0x73, 0x22, 0x11, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
0x52, 0x45, 0x41, 0x44, 0x59, 0x10, 0x00, 0x42, 0x16, 0x5a, 0x14, 0x72, 0x69, 0x61, 0x73, 0x63, 0x69, 0x64, 0x12, 0x29, 0x0a, 0x10, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x5f, 0x61, 0x64, 0x64,
0x2e, 0x65, 0x75, 0x2f, 0x77, 0x69, 0x63, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x62, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x69,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x73, 0x74, 0x65, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x22, 0x11, 0x0a,
0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x52, 0x45, 0x41, 0x44, 0x59, 0x10, 0x00,
0x42, 0x16, 0x5a, 0x14, 0x72, 0x69, 0x61, 0x73, 0x63, 0x2e, 0x65, 0x75, 0x2f, 0x77, 0x69, 0x63,
0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@@ -420,6 +431,8 @@ func file_event_proto_init() {
return return
} }
file_common_proto_init() file_common_proto_init()
file_peer_proto_init()
file_interface_proto_init()
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_event_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_event_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Event); i { switch v := v.(*Event); i {

View File

@@ -3,6 +3,8 @@ syntax = "proto3";
option go_package = "riasc.eu/wice/pkg/pb"; option go_package = "riasc.eu/wice/pkg/pb";
import "common.proto"; import "common.proto";
import "peer.proto";
import "interface.proto";
message Event { message Event {
Timestamp time = 1; Timestamp time = 1;
@@ -19,7 +21,7 @@ message Event {
message PeerEvent { message PeerEvent {
Peer peer = 1; Peer peer = 1;
repeated string modified = 2;
} }
message InterfaceEvent { message InterfaceEvent {

4
pkg/pb/generate.go Normal file
View File

@@ -0,0 +1,4 @@
package pb
//go:generate protoc --go_out=. --go_opt=paths=source_relative socket.proto candidate.proto common.proto event.proto interface.proto offer.proto peer.proto
//go:generate protoc --go-grpc_out=. --go-grpc_opt=paths=source_relative socket.proto

271
pkg/pb/interface.pb.go Normal file
View File

@@ -0,0 +1,271 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.14.0
// source: interface.proto
package pb
import (
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 Interface_Type int32
const (
Interface_UNKNOWN Interface_Type = 0
Interface_LINUX_KERNEL Interface_Type = 1
Interface_OPENBSD_KERNEL Interface_Type = 2
Interface_WINDOWS_KERNEL Interface_Type = 3
Interface_USERSPACE Interface_Type = 4
)
// Enum value maps for Interface_Type.
var (
Interface_Type_name = map[int32]string{
0: "UNKNOWN",
1: "LINUX_KERNEL",
2: "OPENBSD_KERNEL",
3: "WINDOWS_KERNEL",
4: "USERSPACE",
}
Interface_Type_value = map[string]int32{
"UNKNOWN": 0,
"LINUX_KERNEL": 1,
"OPENBSD_KERNEL": 2,
"WINDOWS_KERNEL": 3,
"USERSPACE": 4,
}
)
func (x Interface_Type) Enum() *Interface_Type {
p := new(Interface_Type)
*p = x
return p
}
func (x Interface_Type) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Interface_Type) Descriptor() protoreflect.EnumDescriptor {
return file_interface_proto_enumTypes[0].Descriptor()
}
func (Interface_Type) Type() protoreflect.EnumType {
return &file_interface_proto_enumTypes[0]
}
func (x Interface_Type) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Interface_Type.Descriptor instead.
func (Interface_Type) EnumDescriptor() ([]byte, []int) {
return file_interface_proto_rawDescGZIP(), []int{0, 0}
}
type Interface struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Type Interface_Type `protobuf:"varint,2,opt,name=type,proto3,enum=Interface_Type" json:"type,omitempty"`
PrivateKey []byte `protobuf:"bytes,3,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"`
PublicKey []byte `protobuf:"bytes,4,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
ListenPort uint32 `protobuf:"varint,5,opt,name=listen_port,json=listenPort,proto3" json:"listen_port,omitempty"`
FirewallMark uint32 `protobuf:"varint,6,opt,name=firewall_mark,json=firewallMark,proto3" json:"firewall_mark,omitempty"`
Peers []*Peer `protobuf:"bytes,7,rep,name=peers,proto3" json:"peers,omitempty"`
}
func (x *Interface) Reset() {
*x = Interface{}
if protoimpl.UnsafeEnabled {
mi := &file_interface_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Interface) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Interface) ProtoMessage() {}
func (x *Interface) ProtoReflect() protoreflect.Message {
mi := &file_interface_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 Interface.ProtoReflect.Descriptor instead.
func (*Interface) Descriptor() ([]byte, []int) {
return file_interface_proto_rawDescGZIP(), []int{0}
}
func (x *Interface) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Interface) GetType() Interface_Type {
if x != nil {
return x.Type
}
return Interface_UNKNOWN
}
func (x *Interface) GetPrivateKey() []byte {
if x != nil {
return x.PrivateKey
}
return nil
}
func (x *Interface) GetPublicKey() []byte {
if x != nil {
return x.PublicKey
}
return nil
}
func (x *Interface) GetListenPort() uint32 {
if x != nil {
return x.ListenPort
}
return 0
}
func (x *Interface) GetFirewallMark() uint32 {
if x != nil {
return x.FirewallMark
}
return 0
}
func (x *Interface) GetPeers() []*Peer {
if x != nil {
return x.Peers
}
return nil
}
var File_interface_proto protoreflect.FileDescriptor
var file_interface_proto_rawDesc = []byte{
0x0a, 0x0f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x1a, 0x0a, 0x70, 0x65, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc5, 0x02,
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,
0x23, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e,
0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04,
0x74, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f,
0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x72, 0x69, 0x76, 0x61,
0x74, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f,
0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69,
0x63, 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, 0x1b, 0x0a, 0x05, 0x70, 0x65,
0x65, 0x72, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x50, 0x65, 0x65, 0x72,
0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x22, 0x5c, 0x0a, 0x04, 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, 0x16, 0x5a, 0x14, 0x72, 0x69, 0x61, 0x73, 0x63, 0x2e, 0x65,
0x75, 0x2f, 0x77, 0x69, 0x63, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_interface_proto_rawDescOnce sync.Once
file_interface_proto_rawDescData = file_interface_proto_rawDesc
)
func file_interface_proto_rawDescGZIP() []byte {
file_interface_proto_rawDescOnce.Do(func() {
file_interface_proto_rawDescData = protoimpl.X.CompressGZIP(file_interface_proto_rawDescData)
})
return file_interface_proto_rawDescData
}
var file_interface_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_interface_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_interface_proto_goTypes = []interface{}{
(Interface_Type)(0), // 0: Interface.Type
(*Interface)(nil), // 1: Interface
(*Peer)(nil), // 2: Peer
}
var file_interface_proto_depIdxs = []int32{
0, // 0: Interface.type:type_name -> Interface.Type
2, // 1: Interface.peers:type_name -> Peer
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_interface_proto_init() }
func file_interface_proto_init() {
if File_interface_proto != nil {
return
}
file_peer_proto_init()
if !protoimpl.UnsafeEnabled {
file_interface_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Interface); 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_interface_proto_rawDesc,
NumEnums: 1,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_interface_proto_goTypes,
DependencyIndexes: file_interface_proto_depIdxs,
EnumInfos: file_interface_proto_enumTypes,
MessageInfos: file_interface_proto_msgTypes,
}.Build()
File_interface_proto = out.File
file_interface_proto_rawDesc = nil
file_interface_proto_goTypes = nil
file_interface_proto_depIdxs = nil
}

27
pkg/pb/interface.proto Normal file
View File

@@ -0,0 +1,27 @@
syntax = "proto3";
option go_package = "riasc.eu/wice/pkg/pb";
import "peer.proto";
message Interface {
enum Type {
UNKNOWN = 0;
LINUX_KERNEL = 1;
OPENBSD_KERNEL = 2;
WINDOWS_KERNEL = 3;
USERSPACE = 4;
}
string name = 1;
Type type = 2;
bytes private_key = 3;
bytes public_key = 4;
uint32 listen_port = 5;
uint32 firewall_mark = 6;
repeated Peer peers = 7;
}

5
pkg/pb/offer.go Normal file
View File

@@ -0,0 +1,5 @@
package pb
const (
OfferVersion = 1
)

View File

@@ -63,7 +63,7 @@ func (x Offer_Role) Number() protoreflect.EnumNumber {
// Deprecated: Use Offer_Role.Descriptor instead. // Deprecated: Use Offer_Role.Descriptor instead.
func (Offer_Role) EnumDescriptor() ([]byte, []int) { func (Offer_Role) EnumDescriptor() ([]byte, []int) {
return file_offer_proto_rawDescGZIP(), []int{1, 0} return file_offer_proto_rawDescGZIP(), []int{0, 0}
} }
type Offer_Implementation int32 type Offer_Implementation int32
@@ -109,82 +109,78 @@ func (x Offer_Implementation) Number() protoreflect.EnumNumber {
// Deprecated: Use Offer_Implementation.Descriptor instead. // Deprecated: Use Offer_Implementation.Descriptor instead.
func (Offer_Implementation) EnumDescriptor() ([]byte, []int) { func (Offer_Implementation) EnumDescriptor() ([]byte, []int) {
return file_offer_proto_rawDescGZIP(), []int{1, 1} return file_offer_proto_rawDescGZIP(), []int{0, 1}
} }
type SignedOffer struct { type Offer_Type int32
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Offer []byte `protobuf:"bytes,1,opt,name=offer,proto3" json:"offer,omitempty"` const (
Sigature []byte `protobuf:"bytes,2,opt,name=sigature,proto3" json:"sigature,omitempty"` Offer_OFFER Offer_Type = 0
} Offer_ANSWER Offer_Type = 1
)
func (x *SignedOffer) Reset() { // Enum value maps for Offer_Type.
*x = SignedOffer{} var (
if protoimpl.UnsafeEnabled { Offer_Type_name = map[int32]string{
mi := &file_offer_proto_msgTypes[0] 0: "OFFER",
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1: "ANSWER",
ms.StoreMessageInfo(mi)
} }
} Offer_Type_value = map[string]int32{
"OFFER": 0,
func (x *SignedOffer) String() string { "ANSWER": 1,
return protoimpl.X.MessageStringOf(x)
}
func (*SignedOffer) ProtoMessage() {}
func (x *SignedOffer) ProtoReflect() protoreflect.Message {
mi := &file_offer_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) )
func (x Offer_Type) Enum() *Offer_Type {
p := new(Offer_Type)
*p = x
return p
} }
// Deprecated: Use SignedOffer.ProtoReflect.Descriptor instead. func (x Offer_Type) String() string {
func (*SignedOffer) Descriptor() ([]byte, []int) { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
return file_offer_proto_rawDescGZIP(), []int{0}
} }
func (x *SignedOffer) GetOffer() []byte { func (Offer_Type) Descriptor() protoreflect.EnumDescriptor {
if x != nil { return file_offer_proto_enumTypes[2].Descriptor()
return x.Offer
}
return nil
} }
func (x *SignedOffer) GetSigature() []byte { func (Offer_Type) Type() protoreflect.EnumType {
if x != nil { return &file_offer_proto_enumTypes[2]
return x.Sigature
}
return nil
} }
func (x Offer_Type) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Offer_Type.Descriptor instead.
func (Offer_Type) EnumDescriptor() ([]byte, []int) {
return file_offer_proto_rawDescGZIP(), []int{0, 2}
}
// SDP-like session description
// See: https://www.rfc-editor.org/rfc/rfc8866.html
type Offer struct { type Offer struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` // Version of the WICE signalling protocoll (currently always 1)
Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
// Session epoch, incremented with each offer
Epoch int64 `protobuf:"varint,2,opt,name=epoch,proto3" json:"epoch,omitempty"` Epoch int64 `protobuf:"varint,2,opt,name=epoch,proto3" json:"epoch,omitempty"`
Role Offer_Role `protobuf:"varint,3,opt,name=role,proto3,enum=wice.Offer_Role" json:"role,omitempty"` Type Offer_Type `protobuf:"varint,3,opt,name=type,proto3,enum=wice.Offer_Type" json:"type,omitempty"`
Implementation Offer_Implementation `protobuf:"varint,4,opt,name=implementation,proto3,enum=wice.Offer_Implementation" json:"implementation,omitempty"` Role Offer_Role `protobuf:"varint,4,opt,name=role,proto3,enum=wice.Offer_Role" json:"role,omitempty"`
Candidates []*Candidate `protobuf:"bytes,5,rep,name=candidates,proto3" json:"candidates,omitempty"` Implementation Offer_Implementation `protobuf:"varint,5,opt,name=implementation,proto3,enum=wice.Offer_Implementation" json:"implementation,omitempty"`
Ufrag string `protobuf:"bytes,6,opt,name=Ufrag,proto3" json:"Ufrag,omitempty"` Ufrag string `protobuf:"bytes,6,opt,name=Ufrag,proto3" json:"Ufrag,omitempty"`
Pwd string `protobuf:"bytes,7,opt,name=Pwd,proto3" json:"Pwd,omitempty"` Pwd string `protobuf:"bytes,7,opt,name=Pwd,proto3" json:"Pwd,omitempty"`
Candidates []*Candidate `protobuf:"bytes,8,rep,name=candidates,proto3" json:"candidates,omitempty"`
} }
func (x *Offer) Reset() { func (x *Offer) Reset() {
*x = Offer{} *x = Offer{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_offer_proto_msgTypes[1] mi := &file_offer_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -197,7 +193,7 @@ func (x *Offer) String() string {
func (*Offer) ProtoMessage() {} func (*Offer) ProtoMessage() {}
func (x *Offer) ProtoReflect() protoreflect.Message { func (x *Offer) ProtoReflect() protoreflect.Message {
mi := &file_offer_proto_msgTypes[1] mi := &file_offer_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -210,7 +206,7 @@ func (x *Offer) ProtoReflect() protoreflect.Message {
// Deprecated: Use Offer.ProtoReflect.Descriptor instead. // Deprecated: Use Offer.ProtoReflect.Descriptor instead.
func (*Offer) Descriptor() ([]byte, []int) { func (*Offer) Descriptor() ([]byte, []int) {
return file_offer_proto_rawDescGZIP(), []int{1} return file_offer_proto_rawDescGZIP(), []int{0}
} }
func (x *Offer) GetVersion() int64 { func (x *Offer) GetVersion() int64 {
@@ -227,6 +223,13 @@ func (x *Offer) GetEpoch() int64 {
return 0 return 0
} }
func (x *Offer) GetType() Offer_Type {
if x != nil {
return x.Type
}
return Offer_OFFER
}
func (x *Offer) GetRole() Offer_Role { func (x *Offer) GetRole() Offer_Role {
if x != nil { if x != nil {
return x.Role return x.Role
@@ -241,13 +244,6 @@ func (x *Offer) GetImplementation() Offer_Implementation {
return Offer_FULL return Offer_FULL
} }
func (x *Offer) GetCandidates() []*Candidate {
if x != nil {
return x.Candidates
}
return nil
}
func (x *Offer) GetUfrag() string { func (x *Offer) GetUfrag() string {
if x != nil { if x != nil {
return x.Ufrag return x.Ufrag
@@ -262,76 +258,45 @@ func (x *Offer) GetPwd() string {
return "" return ""
} }
type Candidate struct { func (x *Offer) GetCandidates() []*Candidate {
state protoimpl.MessageState if x != nil {
sizeCache protoimpl.SizeCache return x.Candidates
unknownFields protoimpl.UnknownFields
}
func (x *Candidate) Reset() {
*x = Candidate{}
if protoimpl.UnsafeEnabled {
mi := &file_offer_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
} }
} return nil
func (x *Candidate) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Candidate) ProtoMessage() {}
func (x *Candidate) ProtoReflect() protoreflect.Message {
mi := &file_offer_proto_msgTypes[2]
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 Candidate.ProtoReflect.Descriptor instead.
func (*Candidate) Descriptor() ([]byte, []int) {
return file_offer_proto_rawDescGZIP(), []int{2}
} }
var File_offer_proto protoreflect.FileDescriptor var File_offer_proto protoreflect.FileDescriptor
var file_offer_proto_rawDesc = []byte{ var file_offer_proto_rawDesc = []byte{
0x0a, 0x0b, 0x6f, 0x66, 0x66, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x77, 0x0a, 0x0b, 0x6f, 0x66, 0x66, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x77,
0x69, 0x63, 0x65, 0x22, 0x3f, 0x0a, 0x0b, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x4f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x1a, 0x0f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70,
0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x66, 0x66, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x89, 0x03, 0x0a, 0x05, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x12, 0x18,
0x0c, 0x52, 0x05, 0x6f, 0x66, 0x66, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x69, 0x67, 0x61,
0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x73, 0x69, 0x67, 0x61,
0x74, 0x75, 0x72, 0x65, 0x22, 0xc9, 0x02, 0x0a, 0x05, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x12, 0x18,
0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63,
0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x24, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x24,
0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x77, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x77,
0x69, 0x63, 0x65, 0x2e, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x69, 0x63, 0x65, 0x2e, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04,
0x72, 0x6f, 0x6c, 0x65, 0x12, 0x42, 0x0a, 0x0e, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01,
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x77, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x77, 0x69, 0x63, 0x65, 0x2e, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x2e,
0x69, 0x63, 0x65, 0x2e, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x2e, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x42, 0x0a, 0x0e, 0x69, 0x6d,
0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01,
0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x0a, 0x0a, 0x63, 0x61, 0x6e, 0x64, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x77, 0x69, 0x63, 0x65, 0x2e, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x2e,
0x69, 0x64, 0x61, 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x77, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e,
0x69, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x0a, 0x63, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14,
0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x55, 0x66, 0x72, 0x0a, 0x05, 0x55, 0x66, 0x72, 0x61, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x55,
0x61, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x55, 0x66, 0x72, 0x61, 0x67, 0x12, 0x66, 0x72, 0x61, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x50, 0x77, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28,
0x10, 0x0a, 0x03, 0x50, 0x77, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x50, 0x77, 0x09, 0x52, 0x03, 0x50, 0x77, 0x64, 0x12, 0x2a, 0x0a, 0x0a, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64,
0x64, 0x22, 0x27, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x4f, 0x4e, 0x61, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x43, 0x61, 0x6e,
0x54, 0x52, 0x4f, 0x4c, 0x4c, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x4f, 0x4e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x0a, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74,
0x54, 0x52, 0x4f, 0x4c, 0x4c, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x22, 0x24, 0x0a, 0x0e, 0x49, 0x6d, 0x65, 0x73, 0x22, 0x27, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x4f,
0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x54, 0x52, 0x4f, 0x4c, 0x4c, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x4f,
0x46, 0x55, 0x4c, 0x4c, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x49, 0x54, 0x45, 0x10, 0x01, 0x4e, 0x54, 0x52, 0x4f, 0x4c, 0x4c, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x22, 0x24, 0x0a, 0x0e, 0x49,
0x22, 0x0b, 0x0a, 0x09, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x42, 0x16, 0x5a, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x08, 0x0a,
0x14, 0x72, 0x69, 0x61, 0x73, 0x63, 0x2e, 0x65, 0x75, 0x2f, 0x77, 0x69, 0x63, 0x65, 0x2f, 0x70, 0x04, 0x46, 0x55, 0x4c, 0x4c, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x49, 0x54, 0x45, 0x10,
0x6b, 0x67, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x01, 0x22, 0x1d, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x4f, 0x46, 0x46,
0x45, 0x52, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x4e, 0x53, 0x57, 0x45, 0x52, 0x10, 0x01,
0x42, 0x16, 0x5a, 0x14, 0x72, 0x69, 0x61, 0x73, 0x63, 0x2e, 0x65, 0x75, 0x2f, 0x77, 0x69, 0x63,
0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@@ -346,24 +311,25 @@ func file_offer_proto_rawDescGZIP() []byte {
return file_offer_proto_rawDescData return file_offer_proto_rawDescData
} }
var file_offer_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_offer_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
var file_offer_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_offer_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_offer_proto_goTypes = []interface{}{ var file_offer_proto_goTypes = []interface{}{
(Offer_Role)(0), // 0: wice.Offer.Role (Offer_Role)(0), // 0: wice.Offer.Role
(Offer_Implementation)(0), // 1: wice.Offer.Implementation (Offer_Implementation)(0), // 1: wice.Offer.Implementation
(*SignedOffer)(nil), // 2: wice.SignedOffer (Offer_Type)(0), // 2: wice.Offer.Type
(*Offer)(nil), // 3: wice.Offer (*Offer)(nil), // 3: wice.Offer
(*Candidate)(nil), // 4: wice.Candidate (*Candidate)(nil), // 4: Candidate
} }
var file_offer_proto_depIdxs = []int32{ var file_offer_proto_depIdxs = []int32{
0, // 0: wice.Offer.role:type_name -> wice.Offer.Role 2, // 0: wice.Offer.type:type_name -> wice.Offer.Type
1, // 1: wice.Offer.implementation:type_name -> wice.Offer.Implementation 0, // 1: wice.Offer.role:type_name -> wice.Offer.Role
4, // 2: wice.Offer.candidates:type_name -> wice.Candidate 1, // 2: wice.Offer.implementation:type_name -> wice.Offer.Implementation
3, // [3:3] is the sub-list for method output_type 4, // 3: wice.Offer.candidates:type_name -> Candidate
3, // [3:3] is the sub-list for method input_type 4, // [4:4] is the sub-list for method output_type
3, // [3:3] is the sub-list for extension type_name 4, // [4:4] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension extendee 4, // [4:4] is the sub-list for extension type_name
0, // [0:3] is the sub-list for field type_name 4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
} }
func init() { file_offer_proto_init() } func init() { file_offer_proto_init() }
@@ -371,20 +337,9 @@ func file_offer_proto_init() {
if File_offer_proto != nil { if File_offer_proto != nil {
return return
} }
file_candidate_proto_init()
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_offer_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_offer_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SignedOffer); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_offer_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Offer); i { switch v := v.(*Offer); i {
case 0: case 0:
return &v.state return &v.state
@@ -396,26 +351,14 @@ func file_offer_proto_init() {
return nil return nil
} }
} }
file_offer_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Candidate); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_offer_proto_rawDesc, RawDescriptor: file_offer_proto_rawDesc,
NumEnums: 2, NumEnums: 3,
NumMessages: 3, NumMessages: 1,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@@ -3,11 +3,10 @@ package wice;
option go_package = "riasc.eu/wice/pkg/pb"; option go_package = "riasc.eu/wice/pkg/pb";
message SignedOffer { import "candidate.proto";
bytes offer = 1;
bytes sigature = 2;
}
// SDP-like session description
// See: https://www.rfc-editor.org/rfc/rfc8866.html
message Offer { message Offer {
enum Role { enum Role {
CONTROLLED = 0; CONTROLLED = 0;
@@ -19,26 +18,23 @@ message Offer {
LITE = 1; LITE = 1;
} }
int64 version = 1; enum Type {
int64 epoch = 2; OFFER = 0;
Role role = 3; ANSWER = 1;
Implementation implementation = 4; }
repeated Candidate candidates = 5; // Version of the WICE signalling protocoll (currently always 1)
int64 version = 1;
// Session epoch, incremented with each offer
int64 epoch = 2;
Type type = 3;
Role role = 4;
Implementation implementation = 5;
string Ufrag = 6; string Ufrag = 6;
string Pwd = 7; string Pwd = 7;
}
message Candidate { repeated Candidate candidates = 8;
// Type string `json:"type"`
// Foundation string `json:"foundation"`
// Component int `json:"component"`
// NetworkType string `json:"network"`
// Priority int `json:"priority"`
// Address string `json:"address"`
// Port int `json:"port"`
// TCPType *string `json:"tcp_type,omitempty"`
// RelAddr *string `json:"related_address,omitempty"`
// RelPort *int `json:"related_port,omitempty"`
} }

9
pkg/pb/peer.go Normal file
View File

@@ -0,0 +1,9 @@
package pb
import (
"riasc.eu/wice/pkg/crypto"
)
func (p *Peer) Key() crypto.Key {
return *(*crypto.Key)(p.PublicKey)
}

316
pkg/pb/peer.pb.go Normal file
View File

@@ -0,0 +1,316 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.14.0
// source: peer.proto
package pb
import (
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 PeerDescriptor struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
Hostname string `protobuf:"bytes,2,opt,name=hostname,proto3" json:"hostname,omitempty"`
AllowedIps []string `protobuf:"bytes,3,rep,name=allowed_ips,json=allowedIps,proto3" json:"allowed_ips,omitempty"`
}
func (x *PeerDescriptor) Reset() {
*x = PeerDescriptor{}
if protoimpl.UnsafeEnabled {
mi := &file_peer_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PeerDescriptor) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PeerDescriptor) ProtoMessage() {}
func (x *PeerDescriptor) ProtoReflect() protoreflect.Message {
mi := &file_peer_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 PeerDescriptor.ProtoReflect.Descriptor instead.
func (*PeerDescriptor) Descriptor() ([]byte, []int) {
return file_peer_proto_rawDescGZIP(), []int{0}
}
func (x *PeerDescriptor) GetPublicKey() []byte {
if x != nil {
return x.PublicKey
}
return nil
}
func (x *PeerDescriptor) GetHostname() string {
if x != nil {
return x.Hostname
}
return ""
}
func (x *PeerDescriptor) GetAllowedIps() []string {
if x != nil {
return x.AllowedIps
}
return nil
}
type Peer struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
Endpoint []string `protobuf:"bytes,2,rep,name=Endpoint,proto3" json:"Endpoint,omitempty"`
PersistentKeepaliveInterval uint32 `protobuf:"varint,3,opt,name=persistent_keepalive_interval,json=persistentKeepaliveInterval,proto3" json:"persistent_keepalive_interval,omitempty"`
LastHandshake *Timestamp `protobuf:"bytes,4,opt,name=last_handshake,json=lastHandshake,proto3" json:"last_handshake,omitempty"`
TransmitBytes int64 `protobuf:"varint,5,opt,name=transmit_bytes,json=transmitBytes,proto3" json:"transmit_bytes,omitempty"`
ReceiveBytes int64 `protobuf:"varint,6,opt,name=receive_bytes,json=receiveBytes,proto3" json:"receive_bytes,omitempty"`
AllowedIps []string `protobuf:"bytes,7,rep,name=allowed_ips,json=allowedIps,proto3" json:"allowed_ips,omitempty"`
ProtocolVersion uint32 `protobuf:"varint,8,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"`
State ConnectionState `protobuf:"varint,9,opt,name=state,proto3,enum=ConnectionState" json:"state,omitempty"`
}
func (x *Peer) Reset() {
*x = Peer{}
if protoimpl.UnsafeEnabled {
mi := &file_peer_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Peer) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Peer) ProtoMessage() {}
func (x *Peer) ProtoReflect() protoreflect.Message {
mi := &file_peer_proto_msgTypes[1]
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 Peer.ProtoReflect.Descriptor instead.
func (*Peer) Descriptor() ([]byte, []int) {
return file_peer_proto_rawDescGZIP(), []int{1}
}
func (x *Peer) GetPublicKey() []byte {
if x != nil {
return x.PublicKey
}
return nil
}
func (x *Peer) GetEndpoint() []string {
if x != nil {
return x.Endpoint
}
return nil
}
func (x *Peer) GetPersistentKeepaliveInterval() uint32 {
if x != nil {
return x.PersistentKeepaliveInterval
}
return 0
}
func (x *Peer) GetLastHandshake() *Timestamp {
if x != nil {
return x.LastHandshake
}
return nil
}
func (x *Peer) GetTransmitBytes() int64 {
if x != nil {
return x.TransmitBytes
}
return 0
}
func (x *Peer) GetReceiveBytes() int64 {
if x != nil {
return x.ReceiveBytes
}
return 0
}
func (x *Peer) GetAllowedIps() []string {
if x != nil {
return x.AllowedIps
}
return nil
}
func (x *Peer) GetProtocolVersion() uint32 {
if x != nil {
return x.ProtocolVersion
}
return 0
}
func (x *Peer) GetState() ConnectionState {
if x != nil {
return x.State
}
return ConnectionState_NEW
}
var File_peer_proto protoreflect.FileDescriptor
var file_peer_proto_rawDesc = []byte{
0x0a, 0x0a, 0x70, 0x65, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0c, 0x63, 0x6f,
0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6c, 0x0a, 0x0e, 0x50, 0x65,
0x65, 0x72, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 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, 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, 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, 0x22, 0xf8, 0x02, 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, 0x1a, 0x0a, 0x08, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x03,
0x28, 0x09, 0x52, 0x08, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 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, 0x03, 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, 0x31, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x68, 0x61, 0x6e, 0x64, 0x73, 0x68, 0x61,
0x6b, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73,
0x74, 0x61, 0x6d, 0x70, 0x52, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x48, 0x61, 0x6e, 0x64, 0x73, 0x68,
0x61, 0x6b, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x5f,
0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, 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, 0x06, 0x20, 0x01, 0x28,
0x03, 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12,
0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x69, 0x70, 0x73, 0x18, 0x07,
0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x49, 0x70, 0x73,
0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x76, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x63, 0x6f, 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x05, 0x73,
0x74, 0x61, 0x74, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x43, 0x6f, 0x6e,
0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74,
0x61, 0x74, 0x65, 0x42, 0x16, 0x5a, 0x14, 0x72, 0x69, 0x61, 0x73, 0x63, 0x2e, 0x65, 0x75, 0x2f,
0x77, 0x69, 0x63, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
file_peer_proto_rawDescOnce sync.Once
file_peer_proto_rawDescData = file_peer_proto_rawDesc
)
func file_peer_proto_rawDescGZIP() []byte {
file_peer_proto_rawDescOnce.Do(func() {
file_peer_proto_rawDescData = protoimpl.X.CompressGZIP(file_peer_proto_rawDescData)
})
return file_peer_proto_rawDescData
}
var file_peer_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_peer_proto_goTypes = []interface{}{
(*PeerDescriptor)(nil), // 0: PeerDescriptor
(*Peer)(nil), // 1: Peer
(*Timestamp)(nil), // 2: Timestamp
(ConnectionState)(0), // 3: ConnectionState
}
var file_peer_proto_depIdxs = []int32{
2, // 0: Peer.last_handshake:type_name -> Timestamp
3, // 1: Peer.state:type_name -> ConnectionState
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_peer_proto_init() }
func file_peer_proto_init() {
if File_peer_proto != nil {
return
}
file_common_proto_init()
if !protoimpl.UnsafeEnabled {
file_peer_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PeerDescriptor); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_peer_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Peer); 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_peer_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_peer_proto_goTypes,
DependencyIndexes: file_peer_proto_depIdxs,
MessageInfos: file_peer_proto_msgTypes,
}.Build()
File_peer_proto = out.File
file_peer_proto_rawDesc = nil
file_peer_proto_goTypes = nil
file_peer_proto_depIdxs = nil
}

26
pkg/pb/peer.proto Normal file
View File

@@ -0,0 +1,26 @@
syntax = "proto3";
option go_package = "riasc.eu/wice/pkg/pb";
import "common.proto";
message PeerDescriptor {
bytes public_key = 1;
string hostname = 2;
repeated string allowed_ips = 3;
}
message Peer {
bytes public_key = 1;
repeated string Endpoint = 2;
uint32 persistent_keepalive_interval = 3;
Timestamp last_handshake = 4;
int64 transmit_bytes = 5;
int64 receive_bytes = 6;
repeated string allowed_ips = 7;
uint32 protocol_version = 8;
ConnectionState state = 9;
}

View File

@@ -10,6 +10,7 @@ import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect" reflect "reflect"
sync "sync"
) )
const ( const (
@@ -19,40 +20,326 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
type Status struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Interfaces []*Interface `protobuf:"bytes,1,rep,name=interfaces,proto3" json:"interfaces,omitempty"`
}
func (x *Status) Reset() {
*x = Status{}
if protoimpl.UnsafeEnabled {
mi := &file_socket_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Status) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Status) ProtoMessage() {}
func (x *Status) ProtoReflect() protoreflect.Message {
mi := &file_socket_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 Status.ProtoReflect.Descriptor instead.
func (*Status) Descriptor() ([]byte, []int) {
return file_socket_proto_rawDescGZIP(), []int{0}
}
func (x *Status) GetInterfaces() []*Interface {
if x != nil {
return x.Interfaces
}
return nil
}
type UnWaitParams struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *UnWaitParams) Reset() {
*x = UnWaitParams{}
if protoimpl.UnsafeEnabled {
mi := &file_socket_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UnWaitParams) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UnWaitParams) ProtoMessage() {}
func (x *UnWaitParams) ProtoReflect() protoreflect.Message {
mi := &file_socket_proto_msgTypes[1]
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 UnWaitParams.ProtoReflect.Descriptor instead.
func (*UnWaitParams) Descriptor() ([]byte, []int) {
return file_socket_proto_rawDescGZIP(), []int{1}
}
type SyncConfigParams struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *SyncConfigParams) Reset() {
*x = SyncConfigParams{}
if protoimpl.UnsafeEnabled {
mi := &file_socket_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SyncConfigParams) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SyncConfigParams) ProtoMessage() {}
func (x *SyncConfigParams) ProtoReflect() protoreflect.Message {
mi := &file_socket_proto_msgTypes[2]
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 SyncConfigParams.ProtoReflect.Descriptor instead.
func (*SyncConfigParams) Descriptor() ([]byte, []int) {
return file_socket_proto_rawDescGZIP(), []int{2}
}
type SyncInterfaceParams struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *SyncInterfaceParams) Reset() {
*x = SyncInterfaceParams{}
if protoimpl.UnsafeEnabled {
mi := &file_socket_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SyncInterfaceParams) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SyncInterfaceParams) ProtoMessage() {}
func (x *SyncInterfaceParams) ProtoReflect() protoreflect.Message {
mi := &file_socket_proto_msgTypes[3]
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 SyncInterfaceParams.ProtoReflect.Descriptor instead.
func (*SyncInterfaceParams) Descriptor() ([]byte, []int) {
return file_socket_proto_rawDescGZIP(), []int{3}
}
type ShutdownParams struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *ShutdownParams) Reset() {
*x = ShutdownParams{}
if protoimpl.UnsafeEnabled {
mi := &file_socket_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ShutdownParams) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ShutdownParams) ProtoMessage() {}
func (x *ShutdownParams) ProtoReflect() protoreflect.Message {
mi := &file_socket_proto_msgTypes[4]
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 ShutdownParams.ProtoReflect.Descriptor instead.
func (*ShutdownParams) Descriptor() ([]byte, []int) {
return file_socket_proto_rawDescGZIP(), []int{4}
}
type StreamEventsParams struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *StreamEventsParams) Reset() {
*x = StreamEventsParams{}
if protoimpl.UnsafeEnabled {
mi := &file_socket_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StreamEventsParams) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StreamEventsParams) ProtoMessage() {}
func (x *StreamEventsParams) ProtoReflect() protoreflect.Message {
mi := &file_socket_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 StreamEventsParams.ProtoReflect.Descriptor instead.
func (*StreamEventsParams) Descriptor() ([]byte, []int) {
return file_socket_proto_rawDescGZIP(), []int{5}
}
var File_socket_proto protoreflect.FileDescriptor var File_socket_proto protoreflect.FileDescriptor
var file_socket_proto_rawDesc = []byte{ var file_socket_proto_rawDesc = []byte{
0x0a, 0x0c, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x0a, 0x0c, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04,
0x77, 0x69, 0x63, 0x65, 0x1a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x77, 0x69, 0x63, 0x65, 0x1a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x1a, 0x0b, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x74, 0x6f, 0x1a, 0x0b, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a,
0x5f, 0x0a, 0x06, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x0f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x05, 0x2e, 0x56, 0x6f, 0x69, 0x64, 0x1a, 0x07, 0x2e, 0x22, 0x34, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2a, 0x0a, 0x0a, 0x69, 0x6e,
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x17, 0x0a, 0x06, 0x55, 0x6e, 0x57, 0x61, 0x69, 0x74, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a,
0x12, 0x05, 0x2e, 0x56, 0x6f, 0x69, 0x64, 0x1a, 0x06, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x65,
0x1f, 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x22, 0x0e, 0x0a, 0x0c, 0x55, 0x6e, 0x57, 0x61, 0x69, 0x74,
0x05, 0x2e, 0x56, 0x6f, 0x69, 0x64, 0x1a, 0x06, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x12, 0x0a, 0x10, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f,
0x42, 0x16, 0x5a, 0x14, 0x72, 0x69, 0x61, 0x73, 0x63, 0x2e, 0x65, 0x75, 0x2f, 0x77, 0x69, 0x63, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x79,
0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x6e, 0x63, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d,
0x73, 0x22, 0x10, 0x0a, 0x0e, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x50, 0x61, 0x72,
0x61, 0x6d, 0x73, 0x22, 0x14, 0x0a, 0x12, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x76, 0x65,
0x6e, 0x74, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x32, 0x9d, 0x02, 0x0a, 0x06, 0x53, 0x6f,
0x63, 0x6b, 0x65, 0x74, 0x12, 0x22, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75,
0x73, 0x12, 0x05, 0x2e, 0x56, 0x6f, 0x69, 0x64, 0x1a, 0x0c, 0x2e, 0x77, 0x69, 0x63, 0x65, 0x2e,
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65,
0x61, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x18, 0x2e, 0x77, 0x69, 0x63, 0x65, 0x2e,
0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x50, 0x61, 0x72, 0x61,
0x6d, 0x73, 0x1a, 0x06, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x30, 0x01, 0x12, 0x26,
0x0a, 0x06, 0x55, 0x6e, 0x57, 0x61, 0x69, 0x74, 0x12, 0x12, 0x2e, 0x77, 0x69, 0x63, 0x65, 0x2e,
0x55, 0x6e, 0x57, 0x61, 0x69, 0x74, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x06, 0x2e, 0x45,
0x72, 0x72, 0x6f, 0x72, 0x22, 0x00, 0x12, 0x2a, 0x0a, 0x08, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f,
0x77, 0x6e, 0x12, 0x14, 0x2e, 0x77, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f,
0x77, 0x6e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x06, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72,
0x22, 0x00, 0x12, 0x2e, 0x0a, 0x0a, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
0x12, 0x16, 0x2e, 0x77, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x06, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72,
0x22, 0x00, 0x12, 0x35, 0x0a, 0x0e, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66,
0x61, 0x63, 0x65, 0x73, 0x12, 0x19, 0x2e, 0x77, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63,
0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a,
0x06, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x00, 0x42, 0x16, 0x5a, 0x14, 0x72, 0x69, 0x61,
0x73, 0x63, 0x2e, 0x65, 0x75, 0x2f, 0x77, 0x69, 0x63, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var (
file_socket_proto_rawDescOnce sync.Once
file_socket_proto_rawDescData = file_socket_proto_rawDesc
)
func file_socket_proto_rawDescGZIP() []byte {
file_socket_proto_rawDescOnce.Do(func() {
file_socket_proto_rawDescData = protoimpl.X.CompressGZIP(file_socket_proto_rawDescData)
})
return file_socket_proto_rawDescData
}
var file_socket_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_socket_proto_goTypes = []interface{}{ var file_socket_proto_goTypes = []interface{}{
(*Void)(nil), // 0: Void (*Status)(nil), // 0: wice.Status
(*Status)(nil), // 1: Status (*UnWaitParams)(nil), // 1: wice.UnWaitParams
(*Error)(nil), // 2: Error (*SyncConfigParams)(nil), // 2: wice.SyncConfigParams
(*Event)(nil), // 3: Event (*SyncInterfaceParams)(nil), // 3: wice.SyncInterfaceParams
(*ShutdownParams)(nil), // 4: wice.ShutdownParams
(*StreamEventsParams)(nil), // 5: wice.StreamEventsParams
(*Interface)(nil), // 6: Interface
(*Void)(nil), // 7: Void
(*Event)(nil), // 8: Event
(*Error)(nil), // 9: Error
} }
var file_socket_proto_depIdxs = []int32{ var file_socket_proto_depIdxs = []int32{
0, // 0: wice.Socket.GetStatus:input_type -> Void 6, // 0: wice.Status.interfaces:type_name -> Interface
0, // 1: wice.Socket.UnWait:input_type -> Void 7, // 1: wice.Socket.GetStatus:input_type -> Void
0, // 2: wice.Socket.StreamEvents:input_type -> Void 5, // 2: wice.Socket.StreamEvents:input_type -> wice.StreamEventsParams
1, // 3: wice.Socket.GetStatus:output_type -> Status 1, // 3: wice.Socket.UnWait:input_type -> wice.UnWaitParams
2, // 4: wice.Socket.UnWait:output_type -> Error 4, // 4: wice.Socket.Shutdown:input_type -> wice.ShutdownParams
3, // 5: wice.Socket.StreamEvents:output_type -> Event 2, // 5: wice.Socket.SyncConfig:input_type -> wice.SyncConfigParams
3, // [3:6] is the sub-list for method output_type 3, // 6: wice.Socket.SyncInterfaces:input_type -> wice.SyncInterfaceParams
0, // [0:3] is the sub-list for method input_type 0, // 7: wice.Socket.GetStatus:output_type -> wice.Status
0, // [0:0] is the sub-list for extension type_name 8, // 8: wice.Socket.StreamEvents:output_type -> Event
0, // [0:0] is the sub-list for extension extendee 9, // 9: wice.Socket.UnWait:output_type -> Error
0, // [0:0] is the sub-list for field type_name 9, // 10: wice.Socket.Shutdown:output_type -> Error
9, // 11: wice.Socket.SyncConfig:output_type -> Error
9, // 12: wice.Socket.SyncInterfaces:output_type -> Error
7, // [7:13] is the sub-list for method output_type
1, // [1:7] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
} }
func init() { file_socket_proto_init() } func init() { file_socket_proto_init() }
@@ -62,18 +349,94 @@ func file_socket_proto_init() {
} }
file_common_proto_init() file_common_proto_init()
file_event_proto_init() file_event_proto_init()
file_interface_proto_init()
if !protoimpl.UnsafeEnabled {
file_socket_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Status); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_socket_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UnWaitParams); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_socket_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SyncConfigParams); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_socket_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SyncInterfaceParams); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_socket_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ShutdownParams); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_socket_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StreamEventsParams); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_socket_proto_rawDesc, RawDescriptor: file_socket_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 0, NumMessages: 6,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },
GoTypes: file_socket_proto_goTypes, GoTypes: file_socket_proto_goTypes,
DependencyIndexes: file_socket_proto_depIdxs, DependencyIndexes: file_socket_proto_depIdxs,
MessageInfos: file_socket_proto_msgTypes,
}.Build() }.Build()
File_socket_proto = out.File File_socket_proto = out.File
file_socket_proto_rawDesc = nil file_socket_proto_rawDesc = nil

View File

@@ -5,16 +5,30 @@ option go_package = "riasc.eu/wice/pkg/pb";
import "common.proto"; import "common.proto";
import "event.proto"; import "event.proto";
import "interface.proto";
message Status {
repeated Interface interfaces = 1;
}
message UnWaitParams {}
message SyncConfigParams {}
message SyncInterfaceParams {}
message ShutdownParams {}
message StreamEventsParams {}
service Socket { service Socket {
rpc GetStatus(Void) returns (Status); rpc GetStatus(Void) returns (Status) {}
rpc UnWait(Void) returns (Error); rpc StreamEvents(StreamEventsParams) returns (stream Event) {}
// rpc Shutdown(Void) returns (Error);
// rpc SyncConfig(Void) returns (Error);
// rpc SyncInterfaces(Void) returns (Error);
// rpc AddInterface(Interface) returns (Error);
// rpc RemoveInterface(Interface) returns (Error);
// rpc AddPeer(Peer) returns (Error);
rpc StreamEvents(Void) returns (stream Event); rpc UnWait(UnWaitParams) returns (Error) {}
rpc Shutdown(ShutdownParams) returns (Error) {}
rpc SyncConfig(SyncConfigParams) returns (Error) {}
rpc SyncInterfaces(SyncInterfaceParams) returns (Error) {}
// rpc AddInterface(Interface) returns (Error) {}
// rpc RemoveInterface(Interface) returns (Error) {}
// rpc AddPeer(Peer) returns (Error) {}
} }

View File

@@ -19,8 +19,11 @@ const _ = grpc.SupportPackageIsVersion7
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type SocketClient interface { type SocketClient interface {
GetStatus(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Status, error) GetStatus(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Status, error)
UnWait(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Error, error) StreamEvents(ctx context.Context, in *StreamEventsParams, opts ...grpc.CallOption) (Socket_StreamEventsClient, error)
StreamEvents(ctx context.Context, in *Void, opts ...grpc.CallOption) (Socket_StreamEventsClient, error) UnWait(ctx context.Context, in *UnWaitParams, opts ...grpc.CallOption) (*Error, error)
Shutdown(ctx context.Context, in *ShutdownParams, opts ...grpc.CallOption) (*Error, error)
SyncConfig(ctx context.Context, in *SyncConfigParams, opts ...grpc.CallOption) (*Error, error)
SyncInterfaces(ctx context.Context, in *SyncInterfaceParams, opts ...grpc.CallOption) (*Error, error)
} }
type socketClient struct { type socketClient struct {
@@ -40,16 +43,7 @@ func (c *socketClient) GetStatus(ctx context.Context, in *Void, opts ...grpc.Cal
return out, nil return out, nil
} }
func (c *socketClient) UnWait(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Error, error) { func (c *socketClient) StreamEvents(ctx context.Context, in *StreamEventsParams, opts ...grpc.CallOption) (Socket_StreamEventsClient, error) {
out := new(Error)
err := c.cc.Invoke(ctx, "/wice.Socket/UnWait", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *socketClient) StreamEvents(ctx context.Context, in *Void, opts ...grpc.CallOption) (Socket_StreamEventsClient, error) {
stream, err := c.cc.NewStream(ctx, &Socket_ServiceDesc.Streams[0], "/wice.Socket/StreamEvents", opts...) stream, err := c.cc.NewStream(ctx, &Socket_ServiceDesc.Streams[0], "/wice.Socket/StreamEvents", opts...)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -81,13 +75,52 @@ func (x *socketStreamEventsClient) Recv() (*Event, error) {
return m, nil return m, nil
} }
func (c *socketClient) UnWait(ctx context.Context, in *UnWaitParams, opts ...grpc.CallOption) (*Error, error) {
out := new(Error)
err := c.cc.Invoke(ctx, "/wice.Socket/UnWait", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *socketClient) Shutdown(ctx context.Context, in *ShutdownParams, opts ...grpc.CallOption) (*Error, error) {
out := new(Error)
err := c.cc.Invoke(ctx, "/wice.Socket/Shutdown", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *socketClient) SyncConfig(ctx context.Context, in *SyncConfigParams, opts ...grpc.CallOption) (*Error, error) {
out := new(Error)
err := c.cc.Invoke(ctx, "/wice.Socket/SyncConfig", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *socketClient) SyncInterfaces(ctx context.Context, in *SyncInterfaceParams, opts ...grpc.CallOption) (*Error, error) {
out := new(Error)
err := c.cc.Invoke(ctx, "/wice.Socket/SyncInterfaces", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// SocketServer is the server API for Socket service. // SocketServer is the server API for Socket service.
// All implementations must embed UnimplementedSocketServer // All implementations must embed UnimplementedSocketServer
// for forward compatibility // for forward compatibility
type SocketServer interface { type SocketServer interface {
GetStatus(context.Context, *Void) (*Status, error) GetStatus(context.Context, *Void) (*Status, error)
UnWait(context.Context, *Void) (*Error, error) StreamEvents(*StreamEventsParams, Socket_StreamEventsServer) error
StreamEvents(*Void, Socket_StreamEventsServer) error UnWait(context.Context, *UnWaitParams) (*Error, error)
Shutdown(context.Context, *ShutdownParams) (*Error, error)
SyncConfig(context.Context, *SyncConfigParams) (*Error, error)
SyncInterfaces(context.Context, *SyncInterfaceParams) (*Error, error)
mustEmbedUnimplementedSocketServer() mustEmbedUnimplementedSocketServer()
} }
@@ -98,11 +131,20 @@ type UnimplementedSocketServer struct {
func (UnimplementedSocketServer) GetStatus(context.Context, *Void) (*Status, error) { func (UnimplementedSocketServer) GetStatus(context.Context, *Void) (*Status, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetStatus not implemented") return nil, status.Errorf(codes.Unimplemented, "method GetStatus not implemented")
} }
func (UnimplementedSocketServer) UnWait(context.Context, *Void) (*Error, error) { func (UnimplementedSocketServer) StreamEvents(*StreamEventsParams, Socket_StreamEventsServer) error {
return status.Errorf(codes.Unimplemented, "method StreamEvents not implemented")
}
func (UnimplementedSocketServer) UnWait(context.Context, *UnWaitParams) (*Error, error) {
return nil, status.Errorf(codes.Unimplemented, "method UnWait not implemented") return nil, status.Errorf(codes.Unimplemented, "method UnWait not implemented")
} }
func (UnimplementedSocketServer) StreamEvents(*Void, Socket_StreamEventsServer) error { func (UnimplementedSocketServer) Shutdown(context.Context, *ShutdownParams) (*Error, error) {
return status.Errorf(codes.Unimplemented, "method StreamEvents not implemented") return nil, status.Errorf(codes.Unimplemented, "method Shutdown not implemented")
}
func (UnimplementedSocketServer) SyncConfig(context.Context, *SyncConfigParams) (*Error, error) {
return nil, status.Errorf(codes.Unimplemented, "method SyncConfig not implemented")
}
func (UnimplementedSocketServer) SyncInterfaces(context.Context, *SyncInterfaceParams) (*Error, error) {
return nil, status.Errorf(codes.Unimplemented, "method SyncInterfaces not implemented")
} }
func (UnimplementedSocketServer) mustEmbedUnimplementedSocketServer() {} func (UnimplementedSocketServer) mustEmbedUnimplementedSocketServer() {}
@@ -135,26 +177,8 @@ func _Socket_GetStatus_Handler(srv interface{}, ctx context.Context, dec func(in
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _Socket_UnWait_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Void)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SocketServer).UnWait(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wice.Socket/UnWait",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SocketServer).UnWait(ctx, req.(*Void))
}
return interceptor(ctx, in, info, handler)
}
func _Socket_StreamEvents_Handler(srv interface{}, stream grpc.ServerStream) error { func _Socket_StreamEvents_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(Void) m := new(StreamEventsParams)
if err := stream.RecvMsg(m); err != nil { if err := stream.RecvMsg(m); err != nil {
return err return err
} }
@@ -174,6 +198,78 @@ func (x *socketStreamEventsServer) Send(m *Event) error {
return x.ServerStream.SendMsg(m) return x.ServerStream.SendMsg(m)
} }
func _Socket_UnWait_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UnWaitParams)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SocketServer).UnWait(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wice.Socket/UnWait",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SocketServer).UnWait(ctx, req.(*UnWaitParams))
}
return interceptor(ctx, in, info, handler)
}
func _Socket_Shutdown_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ShutdownParams)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SocketServer).Shutdown(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wice.Socket/Shutdown",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SocketServer).Shutdown(ctx, req.(*ShutdownParams))
}
return interceptor(ctx, in, info, handler)
}
func _Socket_SyncConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SyncConfigParams)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SocketServer).SyncConfig(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wice.Socket/SyncConfig",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SocketServer).SyncConfig(ctx, req.(*SyncConfigParams))
}
return interceptor(ctx, in, info, handler)
}
func _Socket_SyncInterfaces_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SyncInterfaceParams)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SocketServer).SyncInterfaces(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wice.Socket/SyncInterfaces",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SocketServer).SyncInterfaces(ctx, req.(*SyncInterfaceParams))
}
return interceptor(ctx, in, info, handler)
}
// Socket_ServiceDesc is the grpc.ServiceDesc for Socket service. // Socket_ServiceDesc is the grpc.ServiceDesc for Socket service.
// It's only intended for direct use with grpc.RegisterService, // It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
@@ -189,6 +285,18 @@ var Socket_ServiceDesc = grpc.ServiceDesc{
MethodName: "UnWait", MethodName: "UnWait",
Handler: _Socket_UnWait_Handler, Handler: _Socket_UnWait_Handler,
}, },
{
MethodName: "Shutdown",
Handler: _Socket_Shutdown_Handler,
},
{
MethodName: "SyncConfig",
Handler: _Socket_SyncConfig_Handler,
},
{
MethodName: "SyncInterfaces",
Handler: _Socket_SyncInterfaces_Handler,
},
}, },
Streams: []grpc.StreamDesc{ Streams: []grpc.StreamDesc{
{ {

View File

@@ -9,6 +9,8 @@ import (
"go.uber.org/zap" "go.uber.org/zap"
"google.golang.org/grpc" "google.golang.org/grpc"
ginsecure "google.golang.org/grpc/credentials/insecure"
"riasc.eu/wice/pkg/crypto"
"riasc.eu/wice/pkg/pb" "riasc.eu/wice/pkg/pb"
) )
@@ -49,23 +51,25 @@ func Connect(path string) (*Client, error) {
} }
tgt := fmt.Sprintf("unix://%s", path) tgt := fmt.Sprintf("unix://%s", path)
conn, err := grpc.Dial(tgt, grpc.WithInsecure()) conn, err := grpc.Dial(tgt, grpc.WithTransportCredentials(ginsecure.NewCredentials()))
if err != nil { if err != nil {
return nil, err return nil, err
} }
logger := zap.L().Named("socket.client").With(zap.String("path", path))
client := &Client{ client := &Client{
SocketClient: pb.NewSocketClient(conn), SocketClient: pb.NewSocketClient(conn),
grpc: conn, grpc: conn,
logger: zap.L().Named("socket.client"), logger: logger,
Events: make(chan *pb.Event, 100), Events: make(chan *pb.Event, 100),
} }
sts, err := client.UnWait(context.Background(), &pb.Void{}) rerr, err := client.UnWait(context.Background(), &pb.UnWaitParams{})
if err != nil { if err != nil {
return nil, fmt.Errorf("failed RPC request: %w", err) return nil, fmt.Errorf("failed RPC request: %w", err)
} else if !sts.Ok { } else if !rerr.Ok() && rerr.Code != pb.Error_EALREADY {
return nil, fmt.Errorf("received RPC error: %s", sts.Error) return nil, fmt.Errorf("received RPC error: %w", rerr)
} }
go client.streamEvents() go client.streamEvents()
@@ -80,7 +84,7 @@ func (c *Client) Close() error {
} }
func (c *Client) streamEvents() { func (c *Client) streamEvents() {
str, err := c.StreamEvents(context.Background(), &pb.Void{}) str, err := c.StreamEvents(context.Background(), &pb.StreamEventsParams{})
if err != nil { if err != nil {
c.logger.Error("Failed to stream events", zap.Error(err)) c.logger.Error("Failed to stream events", zap.Error(err))
} }
@@ -108,9 +112,10 @@ func (c *Client) WaitForEvent(flt *pb.Event) *pb.Event {
return nil return nil
} }
func (c *Client) WaitPeerHandshake() { func (c *Client) WaitPeerHandshake(peer crypto.Key) {
c.WaitForEvent(&pb.Event{ c.WaitForEvent(&pb.Event{
Type: "handshake", Type: "handshake",
State: "new",
}) })
} }

62
pkg/socket/handlers.go Normal file
View File

@@ -0,0 +1,62 @@
package socket
import (
"context"
"riasc.eu/wice/pkg/pb"
)
func (s *Server) GetStatus(ctx context.Context, _ *pb.Void) (*pb.Status, error) {
return &pb.Status{}, nil
}
func (s *Server) StreamEvents(params *pb.StreamEventsParams, stream pb.Socket_StreamEventsServer) error {
ch := make(chan *pb.Event, 100)
s.eventListenersLock.Lock()
s.eventListeners[ch] = nil
s.eventListenersLock.Unlock()
for evt := range ch {
stream.Send(evt)
}
return nil
}
func (s *Server) UnWait(ctx context.Context, params *pb.UnWaitParams) (*pb.Error, error) {
var e = &pb.Error{
Code: pb.Error_EALREADY,
Message: "already unwaited",
}
s.waitOnce.Do(func() {
s.logger.Info("Control socket un-waited")
s.waitGroup.Done()
e = pb.Success
})
return e, nil
}
func (s *Server) Shutdown(ctx context.Context, params *pb.ShutdownParams) (*pb.Error, error) {
// Notify main loop
s.Requests <- params
return pb.Success, nil
}
func (s *Server) SyncInterfaces(ctx context.Context, params *pb.SyncInterfaceParams) (*pb.Error, error) {
// Notify main loop
s.Requests <- params
return pb.Success, nil
}
func (s *Server) SyncConfig(ctx context.Context, params *pb.SyncConfigParams) (*pb.Error, error) {
return &pb.Error{
Code: pb.Error_ENOTSUP,
Message: "not implemented yet",
}, nil
}

View File

@@ -1,7 +1,6 @@
package socket package socket
import ( import (
"context"
"sync" "sync"
"go.uber.org/zap" "go.uber.org/zap"
@@ -19,6 +18,8 @@ type Server struct {
listener net.Listener listener net.Listener
grpc *grpc.Server grpc *grpc.Server
Requests chan interface{}
eventListeners map[chan *pb.Event]interface{} eventListeners map[chan *pb.Event]interface{}
eventListenersLock sync.Mutex eventListenersLock sync.Mutex
@@ -47,6 +48,7 @@ func Listen(network string, address string, wait bool) (*Server, error) {
logger: logger, logger: logger,
grpc: grpc.NewServer(), grpc: grpc.NewServer(),
eventListeners: map[chan *pb.Event]interface{}{}, eventListeners: map[chan *pb.Event]interface{}{},
Requests: make(chan interface{}),
} }
pb.RegisterSocketServer(s.grpc, s) pb.RegisterSocketServer(s.grpc, s)
@@ -78,36 +80,3 @@ func (s *Server) BroadcastEvent(e *pb.Event) error {
return nil return nil
} }
func (s *Server) GetStatus(ctx context.Context, _ *pb.Void) (*pb.Status, error) {
return &pb.Status{}, nil
}
func (s *Server) StreamEvents(_ *pb.Void, stream pb.Socket_StreamEventsServer) error {
ch := make(chan *pb.Event, 100)
s.eventListenersLock.Lock()
s.eventListeners[ch] = nil
s.eventListenersLock.Unlock()
for evt := range ch {
stream.Send(evt)
}
return nil
}
func (s *Server) UnWait(context.Context, *pb.Void) (*pb.Error, error) {
var e = &pb.Error{
Ok: false,
Error: "already unwaited",
}
s.waitOnce.Do(func() {
s.logger.Info("Control socket un-waited")
s.waitGroup.Done()
e = &pb.Ok
})
return e, nil
}