mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-19 21:59:59 -08:00
Fix all golint comment related problems in the pkg packages
This commit is contained in:
parent
65d43576a0
commit
e7589e706e
17 changed files with 47 additions and 18 deletions
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
package acl
|
||||
|
||||
// Per-channel permissions
|
||||
const (
|
||||
// Per-channel permissions
|
||||
NonePermission = 0x0
|
||||
WritePermission = 0x1
|
||||
TraversePermission = 0x2
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) 2010-2013 The Grumble Authors
|
||||
// The use of this source code is goverened by a BSD-style
|
||||
// license that can be found in the LICENSE-file.
|
||||
|
||||
package acl
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -10,9 +10,11 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// ISODate represents ISO 8601 formatting
|
||||
ISODate = "2006-01-02T15:04:05"
|
||||
)
|
||||
|
||||
// Ban contains information about a specific ban
|
||||
type Ban struct {
|
||||
IP net.IP
|
||||
Mask int
|
||||
|
|
@ -23,7 +25,7 @@ type Ban struct {
|
|||
Duration uint32
|
||||
}
|
||||
|
||||
// Create a net.IPMask from a specified amount of mask bits
|
||||
// IPMask creates a net.IPMask from a specified amount of mask bits
|
||||
func (ban Ban) IPMask() (mask net.IPMask) {
|
||||
allbits := ban.Mask
|
||||
for i := 0; i < 16; i++ {
|
||||
|
|
@ -48,7 +50,7 @@ func (ban Ban) Match(ip net.IP) bool {
|
|||
return banned.Equal(masked)
|
||||
}
|
||||
|
||||
// Set Start date from an ISO 8601 date (in UTC)
|
||||
// SetISOStartDate sets Start date from an ISO 8601 date (in UTC)
|
||||
func (ban *Ban) SetISOStartDate(isodate string) {
|
||||
startTime, err := time.Parse(ISODate, isodate)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// The use of this source code is goverened by a BSD-style
|
||||
// license that can be found in the LICENSE-file.
|
||||
|
||||
// This package implements a simple disk-persisted content-addressed blobstore.
|
||||
// Package blobstore implements a simple disk-persisted content-addressed blobstore.
|
||||
package blobstore
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
|
||||
const decryptHistorySize = 0x100
|
||||
|
||||
// CryptoMode represents a specific cryptographic mode
|
||||
type CryptoMode interface {
|
||||
NonceSize() int
|
||||
KeySize() int
|
||||
|
|
@ -23,6 +24,7 @@ type CryptoMode interface {
|
|||
Decrypt(dst []byte, src []byte, nonce []byte) bool
|
||||
}
|
||||
|
||||
// CryptState represents the current state of a cryptographic operation
|
||||
type CryptState struct {
|
||||
Key []byte
|
||||
EncryptIV []byte
|
||||
|
|
@ -62,6 +64,7 @@ func createMode(mode string) (CryptoMode, error) {
|
|||
return nil, errors.New("cryptstate: no such CryptoMode")
|
||||
}
|
||||
|
||||
// GenerateKey will generate a key for the specific mode
|
||||
func (cs *CryptState) GenerateKey(mode string) error {
|
||||
cm, err := createMode(mode)
|
||||
if err != nil {
|
||||
|
|
@ -93,6 +96,7 @@ func (cs *CryptState) GenerateKey(mode string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// SetKey will set the cryptographic key for a specific mode
|
||||
func (cs *CryptState) SetKey(mode string, key []byte, eiv []byte, div []byte) error {
|
||||
cm, err := createMode(mode)
|
||||
if err != nil {
|
||||
|
|
@ -115,6 +119,7 @@ func (cs *CryptState) Overhead() int {
|
|||
return 1 + cs.mode.Overhead()
|
||||
}
|
||||
|
||||
// Decrypt decrypts the source into the destination
|
||||
func (cs *CryptState) Decrypt(dst, src []byte) error {
|
||||
if len(src) < cs.Overhead() {
|
||||
return errors.New("cryptstate: crypted length too short to decrypt")
|
||||
|
|
@ -228,6 +233,7 @@ func (cs *CryptState) Decrypt(dst, src []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Encrypt will encrypt the source into the destination
|
||||
func (cs *CryptState) Encrypt(dst, src []byte) {
|
||||
// First, increase our IV
|
||||
for i := range cs.EncryptIV {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package freezer
|
|||
|
||||
type typeKind uint32
|
||||
|
||||
// The different types of data that can be frozen
|
||||
const (
|
||||
ServerType typeKind = iota
|
||||
ConfigKeyValuePairType
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@ func isEOF(err error) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// Type Walker implements a method for
|
||||
// Walker implements a method for
|
||||
// iterating the transaction groups of an
|
||||
// immutable Log.
|
||||
type Walker struct {
|
||||
r io.Reader
|
||||
}
|
||||
|
||||
// Type txReader imlpements a checksumming reader, intended
|
||||
// txReader imlpements a checksumming reader, intended
|
||||
// for reading transaction groups of a Log.
|
||||
//
|
||||
// Besides auto-checksumming the read content, it also
|
||||
|
|
@ -79,7 +79,7 @@ func (txr *txReader) Consumed() int {
|
|||
return txr.consumed
|
||||
}
|
||||
|
||||
// Create a new Walker that iterates over the log entries of a given Reader.
|
||||
// NewReaderWalker creates a new Walker that iterates over the log entries of a given Reader.
|
||||
func NewReaderWalker(r io.Reader) (walker *Walker, err error) {
|
||||
walker = new(Walker)
|
||||
walker.r = r
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ type Log struct {
|
|||
wc io.WriteCloser
|
||||
}
|
||||
|
||||
// Type LogTx represents a transaction in the log.
|
||||
// LogTx represents a transaction in the log.
|
||||
// Transactions can be used to group several changes into an
|
||||
// atomic entity in the log file.
|
||||
type LogTx struct {
|
||||
|
|
@ -51,7 +51,7 @@ type LogTx struct {
|
|||
numops int
|
||||
}
|
||||
|
||||
// Create a new log file
|
||||
// NewLogFile creates a new log file
|
||||
func NewLogFile(fn string) (*Log, error) {
|
||||
f, err := os.Create(fn)
|
||||
if err != nil {
|
||||
|
|
@ -69,7 +69,7 @@ func (log *Log) Close() error {
|
|||
return log.wc.Close()
|
||||
}
|
||||
|
||||
// Append a log entry
|
||||
// Put will append a log entry
|
||||
//
|
||||
// This method implicitly creates a transaction
|
||||
// group for this single Put operation. It is merely
|
||||
|
|
@ -83,7 +83,7 @@ func (log *Log) Put(value interface{}) (err error) {
|
|||
return tx.Commit()
|
||||
}
|
||||
|
||||
// Begin a transaction
|
||||
// BeginTx begins a transaction
|
||||
func (log *Log) BeginTx() *LogTx {
|
||||
tx := &LogTx{}
|
||||
tx.log = log
|
||||
|
|
@ -92,7 +92,7 @@ func (log *Log) BeginTx() *LogTx {
|
|||
return tx
|
||||
}
|
||||
|
||||
// Append a log entry to the transaction.
|
||||
// Put will append a log entry to the transaction.
|
||||
// The transaction's log entries will not be persisted to
|
||||
// the log until the Commit has been called on the transaction.
|
||||
func (tx *LogTx) Put(value interface{}) (err error) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
// Options contains the different possible HTML filtering options
|
||||
type Options struct {
|
||||
StripHTML bool
|
||||
MaxTextMessageLength int
|
||||
|
|
@ -24,6 +25,7 @@ var defaultOptions Options = Options{
|
|||
MaxImageMessageLength: 1024 * 1024,
|
||||
}
|
||||
|
||||
// Errors that can happen in this module
|
||||
var (
|
||||
ErrExceedsTextMessageLength = errors.New("Exceeds text message length")
|
||||
ErrExceedsImageMessageLength = errors.New("Exceeds image message length")
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ type LogTarget struct {
|
|||
memLog *bytes.Buffer
|
||||
}
|
||||
|
||||
// Target is the current log target
|
||||
var Target LogTarget
|
||||
|
||||
// Write writes a log message to all registered io.Writers
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package mumbleproto
|
||||
|
||||
// All different message types
|
||||
const (
|
||||
MessageVersion uint16 = iota
|
||||
MessageUDPTunnel
|
||||
|
|
@ -32,6 +33,7 @@ const (
|
|||
MessageServerConfig
|
||||
)
|
||||
|
||||
// All different UDP message types
|
||||
const (
|
||||
UDPMessageVoiceCELTAlpha = iota
|
||||
UDPMessagePing
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"math"
|
||||
)
|
||||
|
||||
// PacketData contains one packet of information
|
||||
type PacketData struct {
|
||||
Buf []byte
|
||||
offset int
|
||||
|
|
@ -17,6 +18,7 @@ type PacketData struct {
|
|||
ok bool
|
||||
}
|
||||
|
||||
// New creates a new packet data from the buffer
|
||||
func New(buf []byte) (pds *PacketData) {
|
||||
pds = new(PacketData)
|
||||
pds.Buf = buf
|
||||
|
|
@ -25,10 +27,12 @@ func New(buf []byte) (pds *PacketData) {
|
|||
return
|
||||
}
|
||||
|
||||
// IsValid checks whether the current packet data is valid
|
||||
func (pds *PacketData) IsValid() bool {
|
||||
return pds.ok
|
||||
}
|
||||
|
||||
// Skip will skip some data
|
||||
func (pds *PacketData) Skip(skip int) {
|
||||
if pds.Left() >= skip {
|
||||
pds.offset += skip
|
||||
|
|
@ -299,7 +303,7 @@ func (pds *PacketData) PutFloat64(val float64) {
|
|||
pds.append(bits & 0xff)
|
||||
}
|
||||
|
||||
// Copy a buffer out of the PacketData into dst.
|
||||
// CopyBytes will copy a buffer out of the PacketData into dst.
|
||||
func (pds *PacketData) CopyBytes(dst []byte) {
|
||||
if pds.Left() >= len(dst) {
|
||||
if copy(dst, pds.Buf[pds.offset:pds.offset+len(dst)]) != len(dst) {
|
||||
|
|
@ -310,7 +314,7 @@ func (pds *PacketData) CopyBytes(dst []byte) {
|
|||
}
|
||||
}
|
||||
|
||||
// Put a buffer src into the PacketData at the
|
||||
// PutBytes will put a buffer src into the PacketData at the
|
||||
// current offset.
|
||||
func (pds *PacketData) PutBytes(src []byte) {
|
||||
if pds.Left() >= len(src) {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@
|
|||
|
||||
package replacefile
|
||||
|
||||
// Flag is a flag that allows you to ignore some errors
|
||||
type Flag uint32
|
||||
|
||||
// The types of errors that can be ignored
|
||||
const (
|
||||
IgnoreMergeErrors Flag = 0x2
|
||||
IgnoreACLErrors Flag = 0x4
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"errors"
|
||||
)
|
||||
|
||||
// The different types of errors that can happen if we're not on windows
|
||||
var (
|
||||
errOnlyWindows = errors.New("replacefile: only implemented on Windows")
|
||||
ErrUnableToMoveReplacement error = errOnlyWindows
|
||||
|
|
@ -17,6 +18,7 @@ var (
|
|||
ErrUnableToRemoveReplaced error = errOnlyWindows
|
||||
)
|
||||
|
||||
// ReplaceFile tries to replace the file
|
||||
func ReplaceFile(replaced string, replacement string, backup string, flags Flag) error {
|
||||
return errOnlyWindows
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,13 @@ var defaultCfg = map[string]string{
|
|||
"SendVersion": "true",
|
||||
}
|
||||
|
||||
// Config contains all configurations
|
||||
type Config struct {
|
||||
cfgMap map[string]string
|
||||
mutex sync.RWMutex
|
||||
}
|
||||
|
||||
// Create a new Config using cfgMap as the intial internal config map.
|
||||
// New creates a new Config using cfgMap as the intial internal config map.
|
||||
// If cfgMap is nil, ConfigWithMap will create a new config map.
|
||||
func New(cfgMap map[string]string) *Config {
|
||||
if cfgMap == nil {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
// A SessionPool is a pool for session IDs.
|
||||
// SessionPool is a pool for session IDs.
|
||||
// IDs are re-used in MRU order, for ease of implementation in Go.
|
||||
type SessionPool struct {
|
||||
mutex sync.Mutex
|
||||
|
|
@ -19,13 +19,13 @@ type SessionPool struct {
|
|||
cur uint32
|
||||
}
|
||||
|
||||
// Create a new SessionPool container.
|
||||
// New creates a new SessionPool container.
|
||||
func New() (pool *SessionPool) {
|
||||
pool = new(SessionPool)
|
||||
return
|
||||
}
|
||||
|
||||
// Enable use-tracking for the SessionPool.
|
||||
// EnableUseTracking will enable use-tracking for the SessionPool.
|
||||
//
|
||||
// When enabled, the SessionPool stores all session IDs
|
||||
// returned by Get() internally. When an ID is reclaimed,
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ var upgrader = websocket.Upgrader{
|
|||
},
|
||||
}
|
||||
|
||||
// Listener represents a specific network listener
|
||||
type Listener struct {
|
||||
sockets chan *conn
|
||||
done chan struct{}
|
||||
|
|
@ -31,6 +32,7 @@ type Listener struct {
|
|||
logger *log.Logger
|
||||
}
|
||||
|
||||
// NewListener creates a new listener
|
||||
func NewListener(laddr net.Addr, logger *log.Logger) *Listener {
|
||||
return &Listener{
|
||||
sockets: make(chan *conn),
|
||||
|
|
@ -40,6 +42,7 @@ func NewListener(laddr net.Addr, logger *log.Logger) *Listener {
|
|||
}
|
||||
}
|
||||
|
||||
// Accept blocks and waits for a new connection
|
||||
func (l *Listener) Accept() (net.Conn, error) {
|
||||
if atomic.LoadInt32(&l.closed) != 0 {
|
||||
return nil, fmt.Errorf("accept ws %v: use of closed websocket listener", l.addr)
|
||||
|
|
@ -52,6 +55,7 @@ func (l *Listener) Accept() (net.Conn, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Close will close the underlying listener
|
||||
func (l *Listener) Close() error {
|
||||
if !atomic.CompareAndSwapInt32(&l.closed, 0, 1) {
|
||||
return fmt.Errorf("close ws %v: use of closed websocket listener", l.addr)
|
||||
|
|
@ -60,6 +64,7 @@ func (l *Listener) Close() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Addr returns the internal address
|
||||
func (l *Listener) Addr() net.Addr {
|
||||
return l.addr
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue