wggrpc

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package wggrpc provides a WireGuard over GRPC client and server implementation.

Index

Constants

View Source
const PeerAddrKey = "x-siderolink-ipv6-addr"

PeerAddrKey is the key used to store the peer address in the grpc context.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowedPeers

type AllowedPeers struct {
	// contains filtered or unexported fields
}

AllowedPeers is a list of allowed peers. Currently, PeerAddrKey netip.Addr value is used as a token.

func NewAllowedPeers

func NewAllowedPeers() *AllowedPeers

NewAllowedPeers creates a new allowed peers list.

func (*AllowedPeers) AddToken

func (p *AllowedPeers) AddToken(pubKey wgtypes.Key, token string)

AddToken adds the peer to the allowed list.

func (*AllowedPeers) CheckToken

func (p *AllowedPeers) CheckToken(token string) bool

CheckToken checks if the token is allowed.

func (*AllowedPeers) RemoveToken

func (p *AllowedPeers) RemoveToken(pubKey wgtypes.Key)

RemoveToken removes the peer from the allowed list.

type Relay

type Relay struct {
	// contains filtered or unexported fields
}

Relay is the client side of the WireGuard over GRPC relay.

func NewRelay

func NewRelay(conn *grpc.ClientConn, retryTimeout time.Duration, queues *wgbind.QueuePair, ourAddr netip.AddrPort) *Relay

NewRelay creates a new Relay.

func NewRelayToHost

func NewRelayToHost(host string, retryTimeout time.Duration, queues *wgbind.QueuePair, ourAddr netip.AddrPort, opts ...grpc.DialOption) (*Relay, error)

NewRelayToHost creates a new Relay.

func (*Relay) Close

func (r *Relay) Close()

Close closes the Relay.

func (*Relay) IsClosed

func (r *Relay) IsClosed() bool

IsClosed returns true if the Relay is closed.

func (*Relay) Run

func (r *Relay) Run(ctx context.Context, logger *zap.Logger) error

Run runs the Relay. It consumes and sends packets from|to the [*QueuePair].

type Service

type Service struct {
	pb.UnimplementedWireGuardOverGRPCServiceServer
	// contains filtered or unexported fields
}

Service is the gRPC service responsible for handling WireGuard over GRPC traffic.

func NewService

func NewService(pt *wgbind.PeerTraffic, allowed *AllowedPeers, logger *zap.Logger) *Service

NewService creates a new WireGuard over GRPC service.

func (*Service) CreateStream

CreateStream implements pb.WireGuardOverGRPCServiceServer.

func (*Service) Wait

func (s *Service) Wait()

Wait waits for all the service goroutines to finish.

Jump to

Keyboard shortcuts

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