server

package
v0.0.0-...-c06769b Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidMonitorDNSName

func IsValidMonitorDNSName(name string) bool

IsValidMonitorDNSName validates DNS names for monitor certificates Monitor names are always 5 parts: host.environment.mon.ntppool.dev

func NewConnectServer

func NewConnectServer(srv *Server) *conServer

func NewLoggingServerHooks

func NewLoggingServerHooks() *twirp.ServerHooks

func WithLogger

func WithLogger(h http.Handler, l *slog.Logger) http.Handler

func WithUserAgent

func WithUserAgent(base http.Handler) http.Handler

Types

type AuthMethod

type AuthMethod string

AuthMethod represents the authentication method used

const (
	AuthMethodMTLS AuthMethod = "mtls"
	AuthMethodJWT  AuthMethod = "jwt"
)

type Config

type Config struct {
	DeploymentEnv depenv.DeploymentEnvironment
	Listen        string
	JWTKey        string
	CertProvider  apitls.AuthProvider
}

type CounterOpt

type CounterOpt struct {
	Name    string
	Counter int
}

type JWTAuthenticator

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

JWTAuthenticator handles JWT token validation using JWKS

func NewJWTAuthenticator

func NewJWTAuthenticator(ctx context.Context, deploymentEnv depenv.DeploymentEnvironment) (*JWTAuthenticator, error)

NewJWTAuthenticator creates a new JWT authenticator with JWKS support

func (*JWTAuthenticator) Close

func (j *JWTAuthenticator) Close()

Close closes the JWKS client

func (*JWTAuthenticator) ValidateToken

func (j *JWTAuthenticator) ValidateToken(ctx context.Context, tokenString string) (*JWTClaims, error)

ValidateToken validates a JWT token and returns the claims

type JWTClaims

type JWTClaims struct {
	jwt.RegisteredClaims
	Monitor string `json:"monitor,omitempty"`
	Scope   string `json:"scope,omitempty"`
}

JWTClaims represents the expected JWT claims structure

type MonitorSettings

type MonitorSettings struct {
	IntervalActive  timeutil.Duration `json:"interval_active"`
	IntervalTesting timeutil.Duration `json:"interval_testing"`
	IntervalAll     timeutil.Duration `json:"interval_all"`
	BatchSize       int32             `json:"batch_size"`
}

type Server

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

func NewServer

func NewServer(ctx context.Context, cfg Config, dbconn *sql.DB, promRegistry prometheus.Registerer) (*Server, error)

func (*Server) GetConfig

func (srv *Server) GetConfig(ctx context.Context, monIP string) (*ntpdb.MonitorConfig, error)

func (*Server) GetServers

func (srv *Server) GetServers(ctx context.Context, monID string) (*ServerListResponse, error)

func (*Server) Run

func (srv *Server) Run() error

func (*Server) SignIPs

func (srv *Server) SignIPs(monitorID uint32, batchID []byte, ip *netip.Addr) ([]byte, error)

func (*Server) SubmitResults

func (srv *Server) SubmitResults(ctx context.Context, in SubmitResultsParam, monIP string) (bool, error)

func (*Server) ValidateIPs

func (srv *Server) ValidateIPs(signature []byte, monitorID uint32, batchID []byte, ip *netip.Addr) (bool, error)

type ServerListResponse

type ServerListResponse struct {
	BatchID []byte
	Config  *ntpdb.MonitorConfig
	Servers []ntpdb.Server
	// contains filtered or unexported fields
}

type SubmitCounters

type SubmitCounters struct {
	Ok         *CounterOpt
	Offset     *CounterOpt
	Timeout    *CounterOpt
	Sig        *CounterOpt
	BatchOrder *CounterOpt
}

type SubmitResultsParam

type SubmitResultsParam struct {
	Version int32
	List    []*apiv2.ServerStatus
	BatchId []byte
}

type TwServer

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

func NewTwServer

func NewTwServer(srv *Server) *TwServer

func (*TwServer) GetConfig

func (s *TwServer) GetConfig(ctx context.Context, in *pb.GetConfigParams) (*pb.Config, error)

func (*TwServer) GetServers

func (s *TwServer) GetServers(ctx context.Context, in *pb.GetServersParams) (*pb.ServerList, error)

func (*TwServer) SubmitResults

func (s *TwServer) SubmitResults(ctx context.Context, in *pb.ServerStatusList) (*pb.ServerStatusResult, error)

Directories

Path Synopsis
twirp
Package prometheus is Twirp server hook that collects Prometheus metrics.
Package prometheus is Twirp server hook that collects Prometheus metrics.
http request to mqtt requests api
http request to mqtt requests api

Jump to

Keyboard shortcuts

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