Documentation ¶
Overview ¶
Package wgbind provides a WireGuard conn.Bind implementation that can be used to proxy wireguard packets over other connections.
Index ¶
- type ClientBind
- func (c *ClientBind) BatchSize() int
- func (c *ClientBind) Close() error
- func (c *ClientBind) Open(uint16) ([]conn.ReceiveFunc, uint16, error)
- func (c *ClientBind) ParseEndpoint(endpoint string) (conn.Endpoint, error)
- func (c *ClientBind) Send(bufs [][]byte, ep conn.Endpoint) error
- func (c *ClientBind) SetMark(uint32) error
- type Packet
- type PeerTraffic
- type QueuePair
- type ReceiveData
- type ServerBind
- func (b *ServerBind) BatchSize() int
- func (b *ServerBind) Close() error
- func (b *ServerBind) Open(port uint16) ([]conn.ReceiveFunc, uint16, error)
- func (b *ServerBind) ParseEndpoint(s string) (conn.Endpoint, error)
- func (b *ServerBind) Send(bufs [][]byte, ep conn.Endpoint) error
- func (b *ServerBind) SetMark(mark uint32) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientBind ¶
type ClientBind struct {
// contains filtered or unexported fields
}
ClientBind implements conn.Bind and is used to send and receive packets to and from the server over grpc connection. It is used on the "Talos" side.
func NewClientBind ¶
func NewClientBind(peerQueues *QueuePair, logger *zap.Logger) *ClientBind
NewClientBind creates a new ClientBind.
func (*ClientBind) Close ¶
func (c *ClientBind) Close() error
Close implements conn.Bind. It will close the context to unblock our own ReceiveFunc.
func (*ClientBind) Open ¶
func (c *ClientBind) Open(uint16) ([]conn.ReceiveFunc, uint16, error)
Open implements conn.Bind. It will use the peerQueues *QueuePair to receive packets from the handler.
func (*ClientBind) ParseEndpoint ¶
func (c *ClientBind) ParseEndpoint(endpoint string) (conn.Endpoint, error)
ParseEndpoint implements conn.Bind.
func (*ClientBind) Send ¶
func (c *ClientBind) Send(bufs [][]byte, ep conn.Endpoint) error
Send implements conn.Bind. It will use the peerQueues *QueuePair to send packets to the handler.
type PeerTraffic ¶
type PeerTraffic struct { FromPeers queue.Queue[ReceiveData] // contains filtered or unexported fields }
PeerTraffic is a struct that holds the traffic from peers and the traffic to peers. Essentially it's queue for packets to "server" and map of ring-queues for packets to "clients". It's used to communicate with the external handler to actually send and receive packets. It's used on the "Omni" side.
func NewPeerTraffic ¶
func NewPeerTraffic(maxFromPeers int) *PeerTraffic
NewPeerTraffic returns a new PeerTraffic with the given maxFromPeers - the number of maxiumum packets from peers that we can hold in our queue before blocking PeerTraffic.PushRecvData.
func (*PeerTraffic) GetSendQueue ¶
GetSendQueue returns the ring queue for the given address. If create is true, it will create a new queue if it doesn't exist. It's used to send packets to the "clients".
func (*PeerTraffic) PopRecvData ¶
func (p *PeerTraffic) PopRecvData(ctx context.Context) (ReceiveData, error)
PopRecvData pops a new ReceiveData from the queue. It will block until the message is popped or the context is done.
func (*PeerTraffic) PushRecvData ¶
func (p *PeerTraffic) PushRecvData(ctx context.Context, rd ReceiveData) error
PushRecvData pushes a new ReceiveData to the queue. It will block until the message is pushed or the context is done.
func (*PeerTraffic) RemoveQueue ¶
func (p *PeerTraffic) RemoveQueue(addr string)
RemoveQueue removes the queue for the given address. It's used to remove the queue for the "client" when it's disconnected.
type QueuePair ¶
type QueuePair struct { FromPeer queue.Queue[Packet] // FromPeer essentially is a queue of packets from the server. ToPeer *queue.RingQueue[Packet] // ToPeer essentially is a queue of packets to the server. }
QueuePair is a pair of queues for the client to communicate with the server. It is used on "Talos" side.
func NewQueuePair ¶
NewQueuePair creates a new QueuePair.
type ReceiveData ¶
type ReceiveData struct { Packet *pb.PeerPacket Addr string }
ReceiveData is a struct that holds the address and the packet received from the peer.
type ServerBind ¶
type ServerBind struct {
// contains filtered or unexported fields
}
ServerBind is a conn.Bind implementation that can be used on "omni" side to receive and send packets to Talos side over grpc.
func NewServerBind ¶
func NewServerBind(defaultConn conn.Bind, grpcPrefix netip.Prefix, pt *PeerTraffic, l *zap.Logger) *ServerBind
NewServerBind creates a new ServerBind. deflt is the default conn.Bind implementation that will be used for non-grpc traffic. grpcPrefix is the prefix that will be used to determine if the traffic should be sent over grpc. PeerTraffic allows for communication with external handler to actually send and receive packets.
func (*ServerBind) Close ¶
func (b *ServerBind) Close() error
Close implements conn.Bind. It will close the default conn.Bind and cancel the context to unblock our own ReceiveFuncs.
func (*ServerBind) Open ¶
func (b *ServerBind) Open(port uint16) ([]conn.ReceiveFunc, uint16, error)
Open implements conn.Bind. It will add a new ReceiveFunc that will receive packets from grpcPeers on top of the default ReceiveFuncs.
func (*ServerBind) ParseEndpoint ¶
func (b *ServerBind) ParseEndpoint(s string) (conn.Endpoint, error)
ParseEndpoint implements conn.Bind.