mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-09-11 01:55:28 -05:00
Common: Apply lint suggestions
This commit is contained in:
@@ -85,8 +85,6 @@ func MarshalNASAuthToken(gamecd string, userid uint64, gsbrcd string, cfc uint64
|
||||
}
|
||||
|
||||
func UnmarshalNASAuthToken(token string) (gamecd string, issuetime time.Time, userid uint64, gsbrcd string, cfc uint64, region byte, lang byte, ingamesn string, challenge string, unitcd byte, isLocalhost bool, err error) {
|
||||
err = nil
|
||||
|
||||
if !strings.HasPrefix(token, "NDS") {
|
||||
err = errors.New("invalid auth token prefix")
|
||||
return
|
||||
@@ -143,9 +141,8 @@ func MarshalGPCMLoginTicket(profileId uint32) string {
|
||||
}
|
||||
|
||||
func UnmarshalGPCMLoginTicket(ticket string) (profileId uint32, issuetime time.Time, err error) {
|
||||
err = nil
|
||||
|
||||
blob, err := Base64DwcEncoding.DecodeString(ticket)
|
||||
var blob []byte
|
||||
blob, err = Base64DwcEncoding.DecodeString(ticket)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -155,7 +152,8 @@ func UnmarshalGPCMLoginTicket(ticket string) (profileId uint32, issuetime time.T
|
||||
return
|
||||
}
|
||||
|
||||
block, err := aes.NewCipher(loginTicketKey)
|
||||
var block cipher.Block
|
||||
block, err = aes.NewCipher(loginTicketKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -560,7 +560,8 @@ func EncodeMatchCommand(command byte, data MatchCommandData) ([]byte, bool) {
|
||||
message = binary.BigEndian.AppendUint32(message, data.Reservation.PublicIP)
|
||||
message = binary.LittleEndian.AppendUint32(message, uint32(data.Reservation.PublicPort))
|
||||
|
||||
if version == 11 {
|
||||
switch version {
|
||||
case 11:
|
||||
isFriendInt := uint32(0)
|
||||
if data.Reservation.IsFriend {
|
||||
isFriendInt = 1
|
||||
@@ -568,7 +569,7 @@ func EncodeMatchCommand(command byte, data MatchCommandData) ([]byte, bool) {
|
||||
message = binary.LittleEndian.AppendUint32(message, isFriendInt)
|
||||
|
||||
message = binary.LittleEndian.AppendUint32(message, data.Reservation.LocalPlayerCount)
|
||||
} else if version == 90 {
|
||||
case 90:
|
||||
message = binary.BigEndian.AppendUint32(message, data.Reservation.LocalIP)
|
||||
message = binary.LittleEndian.AppendUint32(message, uint32(data.Reservation.LocalPort))
|
||||
message = binary.LittleEndian.AppendUint32(message, data.Reservation.Unknown)
|
||||
|
||||
@@ -2,9 +2,19 @@ package common
|
||||
|
||||
import "reflect"
|
||||
|
||||
func MaybeUnused(v ...interface{}) {
|
||||
// MaybeUnused is a helper function to mark variables as used to avoid compiler warnings.
|
||||
func MaybeUnused(v ...interface{}) struct{} {
|
||||
return struct{}{}
|
||||
}
|
||||
|
||||
// ShouldNotError panics if the error is not nil.
|
||||
func ShouldNotError(err error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// ReverseMap takes a map and returns a new map with the keys and values reversed.
|
||||
func ReverseMap(m interface{}) interface{} {
|
||||
inputType := reflect.TypeOf(m)
|
||||
inputValue := reflect.ValueOf(m)
|
||||
|
||||
Reference in New Issue
Block a user