Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fclairamb committed Mar 3, 2024
1 parent 7ca9755 commit bae3ef9
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
13 changes: 11 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,28 +181,37 @@ linters:
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
# - exhaustruct --> Not convinced it's useful
# - exhaustivestruct
- exportloopref
- funlen
# - gci
- forbidigo
- forcetypeassert
- gci
- ginkgolinter
- gochecknoinits
- gochecksumtype
# - gochecknoglobals
- gocognit
- goconst
- gocritic
- gocyclo
# - godot --> lots of not so useful changes
- godox
- goerr113
- gofmt
- goimports
- gosimple
# - golint --> revive
- revive
# - gomnd
# - gomnd --> too much work
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- ineffassign
# - interfacer --> (deprecated)
- lll
Expand Down
4 changes: 3 additions & 1 deletion asciiconverter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type convertMode int8
const (
convertModeToCRLF convertMode = iota
convertModeToLF

bufferSize = 4096
)

type asciiConverter struct {
Expand All @@ -19,7 +21,7 @@ type asciiConverter struct {
}

func newASCIIConverter(r io.Reader, mode convertMode) *asciiConverter {
reader := bufio.NewReaderSize(r, 4096)
reader := bufio.NewReaderSize(r, bufferSize)

return &asciiConverter{
reader: reader,
Expand Down
4 changes: 2 additions & 2 deletions client_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
log "github.com/fclairamb/go-log"
)

// HASHAlgo is the enumerable that represents the supported HASH algorithms
// HASHAlgo is the enumerable that represents the supported HASH algorithms.
type HASHAlgo int8

// Supported hash algorithms
Expand All @@ -25,7 +25,7 @@ const (
HASHAlgoSHA512
)

// TransferType is the enumerable that represents the supported transfer types
// TransferType is the enumerable that represents the supported transfer types.
type TransferType int8

// Supported transfer type
Expand Down
3 changes: 2 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ func (server *FtpServer) Serve() error {
// & https://github.com/fclairamb/ftpserverlib/pull/352#pullrequestreview-1077459896
// The temporaryError method should replace net.Error.Temporary() when the go team
// will have provided us a better way to detect temporary errors.
if ne, ok := err.(net.Error); ok && ne.Temporary() { //nolint:staticcheck
var ne net.Error
if errors.Is(err, ne) && ne.Temporary() { //nolint:staticcheck
if tempDelay == 0 {
tempDelay = 5 * time.Millisecond
} else {
Expand Down
4 changes: 1 addition & 3 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ftpserver

import (
"errors"
"fmt"
"net"
"os"
"syscall"
Expand All @@ -18,8 +17,7 @@ func TestMain(m *testing.M) {
// we change the timezone to be able to test that MLSD/MLST commands write UTC timestamps
loc, err := time.LoadLocation("America/New_York")
if err != nil {
fmt.Printf("unable to set timezone: %v\n", err)
os.Exit(1)
panic(err)
}

time.Local = loc
Expand Down
2 changes: 1 addition & 1 deletion transfer_pasv.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (c *clientHandler) handlePASV(_ string) error {
}
}

p := &passiveTransferHandler{
p := &passiveTransferHandler{ //nolint:forcetypeassert
tcpListener: tcpListener,
listener: listener,
Port: tcpListener.Addr().(*net.TCPAddr).Port,
Expand Down
2 changes: 1 addition & 1 deletion transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ func TestPASVConnectionWait(t *testing.T) {
},
}

p := passiveTransferHandler{
p := passiveTransferHandler{ //nolint:forcetypeassert
listener: &testNetListener{
conn: &testNetConn{
remoteAddr: &net.TCPAddr{IP: nil, Port: 21}, // invalid IP
Expand Down

0 comments on commit bae3ef9

Please sign in to comment.