Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReceiverRecord ¶
type ReceiverRecord struct {
PrivateKey *rsa.PrivateKey // v1
TokenProvider TokenProvider // v2
}
type Server ¶
type Server struct {
VoteHandler VoteListener // Required vote handler
Records []ReceiverRecord
OnErr func(net.Conn, error) // Optional connection handler
}
Server represents a Votifier server.
func (*Server) ListenAndServe ¶
ListenAndServe binds to a specified address-port pair and starts serving Votifier requests.
type TokenProvider ¶
type TokenProvider interface {
// Token returns the token for a service.
Token(service string) string
}
TokenProvider provides a token for a given vote service. The vote service is the name of the service the user is voting from and sent by the vote service itself (e.g. "minecraft-serverlist.net").
func StaticTokenProvider ¶
func StaticTokenProvider(token string) TokenProvider
StaticTokenProvider returns the same token for every request.
type TokenProviderFunc ¶
TokenProviderFunc is a function that implements TokenProvider.
func (TokenProviderFunc) Token ¶
func (f TokenProviderFunc) Token(service string) string
Token implements TokenProvider.
type V1Client ¶
type V1Client struct {
// contains filtered or unexported fields
}
V1Client represents a Votifier v1 client.
func NewV1Client ¶
NewV1Client creates a new Votifier client.
type V2Client ¶
type V2Client struct {
// contains filtered or unexported fields
}
V2Client represents a Votifier v2 client.
func NewV2Client ¶
NewV2Client creates a new Votifier v2 client.
type Vote ¶
type Vote struct {
// The name of the service the user is voting from.
ServiceName string `json:"serviceName"`
// The user's Minecraft username.
Username string `json:"username"`
// The voting user's IP address.
Address string `json:"address"`
// The timestamp this vote was issued.
Timestamp time.Time `json:"timeStamp"`
}
Vote represents a Votifier vote.
func (*Vote) DecodeV1 ¶
func (v *Vote) DecodeV1(data []byte, key *rsa.PrivateKey) error
DecodeV1 decodes the vote from the V1 protocol.
func (*Vote) DecodeV2 ¶
func (v *Vote) DecodeV2(data []byte, tokenProvider TokenProvider, challenge string) error