Documentation ¶
Overview ¶
* Copyright 2018 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright 2018 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright 2018 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright 2018 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright 2018 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright 2018 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright 2018 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
Index ¶
- Constants
- Variables
- func CalculateNameGracePeriodBeginning(end time.Time) time.Time
- func CalculateNameGracePeriodEnd(start time.Time) time.Time
- func IsMojangId(id string) bool
- func IsNameAssociationValid(lastSeen time.Time) bool
- func IsNameAssociationValidAt(at time.Time, lastSeen time.Time) bool
- func IsProfileId(id string) bool
- func ParseId(id string) (uuid.UUID, error)
- func SerializeNameChangeArray(history []*NameChange) ([]byte, error)
- func SerializeProfileIdArray(profileIds []*ProfileId) ([]byte, error)
- func ToMojangId(id uuid.UUID) string
- func ToStandardId(id string) (uuid.UUID, error)
- func ToStandardIdString(id string) (string, error)
- type Blacklist
- func (b *Blacklist) Contains(hash string) bool
- func (b *Blacklist) Deserialize(enc []byte) error
- func (b *Blacklist) IsBlacklisted(addr string) (bool, error)
- func (b *Blacklist) IsBlacklistedDomain(hostname string) (bool, error)
- func (b *Blacklist) IsBlacklistedIP(ip string) (bool, error)
- func (b *Blacklist) Serialize() ([]byte, error)
- type Event
- func (e *Event) BlacklistPayload() (*Blacklist, error)
- func (e *Event) IdKey() (*uuid.UUID, error)
- func (e *Event) NameChangeHistoryPayload() (*NameChangeHistory, error)
- func (e *Event) ProfileIdKey() (*ProfileIdKey, error)
- func (e *Event) ProfileIdPayload() (*ProfileId, error)
- func (e *Event) ProfilePayload() (*Profile, error)
- type EventType
- type NameChange
- type NameChangeHistory
- type Profile
- type ProfileId
- func (p *ProfileId) Deserialize(enc []byte) error
- func (p *ProfileId) IsOverlappingWith(other *ProfileId) bool
- func (p *ProfileId) IsValid(at time.Time) bool
- func (p *ProfileId) Read(reader io.Reader, at time.Time) error
- func (p *ProfileId) Serialize() ([]byte, error)
- func (p *ProfileId) UpdateDiscovery(at time.Time)
- func (p *ProfileId) UpdateExpiration(seen time.Time)
- type ProfileIdKey
- type ProfileProperty
- type ProfileTextures
- type Status
Constants ¶
const NameChangeRateLimitPeriod = time.Hour * 24 * 30
defines the total amount of time that has to pass before a user can choose a new name again
const NameValidityPeriod = time.Hour * 24 * 37
defines the total amount of time a name can be safely associated with a given profile
Variables ¶
var IntroductoryValidityPeriodEnd = time.Unix(1425600000, 0)
defines the date and time at which initial account names are set to expired this is set to the time of introduction (4th of January 2015) + 30 days (for safety we will not be using the full 37 grace period here)
Functions ¶
func CalculateNameGracePeriodBeginning ¶
calculates the beginning of a theoretical grace period
func CalculateNameGracePeriodEnd ¶
calculates the end of a theoretical grace period
func IsMojangId ¶
Evaluates whether the passed ID is a mojang identifier
func IsNameAssociationValid ¶
evaluates whether a given name association is still considered valid (e.g. no other user was able to claim the name since it was last encountered)
func IsNameAssociationValidAt ¶
evaluates whether a given name association is still considered valid (e.g. no other user was able to claim the name since it was last encountered)
func IsProfileId ¶
evaluates whether the passed string is a profileId TODO: This is only used by the legacy API
func ParseId ¶
Parses an identifier (regardless of whether it is supplied in its Mojang or standard format)
func SerializeNameChangeArray ¶
func SerializeNameChangeArray(history []*NameChange) ([]byte, error)
func SerializeProfileIdArray ¶
func ToMojangId ¶
Converts a standard UUID into its Mojang format
func ToStandardId ¶
Converts a Mojang UUID into its RFC format
func ToStandardIdString ¶
Converts a Mojang UUID into its RFC format
Types ¶
type Blacklist ¶
type Blacklist struct {
Hashes []string
}
represents a server blacklist
func NewBlacklist ¶
creates a new blacklist from the supplied list of hashes
func (*Blacklist) Deserialize ¶
func (*Blacklist) IsBlacklisted ¶
evaluates whether the passed hostname has been blacklisted
func (*Blacklist) IsBlacklistedDomain ¶
evaluates whether a given hostname has been blacklisted
func (*Blacklist) IsBlacklistedIP ¶
evaluates whether a given IPv4 address has been blacklisted
type Event ¶
type Event struct { Type EventType Key interface{} Object interface{} }
represents an even which has occurred within the cache
func (*Event) BlacklistPayload ¶
func (*Event) NameChangeHistoryPayload ¶
func (e *Event) NameChangeHistoryPayload() (*NameChangeHistory, error)
func (*Event) ProfileIdKey ¶
func (e *Event) ProfileIdKey() (*ProfileIdKey, error)
func (*Event) ProfileIdPayload ¶
func (*Event) ProfilePayload ¶
type NameChange ¶
represents a single name change within a profile's history note that changedToAt and validUntil may be set to UNIX epoch when the entry represents the initial account name
func DeserializeNameChangeArray ¶
func DeserializeNameChangeArray(enc []byte) ([]*NameChange, error)
func ReadNameChangeArray ¶
func ReadNameChangeArray(reader io.Reader) ([]*NameChange, error)
func (*NameChange) Deserialize ¶
func (p *NameChange) Deserialize(enc []byte) error
func (*NameChange) Serialize ¶
func (p *NameChange) Serialize() ([]byte, error)
type NameChangeHistory ¶
type NameChangeHistory struct {
History []*NameChange
}
encapsulates a name history
func (*NameChangeHistory) Deserialize ¶
func (h *NameChangeHistory) Deserialize(enc []byte) error
func (*NameChangeHistory) Serialize ¶
func (h *NameChangeHistory) Serialize() ([]byte, error)
type Profile ¶
type Profile struct { Id uuid.UUID Name string Properties map[string]*ProfileProperty Textures *ProfileTextures }
func (*Profile) Deserialize ¶
type ProfileId ¶
type ProfileId struct { Id uuid.UUID Name string FirstSeenAt time.Time LastSeenAt time.Time ValidUntil time.Time }
represents a single profile id mapping between a display name and a mapping at a given time note that lastSeenAt and validUntil may be set to UNIX epoch if the initial mapping is requested
func (*ProfileId) Deserialize ¶
func (*ProfileId) IsOverlappingWith ¶
evaluates whether two profileIds theoretically overlap
two profiles are considered to overlap if their validity period overlaps at any point in time or if their assignments are equal while less than 30 days have passed (e.g. it is impossible for another user to claim and unclaim the name in the meantime due to the grace period) TODO: I have no clue how and whether Mojang handles theft of names with content creators
func (*ProfileId) UpdateDiscovery ¶
updates the time at which this id has been discovered
func (*ProfileId) UpdateExpiration ¶
updates the last time at which this id has been encountered and the respective expiration times if the passed time is set before the current last encounter, the method will return immediately without changing the profile state
type ProfileIdKey ¶
type ProfileProperty ¶
type ProfileProperty struct { Name string `json:"name"` Value string `json:"value"` Signature string `json:"signature"` }
func (*ProfileProperty) Deserialize ¶
func (p *ProfileProperty) Deserialize(enc []byte) error
func (*ProfileProperty) Serialize ¶
func (p *ProfileProperty) Serialize() ([]byte, error)
type ProfileTextures ¶
type ProfileTextures struct { Timestamp time.Time ProfileId uuid.UUID ProfileName string Textures map[string]string }
func (*ProfileTextures) Deserialize ¶
func (t *ProfileTextures) Deserialize(enc []byte) error
func (*ProfileTextures) Serialize ¶
func (t *ProfileTextures) Serialize() ([]byte, error)