fsd

package
v0.0.0-...-c0900f9 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CallsignInUseError                       = 1  // Callsign is already in use
	CallsignInvalidError                     = 2  // Callsign is invalid
	AlreadyRegisteredError                   = 3  // Client is already registered
	SyntaxError                              = 4  // Packet syntax is invalid
	SourceInvalidError                       = 5  // Packet source is invalid
	InvalidLogonError                        = 6  // Login credentials or token are invalid
	NoSuchCallsignError                      = 7  // Specified callsign does not exist
	NoFlightPlanError                        = 8  // No flight plan found for the Client
	NoWeatherProfileError                    = 9  // No weather profile available
	InvalidProtocolRevisionError             = 10 // Client uses an unsupported protocol version
	RequestedLevelTooHighError               = 11 // Requested access level is too high
	ServerFullError                          = 12 // Server has reached capacity
	CertificateSuspendedError                = 13 // Client's certificate is suspended
	InvalidControlError                      = 14 // Invalid control command
	InvalidPositionForRatingError            = 15 // Position not allowed for Client's rating
	UnauthorizedSoftwareError                = 16 // Client software is not authorized
	ClientAuthenticationResponseTimeoutError = 17 // Authentication response timed out
)

FSD error codes

Variables

View Source
var ErrCallsignDoesNotExist = errors.New("callsign does not exist")
View Source
var ErrCallsignInUse = errors.New("callsign in use")
View Source
var ErrInvalidAddPacket = errors.New("invalid add packet")

ErrInvalidAddPacket is returned when the add packet from the Client is invalid.

View Source
var ErrInvalidIDPacket = errors.New("invalid ID packet")

ErrInvalidIDPacket is returned when the ID packet from the Client is invalid.

View Source
var ErrUnsupportedAuthClient = errors.New("vatsimauth: unsupported client")

Functions

func MakeJwtToken

func MakeJwtToken(customFields *CustomFields, validityDuration time.Duration) (token *jwt.Token, err error)

Types

type Client

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

type CustomClaims

type CustomClaims struct {
	jwt.RegisteredClaims
	CustomFields
}

type CustomFields

type CustomFields struct {
	TokenType     string        `json:"token_type"`
	CID           int           `json:"cid"`
	FirstName     string        `json:"first_name,omitempty"`
	LastName      string        `json:"last_name,omitempty"`
	NetworkRating NetworkRating `json:"network_rating"`
}

type JwtToken

type JwtToken struct {
	*jwt.Token
}

func ParseJwtToken

func ParseJwtToken(rawToken string, secretKey []byte) (token *JwtToken, err error)

func (*JwtToken) CustomClaims

func (t *JwtToken) CustomClaims() *CustomClaims

type LatLon

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

type NetworkRating

type NetworkRating int
const (
	NetworkRatingInactive NetworkRating = iota - 1
	NetworkRatingSuspended
	NetworkRatingObserver
	NetworkRatingStudent1
	NetworkRatingStudent2
	NetworkRatingStudent3
	NetworkRatingController1
	NetworkRatingController2
	NetworkRatingController3
	NetworkRatingInstructor1
	NetworkRatingInstructor2
	NetworkRatingInstructor3
	NetworkRatingSupervisor
	NetworkRatingAdministator
)

type OnlineUserATC

type OnlineUserATC struct {
	OnlineUserGeneralData
	Frequency string `json:"frequency"`
	Facility  int    `json:"facility"`
	VisRange  int    `json:"visual_range"`
}

type OnlineUserGeneralData

type OnlineUserGeneralData struct {
	Callsign         string    `json:"callsign"`
	CID              int       `json:"cid"`
	Name             string    `json:"name"`
	NetworkRating    int       `json:"network_rating"`
	MaxNetworkRating int       `json:"max_network_rating"`
	Latitude         float64   `json:"latitude"`
	Longitude        float64   `json:"longitude"`
	LogonTime        time.Time `json:"logon_time"`
	LastUpdated      time.Time `json:"last_updated"`
}

type OnlineUserPilot

type OnlineUserPilot struct {
	OnlineUserGeneralData
	Altitude    int    `json:"altitude"`
	Groundspeed int    `json:"groundspeed"`
	Heading     int    `json:"heading"`
	Transponder string `json:"transponder"`
}

type OnlineUsersResponseData

type OnlineUsersResponseData struct {
	Pilots []OnlineUserPilot `json:"pilots"`
	ATC    []OnlineUserATC   `json:"atc"`
}

type PacketType

type PacketType int
const (
	PacketTypeUnknown PacketType = iota
	PacketTypeTextMessage
	PacketTypePilotPosition
	PacketTypePilotPositionFast
	PacketTypePilotPositionSlow
	PacketTypePilotPositionStopped
	PacketTypeATCPosition
	PacketTypeDeleteATC
	PacketTypeDeletePilot
	PacketTypeClientQuery
	PacketTypeClientQueryResponse
	PacketTypeProController
	PacketTypeSquawkbox
	PacketTypeMetarRequest
	PacketTypeKillRequest
	PacketTypeAuthChallenge
	PacketTypeHandoffRequest
	PacketTypeHandoffAccept
	PacketTypeFlightPlan
	PacketTypeFlightPlanAmendment
)

type Server

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

func NewDefaultServer

func NewDefaultServer(ctx context.Context) (server *Server, err error)

NewDefaultServer creates a new Server instance using the default configuration obtained via environment variables

func NewServer

func NewServer(cfg *ServerConfig, dbRepo *db.Repositories, numMetarWorkers int) (server *Server, err error)

NewServer creates a new Server instance.

See NewDefaultServer to create a server using default settings obtained via environment variables.

func (*Server) Run

func (s *Server) Run(ctx context.Context) (err error)

type ServerConfig

type ServerConfig struct {
	FsdListenAddrs []string `env:"FSD_LISTEN_ADDRS, default=:6809"` // FSD listen addresses

	DatabaseDriver      string `env:"DATABASE_DRIVER, default=sqlite"`        // Golang sql database driver name
	DatabaseSourceName  string `env:"DATABASE_SOURCE_NAME, default=:memory:"` // Golang sql database source name
	DatabaseAutoMigrate bool   `env:"DATABASE_AUTO_MIGRATE, default=false"`   // Whether to automatically run database migrations on startup
	DatabaseMaxConns    int    `env:"DATABASE_MAX_CONNS, default=1"`          // Max number of database connections

	NumMetarWorkers int `env:"NUM_METAR_WORKERS, default=4"` // Number of METAR fetch workers to run

	ServiceHTTPListenAddr string `env:"SERVICE_HTTP_LISTEN_ADDR, default=:13618"`
}

Jump to

Keyboard shortcuts

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