all: Remove dead code, fix lost msgLen checks (#6129)
This commit is contained in:
committed by
Jakob Borg
parent
31569debeb
commit
98a1adebe1
@@ -7,37 +7,9 @@
|
||||
package osutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net"
|
||||
)
|
||||
|
||||
// ResolveInterfaceAddresses returns available addresses of the given network
|
||||
// type for a given interface.
|
||||
func ResolveInterfaceAddresses(network, nameOrMac string) []string {
|
||||
intf, err := net.InterfaceByName(nameOrMac)
|
||||
if err == nil {
|
||||
return interfaceAddresses(network, intf)
|
||||
}
|
||||
|
||||
mac, err := net.ParseMAC(nameOrMac)
|
||||
if err != nil {
|
||||
return []string{nameOrMac}
|
||||
}
|
||||
|
||||
intfs, err := net.Interfaces()
|
||||
if err != nil {
|
||||
return []string{nameOrMac}
|
||||
}
|
||||
|
||||
for _, intf := range intfs {
|
||||
if bytes.Equal(intf.HardwareAddr, mac) {
|
||||
return interfaceAddresses(network, &intf)
|
||||
}
|
||||
}
|
||||
|
||||
return []string{nameOrMac}
|
||||
}
|
||||
|
||||
func interfaceAddresses(network string, intf *net.Interface) []string {
|
||||
var out []string
|
||||
addrs, err := intf.Addrs()
|
||||
|
||||
@@ -79,28 +79,6 @@ const (
|
||||
stateReady
|
||||
)
|
||||
|
||||
// Request message flags
|
||||
const (
|
||||
FlagFromTemporary uint32 = 1 << iota
|
||||
)
|
||||
|
||||
// ClusterConfigMessage.Folders flags
|
||||
const (
|
||||
FlagFolderReadOnly uint32 = 1 << 0
|
||||
FlagFolderIgnorePerms = 1 << 1
|
||||
FlagFolderIgnoreDelete = 1 << 2
|
||||
FlagFolderDisabledTempIndexes = 1 << 3
|
||||
FlagFolderAll = 1<<4 - 1
|
||||
)
|
||||
|
||||
// ClusterConfigMessage.Folders.Devices flags
|
||||
const (
|
||||
FlagShareTrusted uint32 = 1 << 0
|
||||
FlagShareReadOnly = 1 << 1
|
||||
FlagIntroducer = 1 << 2
|
||||
FlagShareBits = 0x000000ff
|
||||
)
|
||||
|
||||
// FileInfo.LocalFlags flags
|
||||
const (
|
||||
FlagLocalUnsupported = 1 << 0 // The kind is unsupported, e.g. symlinks on Windows
|
||||
@@ -120,15 +98,14 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrClosed = errors.New("connection closed")
|
||||
ErrTimeout = errors.New("read timeout")
|
||||
ErrSwitchingConnections = errors.New("switching connections")
|
||||
errUnknownMessage = errors.New("unknown message")
|
||||
errInvalidFilename = errors.New("filename is invalid")
|
||||
errUncleanFilename = errors.New("filename not in canonical format")
|
||||
errDeletedHasBlocks = errors.New("deleted file with non-empty block list")
|
||||
errDirectoryHasBlocks = errors.New("directory with non-empty block list")
|
||||
errFileHasNoBlocks = errors.New("file with empty block list")
|
||||
ErrClosed = errors.New("connection closed")
|
||||
ErrTimeout = errors.New("read timeout")
|
||||
errUnknownMessage = errors.New("unknown message")
|
||||
errInvalidFilename = errors.New("filename is invalid")
|
||||
errUncleanFilename = errors.New("filename not in canonical format")
|
||||
errDeletedHasBlocks = errors.New("deleted file with non-empty block list")
|
||||
errDirectoryHasBlocks = errors.New("directory with non-empty block list")
|
||||
errFileHasNoBlocks = errors.New("file with empty block list")
|
||||
)
|
||||
|
||||
type Model interface {
|
||||
@@ -491,6 +468,8 @@ func (c *rawConnection) readMessageAfterHeader(hdr Header, fourByteBuf []byte) (
|
||||
msgLen := int32(binary.BigEndian.Uint32(fourByteBuf))
|
||||
if msgLen < 0 {
|
||||
return nil, fmt.Errorf("negative message length %d", msgLen)
|
||||
} else if msgLen > MaxMessageLen {
|
||||
return nil, fmt.Errorf("message length %d exceeds maximum %d", msgLen, MaxMessageLen)
|
||||
}
|
||||
|
||||
// Then comes the message
|
||||
|
||||
@@ -16,7 +16,6 @@ var (
|
||||
ResponseSuccess = Response{0, "success"}
|
||||
ResponseNotFound = Response{1, "not found"}
|
||||
ResponseAlreadyConnected = Response{2, "already connected"}
|
||||
ResponseInternalError = Response{99, "internal error"}
|
||||
ResponseUnexpectedMessage = Response{100, "unexpected message"}
|
||||
)
|
||||
|
||||
|
||||
@@ -28,11 +28,6 @@ const (
|
||||
minioImpl = "minio/sha256-simd"
|
||||
)
|
||||
|
||||
const (
|
||||
BlockSize = cryptoSha256.BlockSize
|
||||
Size = cryptoSha256.Size
|
||||
)
|
||||
|
||||
// May be switched out for another implementation
|
||||
var (
|
||||
New = cryptoSha256.New
|
||||
|
||||
@@ -47,11 +47,16 @@ const (
|
||||
|
||||
type ExitStatus int
|
||||
|
||||
func (s ExitStatus) AsInt() int {
|
||||
return int(s)
|
||||
}
|
||||
|
||||
const (
|
||||
ExitSuccess ExitStatus = 0
|
||||
ExitError ExitStatus = 1
|
||||
ExitRestart ExitStatus = 3
|
||||
ExitUpgrade ExitStatus = 4
|
||||
ExitSuccess ExitStatus = 0
|
||||
ExitError ExitStatus = 1
|
||||
ExitNoUpgradeAvailable ExitStatus = 2
|
||||
ExitRestart ExitStatus = 3
|
||||
ExitUpgrade ExitStatus = 4
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
|
||||
@@ -37,7 +37,6 @@ type Asset struct {
|
||||
}
|
||||
|
||||
var (
|
||||
ErrVersionUpToDate = errors.New("current version is up to date")
|
||||
ErrNoReleaseDownload = errors.New("couldn't find a release to download")
|
||||
ErrNoVersionToSelect = errors.New("no version to select")
|
||||
ErrUpgradeUnsupported = errors.New("upgrade unsupported")
|
||||
|
||||
Reference in New Issue
Block a user