shipgate

package
v0.0.0-...-34f5af7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const ShipgatePathPrefix = "/twirp/archon.Shipgate/"

ShipgatePathPrefix is a convenience constant that may identify URL paths. Should be used with caution, it only matches routes generated by Twirp Go clients, with the default "/twirp" prefix and default CamelCase service and method names. More info: https://twitchtv.github.io/twirp/docs/routing.html

Variables

View Source
var (
	ErrUnknown            = errors.New("an unexpected error occurred, please contact your server administrator")
	ErrInvalidCredentials = errors.New("username/combination password not found")
	ErrAccountBanned      = errors.New("this account has been suspended")
)
View Source
var File_internal_shipgate_shipgate_proto protoreflect.FileDescriptor

Functions

func HashPassword

func HashPassword(password string) string

HashPassword returns a version of password with Archon's chosen hashing strategy.

func WriteError

func WriteError(resp http.ResponseWriter, err error)

WriteError writes an HTTP response with a valid Twirp error format (code, msg, meta). Useful outside of the Twirp server (e.g. http middleware), but does not trigger hooks. If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)

Types

type AuthenticateAccountRequest

type AuthenticateAccountRequest struct {
	Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
	Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
	// contains filtered or unexported fields
}

func (*AuthenticateAccountRequest) Descriptor deprecated

func (*AuthenticateAccountRequest) Descriptor() ([]byte, []int)

Deprecated: Use AuthenticateAccountRequest.ProtoReflect.Descriptor instead.

func (*AuthenticateAccountRequest) GetPassword

func (x *AuthenticateAccountRequest) GetPassword() string

func (*AuthenticateAccountRequest) GetUsername

func (x *AuthenticateAccountRequest) GetUsername() string

func (*AuthenticateAccountRequest) ProtoMessage

func (*AuthenticateAccountRequest) ProtoMessage()

func (*AuthenticateAccountRequest) ProtoReflect

func (*AuthenticateAccountRequest) Reset

func (x *AuthenticateAccountRequest) Reset()

func (*AuthenticateAccountRequest) String

func (x *AuthenticateAccountRequest) String() string

type CharacterRequest

type CharacterRequest struct {
	AccountId uint64 `protobuf:"varint,1,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"`
	Slot      uint32 `protobuf:"varint,2,opt,name=slot,proto3" json:"slot,omitempty"`
	// contains filtered or unexported fields
}

func (*CharacterRequest) Descriptor deprecated

func (*CharacterRequest) Descriptor() ([]byte, []int)

Deprecated: Use CharacterRequest.ProtoReflect.Descriptor instead.

func (*CharacterRequest) GetAccountId

func (x *CharacterRequest) GetAccountId() uint64

func (*CharacterRequest) GetSlot

func (x *CharacterRequest) GetSlot() uint32

func (*CharacterRequest) ProtoMessage

func (*CharacterRequest) ProtoMessage()

func (*CharacterRequest) ProtoReflect

func (x *CharacterRequest) ProtoReflect() protoreflect.Message

func (*CharacterRequest) Reset

func (x *CharacterRequest) Reset()

func (*CharacterRequest) String

func (x *CharacterRequest) String() string

type FindCharacterResponse

type FindCharacterResponse struct {
	Exists    bool             `protobuf:"varint,1,opt,name=exists,proto3" json:"exists,omitempty"`
	Character *proto.Character `protobuf:"bytes,2,opt,name=character,proto3" json:"character,omitempty"`
	// contains filtered or unexported fields
}

func (*FindCharacterResponse) Descriptor deprecated

func (*FindCharacterResponse) Descriptor() ([]byte, []int)

Deprecated: Use FindCharacterResponse.ProtoReflect.Descriptor instead.

func (*FindCharacterResponse) GetCharacter

func (x *FindCharacterResponse) GetCharacter() *proto.Character

func (*FindCharacterResponse) GetExists

func (x *FindCharacterResponse) GetExists() bool

func (*FindCharacterResponse) ProtoMessage

func (*FindCharacterResponse) ProtoMessage()

func (*FindCharacterResponse) ProtoReflect

func (x *FindCharacterResponse) ProtoReflect() protoreflect.Message

func (*FindCharacterResponse) Reset

func (x *FindCharacterResponse) Reset()

func (*FindCharacterResponse) String

func (x *FindCharacterResponse) String() string

type GetGuildcardEntriesRequest

type GetGuildcardEntriesRequest struct {
	AccountId uint64 `protobuf:"varint,1,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"`
	// contains filtered or unexported fields
}

func (*GetGuildcardEntriesRequest) Descriptor deprecated

func (*GetGuildcardEntriesRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetGuildcardEntriesRequest.ProtoReflect.Descriptor instead.

func (*GetGuildcardEntriesRequest) GetAccountId

func (x *GetGuildcardEntriesRequest) GetAccountId() uint64

func (*GetGuildcardEntriesRequest) ProtoMessage

func (*GetGuildcardEntriesRequest) ProtoMessage()

func (*GetGuildcardEntriesRequest) ProtoReflect

func (*GetGuildcardEntriesRequest) Reset

func (x *GetGuildcardEntriesRequest) Reset()

func (*GetGuildcardEntriesRequest) String

func (x *GetGuildcardEntriesRequest) String() string

type GetGuildcardEntriesResponse

type GetGuildcardEntriesResponse struct {
	Entries []*proto.GuildcardEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
	// contains filtered or unexported fields
}

func (*GetGuildcardEntriesResponse) Descriptor deprecated

func (*GetGuildcardEntriesResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetGuildcardEntriesResponse.ProtoReflect.Descriptor instead.

func (*GetGuildcardEntriesResponse) GetEntries

func (*GetGuildcardEntriesResponse) ProtoMessage

func (*GetGuildcardEntriesResponse) ProtoMessage()

func (*GetGuildcardEntriesResponse) ProtoReflect

func (*GetGuildcardEntriesResponse) Reset

func (x *GetGuildcardEntriesResponse) Reset()

func (*GetGuildcardEntriesResponse) String

func (x *GetGuildcardEntriesResponse) String() string

type GetPlayerOptionsRequest

type GetPlayerOptionsRequest struct {
	AccountId uint64 `protobuf:"varint,1,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"`
	// contains filtered or unexported fields
}

func (*GetPlayerOptionsRequest) Descriptor deprecated

func (*GetPlayerOptionsRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetPlayerOptionsRequest.ProtoReflect.Descriptor instead.

func (*GetPlayerOptionsRequest) GetAccountId

func (x *GetPlayerOptionsRequest) GetAccountId() uint64

func (*GetPlayerOptionsRequest) ProtoMessage

func (*GetPlayerOptionsRequest) ProtoMessage()

func (*GetPlayerOptionsRequest) ProtoReflect

func (x *GetPlayerOptionsRequest) ProtoReflect() protoreflect.Message

func (*GetPlayerOptionsRequest) Reset

func (x *GetPlayerOptionsRequest) Reset()

func (*GetPlayerOptionsRequest) String

func (x *GetPlayerOptionsRequest) String() string

type GetPlayerOptionsResponse

type GetPlayerOptionsResponse struct {
	Exists        bool                 `protobuf:"varint,1,opt,name=exists,proto3" json:"exists,omitempty"`
	PlayerOptions *proto.PlayerOptions `protobuf:"bytes,2,opt,name=player_options,json=playerOptions,proto3" json:"player_options,omitempty"`
	// contains filtered or unexported fields
}

func (*GetPlayerOptionsResponse) Descriptor deprecated

func (*GetPlayerOptionsResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetPlayerOptionsResponse.ProtoReflect.Descriptor instead.

func (*GetPlayerOptionsResponse) GetExists

func (x *GetPlayerOptionsResponse) GetExists() bool

func (*GetPlayerOptionsResponse) GetPlayerOptions

func (x *GetPlayerOptionsResponse) GetPlayerOptions() *proto.PlayerOptions

func (*GetPlayerOptionsResponse) ProtoMessage

func (*GetPlayerOptionsResponse) ProtoMessage()

func (*GetPlayerOptionsResponse) ProtoReflect

func (x *GetPlayerOptionsResponse) ProtoReflect() protoreflect.Message

func (*GetPlayerOptionsResponse) Reset

func (x *GetPlayerOptionsResponse) Reset()

func (*GetPlayerOptionsResponse) String

func (x *GetPlayerOptionsResponse) String() string

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.

HTTPClient implementations should not follow redirects. Redirects are automatically disabled if *(net/http).Client is passed to client constructors. See the withoutRedirects function in this file for more details.

type RegisterShipRequest

type RegisterShipRequest struct {
	Name       string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Address    string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
	Port       string `protobuf:"bytes,3,opt,name=port,proto3" json:"port,omitempty"`
	MaxPlayers int32  `protobuf:"varint,4,opt,name=max_players,json=maxPlayers,proto3" json:"max_players,omitempty"`
	// contains filtered or unexported fields
}

func (*RegisterShipRequest) Descriptor deprecated

func (*RegisterShipRequest) Descriptor() ([]byte, []int)

Deprecated: Use RegisterShipRequest.ProtoReflect.Descriptor instead.

func (*RegisterShipRequest) GetAddress

func (x *RegisterShipRequest) GetAddress() string

func (*RegisterShipRequest) GetMaxPlayers

func (x *RegisterShipRequest) GetMaxPlayers() int32

func (*RegisterShipRequest) GetName

func (x *RegisterShipRequest) GetName() string

func (*RegisterShipRequest) GetPort

func (x *RegisterShipRequest) GetPort() string

func (*RegisterShipRequest) ProtoMessage

func (*RegisterShipRequest) ProtoMessage()

func (*RegisterShipRequest) ProtoReflect

func (x *RegisterShipRequest) ProtoReflect() protoreflect.Message

func (*RegisterShipRequest) Reset

func (x *RegisterShipRequest) Reset()

func (*RegisterShipRequest) String

func (x *RegisterShipRequest) String() string

type Server

type Server struct {
	Config *core.Config
	Logger *logrus.Logger
	// contains filtered or unexported fields
}

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context)

func (*Server) Start

func (s *Server) Start(ctx context.Context)

type ShipList

type ShipList struct {
	Ships []*proto.Ship `protobuf:"bytes,1,rep,name=ships,proto3" json:"ships,omitempty"`
	// contains filtered or unexported fields
}

func (*ShipList) Descriptor deprecated

func (*ShipList) Descriptor() ([]byte, []int)

Deprecated: Use ShipList.ProtoReflect.Descriptor instead.

func (*ShipList) GetShips

func (x *ShipList) GetShips() []*proto.Ship

func (*ShipList) ProtoMessage

func (*ShipList) ProtoMessage()

func (*ShipList) ProtoReflect

func (x *ShipList) ProtoReflect() protoreflect.Message

func (*ShipList) Reset

func (x *ShipList) Reset()

func (*ShipList) String

func (x *ShipList) String() string

type Shipgate

type Shipgate interface {
	// GetActiveShips returns the list of Ships that currently connected to the
	// shipgate and ready to receive players.
	GetActiveShips(context.Context, *google_protobuf.Empty) (*ShipList, error)

	// RegisterShip informs the shipgate that it is able to serve players.
	RegisterShip(context.Context, *RegisterShipRequest) (*google_protobuf.Empty, error)

	// AuthenticateAccount verifies an account. A password should be provided
	// via the rpc call metadata.
	AuthenticateAccount(context.Context, *AuthenticateAccountRequest) (*archon.Account, error)

	// FindCharacter looks up character in a slot on an account.
	FindCharacter(context.Context, *CharacterRequest) (*FindCharacterResponse, error)

	// UpsertCharacter creates a new character in a slot on an account.
	UpsertCharacter(context.Context, *UpsertCharacterRequest) (*google_protobuf.Empty, error)

	// DeleteCharacter deletes the character data in a slot on an account.
	DeleteCharacter(context.Context, *CharacterRequest) (*google_protobuf.Empty, error)

	// GetGuildcardEntires returns the list of guildcards on an account.
	GetGuildcardEntries(context.Context, *GetGuildcardEntriesRequest) (*GetGuildcardEntriesResponse, error)

	// GetPlayerOptions returns the player options tied to an account.
	GetPlayerOptions(context.Context, *GetPlayerOptionsRequest) (*GetPlayerOptionsResponse, error)

	// GetPlayerOptions updates or creates the player options tied to an account.
	UpsertPlayerOptions(context.Context, *UpsertPlayerOptionsRequest) (*google_protobuf.Empty, error)
}

ShipgateService provides game functionality and is intended for use by ship servers serving players.

func NewRPCClient

func NewRPCClient(cfg *core.Config) Shipgate

func NewShipgateJSONClient

func NewShipgateJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Shipgate

NewShipgateJSONClient creates a JSON client that implements the Shipgate interface. It communicates using JSON and can be configured with a custom HTTPClient.

func NewShipgateProtobufClient

func NewShipgateProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Shipgate

NewShipgateProtobufClient creates a Protobuf client that implements the Shipgate interface. It communicates using Protobuf and can be configured with a custom HTTPClient.

type TwirpServer

type TwirpServer interface {
	http.Handler

	// ServiceDescriptor returns gzipped bytes describing the .proto file that
	// this service was generated from. Once unzipped, the bytes can be
	// unmarshalled as a
	// google.golang.org/protobuf/types/descriptorpb.FileDescriptorProto.
	//
	// The returned integer is the index of this particular service within that
	// FileDescriptorProto's 'Service' slice of ServiceDescriptorProtos. This is a
	// low-level field, expected to be used for reflection.
	ServiceDescriptor() ([]byte, int)

	// ProtocGenTwirpVersion is the semantic version string of the version of
	// twirp used to generate this file.
	ProtocGenTwirpVersion() string

	// PathPrefix returns the HTTP URL path prefix for all methods handled by this
	// service. This can be used with an HTTP mux to route Twirp requests.
	// The path prefix is in the form: "/<prefix>/<package>.<Service>/"
	// that is, everything in a Twirp route except for the <Method> at the end.
	PathPrefix() string
}

TwirpServer is the interface generated server structs will support: they're HTTP handlers with additional methods for accessing metadata about the service. Those accessors are a low-level API for building reflection tools. Most people can think of TwirpServers as just http.Handlers.

func NewShipgateServer

func NewShipgateServer(svc Shipgate, opts ...interface{}) TwirpServer

NewShipgateServer builds a TwirpServer that can be used as an http.Handler to handle HTTP requests that are routed to the right method in the provided svc implementation. The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks).

type UpsertCharacterRequest

type UpsertCharacterRequest struct {
	AccountId uint64           `protobuf:"varint,1,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"`
	Character *proto.Character `protobuf:"bytes,2,opt,name=character,proto3" json:"character,omitempty"`
	// contains filtered or unexported fields
}

func (*UpsertCharacterRequest) Descriptor deprecated

func (*UpsertCharacterRequest) Descriptor() ([]byte, []int)

Deprecated: Use UpsertCharacterRequest.ProtoReflect.Descriptor instead.

func (*UpsertCharacterRequest) GetAccountId

func (x *UpsertCharacterRequest) GetAccountId() uint64

func (*UpsertCharacterRequest) GetCharacter

func (x *UpsertCharacterRequest) GetCharacter() *proto.Character

func (*UpsertCharacterRequest) ProtoMessage

func (*UpsertCharacterRequest) ProtoMessage()

func (*UpsertCharacterRequest) ProtoReflect

func (x *UpsertCharacterRequest) ProtoReflect() protoreflect.Message

func (*UpsertCharacterRequest) Reset

func (x *UpsertCharacterRequest) Reset()

func (*UpsertCharacterRequest) String

func (x *UpsertCharacterRequest) String() string

type UpsertPlayerOptionsRequest

type UpsertPlayerOptionsRequest struct {
	AccountId     uint64               `protobuf:"varint,1,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"`
	PlayerOptions *proto.PlayerOptions `protobuf:"bytes,2,opt,name=player_options,json=playerOptions,proto3" json:"player_options,omitempty"`
	// contains filtered or unexported fields
}

func (*UpsertPlayerOptionsRequest) Descriptor deprecated

func (*UpsertPlayerOptionsRequest) Descriptor() ([]byte, []int)

Deprecated: Use UpsertPlayerOptionsRequest.ProtoReflect.Descriptor instead.

func (*UpsertPlayerOptionsRequest) GetAccountId

func (x *UpsertPlayerOptionsRequest) GetAccountId() uint64

func (*UpsertPlayerOptionsRequest) GetPlayerOptions

func (x *UpsertPlayerOptionsRequest) GetPlayerOptions() *proto.PlayerOptions

func (*UpsertPlayerOptionsRequest) ProtoMessage

func (*UpsertPlayerOptionsRequest) ProtoMessage()

func (*UpsertPlayerOptionsRequest) ProtoReflect

func (*UpsertPlayerOptionsRequest) Reset

func (x *UpsertPlayerOptionsRequest) Reset()

func (*UpsertPlayerOptionsRequest) String

func (x *UpsertPlayerOptionsRequest) String() string

Jump to

Keyboard shortcuts

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