Skip to content

Commit

Permalink
server: update lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0Vu committed Oct 23, 2023
1 parent 53e8faf commit e3dc34e
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
7 changes: 5 additions & 2 deletions server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ default: lint test

.PHONY: lint
lint:
# go get github.com/golangci/golangci-lint/cmd/[email protected]
# $(GOPATH)/bin/golangci-lint run -e gosec ./... --timeout 2m
# cd ../tools && go install github.com/golangci/golangci-lint/cmd/golangci-lint
# $(GOPATH)/bin/golangci-lint run -e gosec ./... --timeout=2m
cd ../ test && go install honnef.co/go/tools/cmd/staticcheck@latest
$(GOPATH)/bin/staticcheck ./...
go vet ./...
go fmt ./...
go mod tidy

Expand Down
1 change: 0 additions & 1 deletion server/cborplugin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
// as described in our Kaetzchen specification document:
//
// https://github.com/katzenpost/docs/blob/master/specs/kaetzchen.rst
//
package cborplugin

import (
Expand Down
5 changes: 2 additions & 3 deletions server/cmd/meson-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package main

import (
Expand Down Expand Up @@ -61,10 +60,10 @@ func main() {
}

// Setup the signal handling.
haltCh := make(chan os.Signal)
haltCh := make(chan os.Signal, 1)
signal.Notify(haltCh, os.Interrupt, syscall.SIGTERM) // nolint

rotateCh := make(chan os.Signal)
rotateCh := make(chan os.Signal, 1)
signal.Notify(rotateCh, syscall.SIGHUP) // nolint

// Start up the server.
Expand Down
4 changes: 2 additions & 2 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ func Store(cfg *Config, fileName string) error {
// returns the Config.
func Load(b []byte) (*Config, error) {
if b == nil {
return nil, errors.New("No nil buffer as config file")
return nil, errors.New("no nil buffer as config file")
}

cfg := new(Config)
Expand All @@ -918,7 +918,7 @@ func Load(b []byte) (*Config, error) {
return nil, err
}
if undecoded := md.Undecoded(); len(undecoded) != 0 {
return nil, fmt.Errorf("config: Undecoded keys in config file: %v", undecoded)
return nil, fmt.Errorf("undecoded keys in config file: %v", undecoded)
}
if err := cfg.FixupAndValidate(); err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions server/internal/incoming/incoming_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ func (c *incomingConn) worker() {
defer c.w.Close()

// Bind the session to the conn, handshake, authenticate.
timeoutMs := time.Duration(c.l.glue.Config().Debug.HandshakeTimeout) * time.Millisecond
_ = c.c.SetDeadline(time.Now().Add(timeoutMs))
timeoutDu := time.Duration(c.l.glue.Config().Debug.HandshakeTimeout) * time.Millisecond
_ = c.c.SetDeadline(time.Now().Add(timeoutDu))
if err = c.w.Initialize(c.c); err != nil {
c.log.Errorf("Handshake failed: %v", err)
return
Expand Down Expand Up @@ -233,8 +233,8 @@ func (c *incomingConn) worker() {
}

// Start the reauthenticate ticker.
reauthMs := time.Duration(c.l.glue.Config().Debug.ReauthInterval) * time.Millisecond
reauth := time.NewTicker(reauthMs)
reauthDu := time.Duration(c.l.glue.Config().Debug.ReauthInterval) * time.Millisecond
reauth := time.NewTicker(reauthDu)
defer reauth.Stop()

// Start reading from the peer.
Expand Down
8 changes: 4 additions & 4 deletions server/internal/outgoing/outgoing_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ func (c *outgoingConn) onConnEstablished(conn net.Conn, closeCh <-chan struct{})
defer w.Close()

// Bind the session to the conn, handshake, authenticate.
timeoutMs := time.Duration(c.co.glue.Config().Debug.HandshakeTimeout) * time.Millisecond
_ = conn.SetDeadline(time.Now().Add(timeoutMs))
timeoutDu := time.Duration(c.co.glue.Config().Debug.HandshakeTimeout) * time.Millisecond
_ = conn.SetDeadline(time.Now().Add(timeoutDu))
if err = w.Initialize(conn); err != nil {
c.log.Errorf("Handshake failed: %v", err)
return
Expand Down Expand Up @@ -326,8 +326,8 @@ func (c *outgoingConn) onConnEstablished(conn net.Conn, closeCh <-chan struct{})
}()

// Start the reauthenticate ticker.
reauthMs := time.Duration(c.co.glue.Config().Debug.ReauthInterval) * time.Millisecond
reauth := time.NewTicker(reauthMs)
reauthDu := time.Duration(c.co.glue.Config().Debug.ReauthInterval) * time.Millisecond
reauth := time.NewTicker(reauthDu)
defer reauth.Stop()

// Shuffle packets from the send queue out to the peer.
Expand Down
2 changes: 1 addition & 1 deletion server/internal/packet/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (pkt *Packet) copyToRaw(b []byte) error {
func (pkt *Packet) disposeRaw() {
if len(pkt.Raw) == constants.PacketLength {
utils.ExplicitBzero(pkt.Raw)
rawPacketPool.Put(pkt.Raw) // nolint: megacheck
rawPacketPool.Put(&pkt.Raw) // nolint: megacheck
}
pkt.Raw = nil
}
Expand Down
4 changes: 2 additions & 2 deletions server/internal/pki/pki.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ func (p *pki) GetRawConsensus(epoch uint64) ([]byte, error) {

func (p *pki) Now() (epoch uint64, ellapsed time.Duration, till time.Duration, err error) {
if p.impl == nil {
return 0, 0, 0, fmt.Errorf("PKI client uninitialized.")
return 0, 0, 0, fmt.Errorf("PKI client uninitialized")
}
return epochtime.Now(p.impl)
}
Expand Down Expand Up @@ -732,7 +732,7 @@ func New(glue glue.Glue) (glue.PKI, error) {
}

if len(p.descAddrMap) == 0 {
return nil, errors.New("Descriptor address map is zero size.")
return nil, errors.New("descriptor address map is zero size")
}

if glue.Config().PKI.Nonvoting != nil {
Expand Down
3 changes: 1 addition & 2 deletions server/internal/provider/kaetzchen/kaetzchen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/katzenpost/core/log"
"github.com/katzenpost/core/monotime"
"github.com/katzenpost/core/sphinx/commands"
"github.com/katzenpost/core/sphinx/constants"
sConstants "github.com/katzenpost/core/sphinx/constants"
"github.com/katzenpost/core/thwack"
"github.com/katzenpost/core/wire"
Expand Down Expand Up @@ -70,7 +69,7 @@ type mockSpool struct{}

func (s *mockSpool) StoreMessage(u, msg []byte) error { return nil }

func (s *mockSpool) StoreSURBReply(u []byte, id *[constants.SURBIDLength]byte, msg []byte) error {
func (s *mockSpool) StoreSURBReply(u []byte, id *[sConstants.SURBIDLength]byte, msg []byte) error {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions server/userdb/externuserdb/externuserdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
)

var (
errCantModify = errors.New("Not implemented: External authentication is enabled, you can not modify users")
errNotSupported = errors.New("Not implemented: Support not implemented yet")
errCantModify = errors.New("not implemented: External authentication is enabled, you can not modify users")
errNotSupported = errors.New("not implemented: Support not implemented yet")
jsonHandle = &codec.JsonHandle{}
)

Expand Down

0 comments on commit e3dc34e

Please sign in to comment.