rpc

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BuildInfo = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Name: "doublezero_qaagent_build_info",
		Help: "Build information of the QA agent",
	},
		[]string{"version", "commit", "date"},
	)

	PingPacketsLostTotal = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "doublezero_qaagent_ping_packets_lost_total",
		Help: "Total number of packets lost during ping tests",
	},
		[]string{"source_ip", "target_ip"},
	)

	UserConnectDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "doublezero_qaagent_user_connect_duration_seconds",
		Help:    "Duration of connect operations",
		Buckets: prometheus.ExponentialBuckets(1, 1.5, 12),
	}, []string{"user_type"})

	UserDisconnectDuration = promauto.NewHistogram(prometheus.HistogramOpts{
		Name:    "doublezero_qaagent_user_disconnect_duration_seconds",
		Help:    "Duration of disconnect operations",
		Buckets: prometheus.ExponentialBuckets(1, 1.5, 12),
	})
)

Functions

This section is empty.

Types

type Joiner

type Joiner interface {
	JoinGroup(ctx context.Context, group net.IP, port string, ifName string) error
	Stop()
	GetStatistics(net.IP) uint64
}

type MyTracerouteHub added in v0.7.2

type MyTracerouteHub struct {
	Count   uint32  `json:"count"`
	Host    string  `json:"host"`
	LossPct float32 `json:"Loss%"`
	Sent    uint32  `json:"Snt"`
	Last    float32 `json:"Last"`
	Avg     float32 `json:"Avg"`
	Best    float32 `json:"Best"`
	Worst   float32 `json:"Wrst"`
	StdDev  float32 `json:"StDev"`
}

type MyTracerouteMTR added in v0.7.2

type MyTracerouteMTR struct {
	Src   string `json:"src"`
	Dst   string `json:"dst"`
	Tests uint32 `json:"tests"`
}

type MyTracerouteReport added in v0.7.2

type MyTracerouteReport struct {
	MTR  MyTracerouteMTR   `json:"mtr"`
	Hubs []MyTracerouteHub `json:"hubs"`
}

type MyTracerouteResult added in v0.7.2

type MyTracerouteResult struct {
	Report MyTracerouteReport `json:"report"`
}
type Netlink struct{}

func (*Netlink) RouteByProtocol added in v0.7.2

func (d *Netlink) RouteByProtocol(protocol int) ([]Route, error)

func (*Netlink) RouteGet added in v0.7.2

func (d *Netlink) RouteGet(dest net.IP) ([]Route, error)

type Netlinker added in v0.7.2

type Netlinker interface {
	RouteGet(src net.IP) ([]Route, error)
	RouteByProtocol(protocol int) ([]Route, error)
}

type Option

type Option func(*QAAgent)

func WithDZClient added in v0.7.2

func WithDZClient(client *http.Client) Option

func WithDZStatusURL added in v0.7.2

func WithDZStatusURL(url string) Option

func WithJoiner added in v0.7.2

func WithJoiner(j Joiner) Option

func WithNetlinker added in v0.7.2

func WithNetlinker(n Netlinker) Option

type QAAgent

type QAAgent struct {
	pb.UnimplementedQAAgentServiceServer
	// contains filtered or unexported fields
}

func NewQAAgent

func NewQAAgent(logger *slog.Logger, addr string, opts ...Option) (*QAAgent, error)

NewQAAgent creates a new QAAgent instance. It accepts an address (i.e. localhost:443) to listen on and a Joiner interface for managing multicast group joins.

func (*QAAgent) ConnectMulticast

func (q *QAAgent) ConnectMulticast(ctx context.Context, req *pb.ConnectMulticastRequest) (*pb.Result, error)

ConnectMulticast implements the ConnectMulticast RPC, which connects to a multicast group as either a publisher or subscriber. This call will block until the tunnel is up according to the DoubleZero status output or return an error if the tunnel is not up within 60 seconds.

func (*QAAgent) ConnectUnicast

func (q *QAAgent) ConnectUnicast(ctx context.Context, req *pb.ConnectUnicastRequest) (*pb.Result, error)

ConnectUnicast implements the ConnectUnicast RPC. This establishes a unicast tunnel to DoubleZero using IBRL mode. This call will block until the tunnel is up according to the DoubleZero status output or return an error if the tunnel is not up within 20 seconds.

func (*QAAgent) CreateMulticastGroup

func (q *QAAgent) CreateMulticastGroup(ctx context.Context, req *pb.CreateMulticastGroupRequest) (*pb.Result, error)

CreateMulticastGroup implements the CreateMulticastGroup RPC, which creates a multicast group with the specified code and maximum bandwidth.

func (*QAAgent) DeleteMulticastGroup

func (q *QAAgent) DeleteMulticastGroup(ctx context.Context, req *pb.DeleteMulticastGroupRequest) (*pb.Result, error)

DeleteMulticastGroup implements the DeleteMulticastGroup RPC, which deletes a multicast group by its public key.

func (*QAAgent) Disconnect

func (q *QAAgent) Disconnect(ctx context.Context, req *emptypb.Empty) (*pb.Result, error)

Disconnect implements the Disconnect RPC, which removes the current tunnel from DoubleZero.

func (*QAAgent) GetPublicIP added in v0.7.2

func (q *QAAgent) GetPublicIP(ctx context.Context, req *emptypb.Empty) (*pb.GetPublicIPResponse, error)

func (*QAAgent) GetRoutes added in v0.7.2

func (q *QAAgent) GetRoutes(ctx context.Context, req *emptypb.Empty) (*pb.GetRoutesResponse, error)

GetRoutes implements the GetRoutes RPC, which retrieves the installed routes in the kernel routing table.

func (*QAAgent) GetStatus

func (q *QAAgent) GetStatus(ctx context.Context, req *emptypb.Empty) (*pb.StatusResponse, error)

GetStatus implements the GetStatus RPC, which retrieves the current status of the configured DoubleZero tunnel. This is equivalent to the `doublezero status` command.

func (*QAAgent) MulticastAllowListAdd

func (q *QAAgent) MulticastAllowListAdd(ctx context.Context, req *pb.MulticastAllowListAddRequest) (*pb.Result, error)

MulticastAllowListAdd implements the MulticastAllowListAdd RPC, which adds a publisher or subscriber to the multicast allowlist for a specific group.

func (*QAAgent) MulticastJoin

func (q *QAAgent) MulticastJoin(ctx context.Context, req *pb.MulticastJoinRequest) (*pb.MulticastJoinResult, error)

MulticastJoin implements the MulticastJoin RPC, joins the requested multicast group and counts received packets per joined group. Use the GetStatistics RPC to retrieve the stats.

func (*QAAgent) MulticastLeave

func (q *QAAgent) MulticastLeave(ctx context.Context, in *emptypb.Empty) (*emptypb.Empty, error)

MulticastLeave implements the MulticastLeave RPC and stops listening to all multicast groups.

func (*QAAgent) MulticastReport

func (q *QAAgent) MulticastReport(ctx context.Context, req *pb.MulticastReportRequest) (*pb.MulticastReportResult, error)

MulticastReport implements the MulticastReport RPC, which retrieves statistics for multicast groups that the agent is currently listening to. It returns the number of packets received for each group.

func (*QAAgent) MulticastSend

func (q *QAAgent) MulticastSend(ctx context.Context, req *pb.MulticastSendRequest) (*emptypb.Empty, error)

MulticastSend implements the MulticastSend RPC, which sends multicast packets to a specified group for a given duration.

func (*QAAgent) Ping

func (q *QAAgent) Ping(ctx context.Context, req *pb.PingRequest) (*pb.PingResult, error)

Ping implements the Ping RPC, executes a set of ICMP pings, and reports the results to the caller. This requires CAP_NET_RAW capability to run successfully due to the use of raw sockets.

func (*QAAgent) Start

func (q *QAAgent) Start(ctx context.Context) error

Start starts the QAAgent and blocks until the context is done or an error occurs.

func (*QAAgent) Traceroute added in v0.7.2

func (q *QAAgent) Traceroute(ctx context.Context, req *pb.TracerouteRequest) (*pb.TracerouteResult, error)

Traceroute implements the Traceroute RPC, which traces the route to the target IP, and returns the results.

func (*QAAgent) TracerouteRaw added in v0.7.2

func (q *QAAgent) TracerouteRaw(ctx context.Context, req *pb.TracerouteRequest) (*pb.Result, error)

TracerouteRaw implements the TracerouteRaw RPC, which traces the route to the target IP, and returns the raw output.

type Route added in v0.7.2

type Route struct {
	Dst *net.IPNet
	Src net.IP
	Gw  net.IP
}

type StatusResponse

type StatusResponse struct {
	Response struct {
		TunnelName       string `json:"tunnel_name"`
		TunnelSrc        string `json:"tunnel_src"`
		TunnelDst        string `json:"tunnel_dst"`
		DoubleZeroIP     string `json:"doublezero_ip"`
		UserType         string `json:"user_type"`
		DoubleZeroStatus struct {
			SessionStatus     string `json:"session_status"`
			LastSessionUpdate int64  `json:"last_session_update"`
		} `json:"doublezero_status"`
	} `json:"response"`
	CurrentDevice       string `json:"current_device"`
	LowestLatencyDevice string `json:"lowest_latency_device"`
	Metro               string `json:"metro"`
	Network             string `json:"network"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL