hkpserver

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseRoute   = "/"
	AddRoute    = "/pks/add"
	LookupRoute = "/pks/lookup"
)
View Source
const (
	DefaultAddr = "localhost:11371"
)

Variables

This section is empty.

Functions

func LogRequestHandler

func LogRequestHandler(h http.Handler) http.Handler

LogRequestHandler provides an HTTP handler to log HTTP requests.

func Start

func Start(ctx context.Context, cfg Config) error

Start starts HKP server with the corresponding server configuration.

func WriteIndex

func WriteIndex(w io.Writer, el openpgp.EntityList) error

WriteIndex writes on w a readable index based on the entity list provided. The index format follows the one described in the HKP draft https://tools.ietf.org/html/draft-shaw-openpgp-hkp-00#section-5.2

Types

type Config

type Config struct {
	Addr             string
	PublicPem        string
	PrivatePem       string
	DB               database.Engine
	Verifier         Verifier
	CustomHandler    func(http.Handler) http.Handler
	MaxHeaderBytes   int
	MaxBodyBytes     int64
	KeyPushRateLimit RateLimit
}

type Error

type Error struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

Error describes an error with code and message.

type ErrorResponse

type ErrorResponse struct {
	Error *Error `json:"error"`
}

ErrorResponse describes a JSON error response.

type RateLimit

type RateLimit string

func (RateLimit) Parse

func (r RateLimit) Parse() (int, int, error)

type Status

type Status interface {
	Is(int) bool
	IsError() bool
	Write(http.ResponseWriter)
}

func NewAcceptedStatus

func NewAcceptedStatus(message ...string) Status

func NewBadRequestStatus

func NewBadRequestStatus(message ...string) Status

func NewConflictStatus

func NewConflictStatus(message ...string) Status

func NewForbiddenStatus

func NewForbiddenStatus(message ...string) Status

func NewInternalServerErrorStatus

func NewInternalServerErrorStatus(message ...string) Status

func NewMethodNotAllowedStatus

func NewMethodNotAllowedStatus(message ...string) Status

func NewNotFoundStatus

func NewNotFoundStatus(message ...string) Status

func NewNotImplementedStatus

func NewNotImplementedStatus(message ...string) Status

func NewOKStatus

func NewOKStatus(message ...string) Status

func NewStatus

func NewStatus(code int, isError bool, message ...string) Status

func NewTooManyRequestStatus

func NewTooManyRequestStatus(message ...string) Status

type Verifier

type Verifier interface {
	Init(database.Engine, *http.ServeMux) error
	Verify(openpgp.EntityList, *http.Request) (openpgp.EntityList, Status)
}

Verifier is the key verifier interface allowing HKP to reject/accept keys based on custom criteria.

Jump to

Keyboard shortcuts

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