Documentation
¶
Overview ¶
Package serviceauthority verifies account authority records without I/O.
Index ¶
- Constants
- Variables
- func Compare(previous, next Generation) error
- func DecodeBase64(value string, limit int) ([]byte, error)
- func PublicKey(value string) ([32]byte, error)
- func VerifySigned(domain, encoded string, key [32]byte, limit int) ([]byte, error)
- type AdmissionState
- type Allowance
- type Descriptor
- type Entitlement
- type Generation
- type RegistrationAuthorization
- type RegistrationDelivery
- type RegistrationReservation
- type Ticket
Constants ¶
const ( CertificateDomain = "windshare/authority-certificate/v1\x00" TicketDomain = "windshare/account-ticket/v1\x00" DescriptorDomain = "windshare/node-descriptor/v2\x00" BlocksDomain = "windshare/public-blocks/v1\x00" MaximumTicketBytes = 512 MaximumDescriptorBytes = 16 << 10 MaximumResponseBytes = 512 << 10 MaximumCounter = 1<<53 - 1 DaySeconds = 86400 ClockSkew = 300 TicketLifetime = 12 * 60 * 60 EntitlementLifetime = 5 * 60 CertificateLifetime = 180 * DaySeconds )
Variables ¶
Functions ¶
func Compare ¶
func Compare(previous, next Generation) error
Compare is independent of wall time: expiry never erases the rollback barrier.
Types ¶
type AdmissionState ¶
type AdmissionState uint8
const ( AdmissionReady AdmissionState = iota + 1 AdmissionPendingSetup AdmissionExpired AdmissionTemporaryFailure AdmissionDenied AdmissionUserActionRequired AdmissionPendingAttribution )
func (AdmissionState) Name ¶
func (state AdmissionState) Name() string
type Descriptor ¶
type Descriptor struct {
Version int `json:"version"`
NodeID string `json:"node_id"`
NodeKey string `json:"node_key"`
RelayEndpoint string `json:"relay_endpoint"`
Services struct {
Relay bool `json:"relay"`
STUN bool `json:"stun"`
} `json:"services"`
STUN []string `json:"stun"`
Zone string `json:"zone"`
Region string `json:"region"`
Capacity *uint64 `json:"capacity_bytes_per_second"`
Classes []string `json:"classes"`
IssuedAt uint64 `json:"issued_at"`
ExpiresAt uint64 `json:"expires_at"`
Available bool `json:"relay_available"`
Anonymous bool `json:"anonymous"`
ConsoleURL string `json:"console_url"`
AccountLoginPage string `json:"account_login_page,omitempty"`
}
func InspectDescriptor ¶
func InspectDescriptor(data []byte, now time.Time) (Descriptor, error)
InspectDescriptor verifies a self-asserted identity for manual enrollment. Official admission must still pin that key with VerifyDescriptor.
func VerifyDescriptor ¶
func (Descriptor) RelayBaseURL ¶
func (descriptor Descriptor) RelayBaseURL() string
RelayBaseURL is for APIs that append their protocol path. The signed descriptor carries the complete canonical WebSocket endpoint, never an ambiguous base.
type Entitlement ¶
type Entitlement struct {
Version uint64 `json:"version"`
Day uint64 `json:"day"`
ValidUntil uint64 `json:"valid_until"`
RemainingBytes uint64 `json:"remaining_bytes"`
}
func Advance ¶
func Advance(previous, next Entitlement) Entitlement
func (Entitlement) ResetAt ¶
func (value Entitlement) ResetAt() time.Time
func (Entitlement) ValidSnapshot ¶
func (value Entitlement) ValidSnapshot(issued uint64) bool
type Generation ¶
type Generation struct {
Issuer [32]byte
Number uint64
Key [32]byte
NotBefore uint64
ExpiresAt uint64
}
func VerifyGeneration ¶
func VerifyGeneration(certificate string, root [32]byte) (Generation, error)
type RegistrationAuthorization ¶
type RegistrationAuthorization struct {
State AdmissionState
Bearer string `json:"-"`
Changed <-chan struct{} `json:"-"`
Cause error `json:"-"`
Reservation RegistrationReservation `json:"-"`
}
A waiting RegistrationAuthorization and its Changed signal describe the same revision so progress cannot be missed while starting a wait.
type RegistrationDelivery ¶ added in v0.1.4
type RegistrationDelivery uint8
const ( RegistrationMayHaveBeenSent RegistrationDelivery = iota RegistrationNotSent )
type RegistrationReservation ¶ added in v0.1.4
type RegistrationReservation func(RegistrationDelivery)
A RegistrationReservation pins attribution for one ready attempt. Settle it with the dial result before applying any local cancellation or admission policy.
func (RegistrationReservation) Finish ¶ added in v0.1.4
func (reservation RegistrationReservation) Finish(delivery RegistrationDelivery)