Documentation ¶
Index ¶
- Constants
- Variables
- type AuthApp
- type AuthEphemeral
- type AuthNegotiate
- type AuthProof
- type Config
- type Database
- func (database *Database) AddUser(username string, email string, password string) (err error)
- func (database *Database) FindUser(username string) (user *User, err error)
- func (database *Database) Import(paths ...string) (err error)
- func (database *Database) LoginUser(username string, password string) (user *User, err error)
- type FormErrors
- type LoginData
- type LoginForm
- type Profile
- type ServerEphemeral
- type ServerNegotiate
- type ServerProof
- type SessionError
- type SessionErrorType
- type TemplateDefs
- type TemplateNames
- type User
- type WebApp
- func (webApp *WebApp) AddTemplateDefs(tmpls *TemplateDefs) (err error)
- func (webApp *WebApp) Home(res http.ResponseWriter, req *http.Request)
- func (webApp *WebApp) ListenAndServe(addr string) (err error)
- func (webApp *WebApp) Login(ctx context.Context, res http.ResponseWriter, req *http.Request)
- func (webApp *WebApp) RenderTemplate(res http.ResponseWriter, req *http.Request, name string, data interface{})
Constants ¶
const ( UserAccessUnverified string = "UNVERIFIED" UserAccessUser string = "USER" UserAccessOp string = "OP" UserAccessMaster string = "MASTER" UserAccessOwner string = "OWNER" )
User access constants.
const ( CharonServerNegotiate uint32 = 0xD003CA01 CharonAuthNegotiate uint32 = 0xD003CA10 CharonServerEphemeral uint32 = 0xD003CA02 CharonAuthEphemeral uint32 = 0xD003CA20 CharonServerProof uint32 = 0xD003CA03 CharonAuthProof uint32 = 0xD003CA30 CharonUserError uint32 = 0xD003CAFF CharonSessionError uint32 = 0xD003CAEE )
Protocol constants.
Variables ¶
var BaseTemplates = TemplateDefs{ "home": TemplateNames{"layout", "header", "home"}, "login": TemplateNames{"layout", "header", "login"}, }
BaseTemplates contains template definitions for the base routes.
Functions ¶
This section is empty.
Types ¶
type AuthApp ¶
type AuthApp struct {
// contains filtered or unexported fields
}
AuthApp contains all state for a single instance of the authentication server.
func NewAuthApp ¶
NewAuthApp creates a new instance of the auth server app.
func (*AuthApp) ListenAndServe ¶
ListenAndServe starts the auth server app.
type AuthEphemeral ¶
type AuthEphemeral struct {
// contains filtered or unexported fields
}
AuthEphemeral contains an SRP ephemeral value sent from the auth server to the game server.
func (*AuthEphemeral) MarshalBinary ¶
func (packet *AuthEphemeral) MarshalBinary() (data []byte, err error)
MarshalBinary marshalls an AuthEphemeral from binary data.
func (*AuthEphemeral) UnmarshalBinary ¶
func (packet *AuthEphemeral) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary unmarshalls an AuthEphemeral to binary data.
type AuthNegotiate ¶
type AuthNegotiate struct {
// contains filtered or unexported fields
}
AuthNegotiate is a connection negotiation packet that is sent from the auth server to the game server.
func (*AuthNegotiate) MarshalBinary ¶
func (packet *AuthNegotiate) MarshalBinary() (data []byte, err error)
MarshalBinary marshalls an AuthNegotiate from binary data.
func (*AuthNegotiate) UnmarshalBinary ¶
func (packet *AuthNegotiate) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary unmarshalls an AuthNegotiate to binary data.
type AuthProof ¶
type AuthProof struct {
// contains filtered or unexported fields
}
AuthProof contains a SRP proof value sent from the auth server to the game server.
func (*AuthProof) MarshalBinary ¶
MarshalBinary marshalls an AuthProof from binary data.
func (*AuthProof) UnmarshalBinary ¶
UnmarshalBinary unmarshalls an AuthProof to binary data.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is an instance of our database connection and all necessary state used to manage said instance.
func NewDatabase ¶
NewDatabase creates a new Database instance.
type FormErrors ¶
FormErrors contains a list of errors keyed on their struct names.
type LoginData ¶
type LoginData struct { Form *LoginForm Errors FormErrors }
LoginData contains the context for the Login page.
func NewLoginData ¶
NewLoginData creates a new LoginData that optionally contains prepopulated data from the request.
type Profile ¶
type Profile struct { ID uint User_id uint Clan string Contactinfo string Country string Gravatar string Location string Message string Username string Visible bool Visible_lastplayed bool }
Profile is representation of the `profile` table in the database.
type ServerEphemeral ¶
type ServerEphemeral struct {
// contains filtered or unexported fields
}
ServerEphemeral contains an SRP ephemeral value sent from the game server to the auth server.
func (*ServerEphemeral) MarshalBinary ¶
func (packet *ServerEphemeral) MarshalBinary() (data []byte, err error)
MarshalBinary marshalls a ServerEphemeral from binary data.
func (*ServerEphemeral) UnmarshalBinary ¶
func (packet *ServerEphemeral) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary unmarshalls a ServerEphemeral to binary data.
type ServerNegotiate ¶
type ServerNegotiate struct {
// contains filtered or unexported fields
}
ServerNegotiate is a connection negotiation packet that is sent from the game server to the auth server.
func (*ServerNegotiate) MarshalBinary ¶
func (packet *ServerNegotiate) MarshalBinary() (data []byte, err error)
MarshalBinary marshalls a ServerNegotiate from binary data.
func (*ServerNegotiate) UnmarshalBinary ¶
func (packet *ServerNegotiate) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary unmarshalls a ServerNegotiate to binary data.
type ServerProof ¶
type ServerProof struct {
// contains filtered or unexported fields
}
ServerProof contains a SRP proof value sent from the game server to the auth server.
func (*ServerProof) MarshalBinary ¶
func (packet *ServerProof) MarshalBinary() (data []byte, err error)
MarshalBinary marshalls a ServerProof from binary data.
func (*ServerProof) UnmarshalBinary ¶
func (packet *ServerProof) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary unmarshalls a ServerProof to binary data.
type SessionError ¶
type SessionError struct {
// contains filtered or unexported fields
}
func (*SessionError) MarshalBinary ¶
func (packet *SessionError) MarshalBinary() (data []byte, err error)
func (*SessionError) UnmarshalBinary ¶
func (packet *SessionError) UnmarshalBinary(data []byte) (err error)
type SessionErrorType ¶
type SessionErrorType uint8
const ( SessionErrorTryLater SessionErrorType = iota SessionErrorNoExist SessionErrorVerifierUnsafe SessionErrorAuthFailed )
type TemplateDefs ¶
type TemplateDefs map[string]TemplateNames
TemplateDefs defines a map of template names for keys and TemplateNames for values
type TemplateNames ¶
type TemplateNames []string
TemplateNames defines a list of templates that exist in the "templates/html" directory, and end with a ".tmpl" extension.
type User ¶
type User struct { ID uint Username string Email string Verifier []byte Salt []byte Access string Active bool CreatedAt time.Time `db:"createdAt"` UpdatedAt time.Time `db:"updatedAt"` }
User is a representation of the `User` table in the database.
type WebApp ¶
type WebApp struct {
// contains filtered or unexported fields
}
WebApp contains all state for a single instance of the webserver.
func (*WebApp) AddTemplateDefs ¶
func (webApp *WebApp) AddTemplateDefs(tmpls *TemplateDefs) (err error)
AddTemplateDefs takes the passed template definitions, figures out where they exist on the filesystem, parses them, and puts them in the template store for later execution.
func (*WebApp) Home ¶
func (webApp *WebApp) Home(res http.ResponseWriter, req *http.Request)
Home renders the homepage.
func (*WebApp) ListenAndServe ¶
ListenAndServe has the web server listen on a specific address and port, essentially passing straight through to the http method of the same name.
func (*WebApp) RenderTemplate ¶
func (webApp *WebApp) RenderTemplate(res http.ResponseWriter, req *http.Request, name string, data interface{})
RenderTemplate renders a named template from the template store that was previously added by AddTemplateDefs.