server

package
v0.0.0-...-a727419 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	*fastws.Conn
}

func (*Connection) RecvHello

func (c *Connection) RecvHello() (*string, *string, error)

func (*Connection) SendFinalAck

func (c *Connection) SendFinalAck(sessionID string, hmacSeed int64) error

func (*Connection) SendHello

func (c *Connection) SendHello(payload []byte) error

type LicenseHolders

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

type LicenseMsg

type LicenseMsg struct {
	IntegritySignature string `json:"integrity_signature"`
	Fingerprint        string `json:"fingerprint"`
	AppID              string `json:"app_id"`
	OwnerID            string `json:"owner_id"`
	LicenseKey         string `json:"license_key"`
}

type NewApplicationMsg

type NewApplicationMsg struct {
	OwnerID string `json:"owner_id"`
	Name    string `json:"name"`
}

type NewLicenseMsg

type NewLicenseMsg struct {
	OwnerID       string `json:"owner_id"`
	Expiry        uint64 `json:"expiry"`
	AppID         string `json:"app_id"`
	AppName       string `json:"name"`
	Mask          string `json:"mask,omitempty"`
	OnlyCapitals  bool   `json:"include_capitals,omitempty"`
	OnlyLowercase bool   `json:"include_lowercase,omitempty"`
}

type Route

type Route struct {
	Method     string
	Path       string
	Func       fiber.Handler
	Restricted bool
}

type Server

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

func NewServer

func NewServer(dbCtx context.Context, rdb *redis.Connection, jwtSecret []byte) *Server

func (*Server) Bind

func (s *Server) Bind()

func (*Server) Clean

func (s *Server) Clean() error

func (*Server) ClientHello

func (s *Server) ClientHello(conn *fastws.Conn) error

ClientHello preforms a DHE and registers a new session if successful.

func (*Server) CreateApplication

func (s *Server) CreateApplication(c fiber.Ctx) error

CreateApplication creates a new application and dumps it in the database ! Most of these endpoints don't need to be encrypted. * If it's ever going to be used in production, it's probably a good idea to remove the encryption.

func (*Server) CreateLicense

func (s *Server) CreateLicense(c fiber.Ctx) error

CreateLicense creates a new license and dumps it in the database

func (*Server) DefaultOptions

func (s *Server) DefaultOptions()

func (*Server) EncryptJson

func (s *Server) EncryptJson(c fiber.Ctx, plainText any, session *Session) error

func (*Server) ErrorHandler

func (s *Server) ErrorHandler(c fiber.Ctx, errResp error) error

func (*Server) GenerateKeyPair

func (s *Server) GenerateKeyPair(username string, admin int8) (*fiber.Map, error)

func (*Server) IntegrityMiddleware

func (s *Server) IntegrityMiddleware(c fiber.Ctx, body []byte) error

func (*Server) Login

func (s *Server) Login(c fiber.Ctx) error

Login will authenticate an account via JWT

func (*Server) Logout

func (s *Server) Logout(c fiber.Ctx) error

Logout will delete the refresh token from the database

func (*Server) NewOwner

func (s *Server) NewOwner(c fiber.Ctx) error

Admin only route

func (*Server) ParseBody

func (s *Server) ParseBody(c fiber.Ctx) (*Session, []byte, error)

func (*Server) RefreshAccessToken

func (s *Server) RefreshAccessToken(c fiber.Ctx) error

func (*Server) Register

func (s *Server) Register(c fiber.Ctx) error

Register will create a new account

func (*Server) ServeHello

func (s *Server) ServeHello(conn *fastws.Conn)

func (*Server) ServerOptions

func (s *Server) ServerOptions(e ...fiber.Handler)

func (*Server) Start

func (s *Server) Start(port string) error

func (*Server) VerifyLicense

func (s *Server) VerifyLicense(c fiber.Ctx) error

VerifyLicense will verify the license against the database. We use Session based authentication instead of JWT because this should be treated as a one-time-use token. There will be no need to do anything after this process. If you would like to verify a license another time, it is much more secure to just create another session instead.

type Session

type Session struct {
	PrivateKey [32]byte `json:"private_key" redis:"private_key"`
	HashKey    [32]byte `json:"hash_key" redis:"hash_key"`
	Nonce      [12]byte `json:"nonce" redis:"nonce"`
}

func FromMap

func FromMap(m fiber.Map) *Session

type SterlizedSession

type SterlizedSession struct {
	PrivateKey string `json:"private_key" redis:"private_key"`
	HashKey    string `json:"hash_key" redis:"hash_key"`
	Nonce      string `json:"nonce" redis:"nonce"`
}

type UserJWT

type UserJWT struct {
	Username string  `json:"username"`
	Exp      float64 `json:"exp"`
	Admin    int8    `json:"admin"`
}

type UserMsg

type UserMsg struct {
	APIKey   string `json:"api_key,omitempty"`
	Username string `json:"username"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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