Documentation ¶
Index ¶
- func AuthTokens(tokens ...string) func(http.Handler) http.Handler
- func Logger(next jsonrpc.Handler) jsonrpc.Handler
- func PreventReferer(next http.Handler) http.Handler
- type Server
- func (s *Server) AddPeer(ctx context.Context, req *client.AddPeerRequest) (*client.AddPeerResponse, error)
- func (s *Server) GetDeviceInfo(ctx context.Context, req *client.GetDeviceInfoRequest) (*client.GetDeviceInfoResponse, error)
- func (s *Server) GetPeer(ctx context.Context, req *client.GetPeerRequest) (*client.GetPeerResponse, error)
- func (s *Server) ListPeers(ctx context.Context, req *client.ListPeersRequest) (*client.ListPeersResponse, error)
- func (s *Server) RemovePeer(ctx context.Context, req *client.RemovePeerRequest) (*client.RemovePeerResponse, error)
- func (s *Server) ServeJSONRPC(w jsonrpc.ResponseWriter, r *jsonrpc.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthTokens ¶
AuthTokens only allows a request to continue if one of the pre-configured tokens is provided by the client in the Authorization header, otherwise a HTTP 403 Forbidden is returned and the request terminated.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the host-side implementation of the WG-API Client. It supports both Kernel and Userland implementations of WireGuard.
func (*Server) AddPeer ¶
func (s *Server) AddPeer(ctx context.Context, req *client.AddPeerRequest) (*client.AddPeerResponse, error)
AddPeer inserts a new Peer into the WireGuard interfaces table, multiple calls to AddPeer can be used to update details of the Peer.
func (*Server) GetDeviceInfo ¶
func (s *Server) GetDeviceInfo(ctx context.Context, req *client.GetDeviceInfoRequest) (*client.GetDeviceInfoResponse, error)
GetDeviceInfo returns information such as the public key and type of interface for the currently configured device.
func (*Server) GetPeer ¶
func (s *Server) GetPeer(ctx context.Context, req *client.GetPeerRequest) (*client.GetPeerResponse, error)
GetPeer retrieves a specific Peer by their public key.
func (*Server) ListPeers ¶
func (s *Server) ListPeers(ctx context.Context, req *client.ListPeersRequest) (*client.ListPeersResponse, error)
ListPeers retrieves information about all Peers known to the current WireGuard interface, including allowed IP addresses and usage stats, optionally with pagination.
func (*Server) RemovePeer ¶
func (s *Server) RemovePeer(ctx context.Context, req *client.RemovePeerRequest) (*client.RemovePeerResponse, error)
RemovePeer deletes a Peer from the WireGuard interfaces table by their public key,
func (*Server) ServeJSONRPC ¶
func (s *Server) ServeJSONRPC(w jsonrpc.ResponseWriter, r *jsonrpc.Request)
ServeJSONRPC handles incoming WG-API requests.