server

package
v0.0.0-...-dc54953 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthTokens

func AuthTokens(tokens ...string) func(http.Handler) http.Handler

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.

func Logger

func Logger(next jsonrpc.Handler) jsonrpc.Handler

Logger logs JSON-RPC requests.

func PreventReferer

func PreventReferer(next http.Handler) http.Handler

PreventReferer blocks any request that contains a Referer or Origin header, as this would indicate a web browser is submitting the request and this server should NOT be directly accessible that way.

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 NewServer

func NewServer(wg *wgctrl.Client, deviceName string) (*Server, error)

NewServer initializes a Server with a WireGuard client.

func (*Server) AddPeer

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

GetDeviceInfo returns information such as the public key and type of interface for the currently configured device.

func (*Server) GetPeer

GetPeer retrieves a specific Peer by their public key.

func (*Server) ListPeers

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

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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