Skip to content

Commit

Permalink
Merge branch 'master' into err
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger authored Sep 14, 2024
2 parents 61fdfb5 + 5169509 commit 67b430a
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 96 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
groups:
all-dependencies:
patterns:
- "*"
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint & Test
on:
pull_request:
push:
branches:
- master

jobs:
test:
uses: SiaFoundation/workflows/.github/workflows/go-test.yml@master
with:
try-build: false
34 changes: 0 additions & 34 deletions .github/workflows/test.yml

This file was deleted.

116 changes: 75 additions & 41 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,8 @@ run:
# list of build tags, all linters use it. Default is empty list.
build-tags: []

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
skip-dirs:
- cover

# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
skip-files: []

# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true

Expand All @@ -50,44 +30,98 @@ linters-settings:
## Enabled linters:
govet:
# report about shadowed variables
check-shadowing: false
disable-all: false

golint:
min-confidence: 1.0
tagliatelle:
case:
rules:
json: goCamel
yaml: goCamel


gocritic:
# Which checks should be enabled; can't be combined with 'disabled-checks';
# See https://go-critic.github.io/overview#checks-overview
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
# By default list of stable checks is used.
enabled-checks:
- argOrder # Diagnostic options
- badCond
- caseOrder
- dupArg
- dupBranchBody
- dupCase
- dupSubExpr
- nilValReturn
- offBy1
- weakCond
- boolExprSimplify # Style options here and below.
- builtinShadow
- emptyFallthrough
- hexLiteral
- underef
- equalFold
enabled-tags:
- diagnostic
- style
disabled-checks:
# diagnostic
- commentedOutCode
- uncheckedInlineErr

# style
- emptyStringTest
- exitAfterDefer
- ifElseChain
- importShadow
- initClause
- nestingReduce
- octalLiteral
- paramTypeCombine
- ptrToRefParam
- stringsCompare
- tooManyResultsChecker
- typeDefFirst
- typeUnparen
- unlabelStmt
- unnamedResult
- whyNoLint
revive:
ignore-generated-header: true
rules:
- name: blank-imports
disabled: false
- name: bool-literal-in-expr
disabled: false
- name: confusing-naming
disabled: false
- name: confusing-results
disabled: false
- name: constant-logical-expr
disabled: false
- name: context-as-argument
disabled: false
- name: exported
disabled: false
- name: errorf
disabled: false
- name: if-return
disabled: false
- name: indent-error-flow
disabled: true
- name: increment-decrement
disabled: false
- name: modifies-value-receiver
disabled: true
- name: optimize-operands-order
disabled: false
- name: range-val-in-closure
disabled: false
- name: struct-tag
disabled: false
- name: superfluous-else
disabled: false
- name: time-equal
disabled: false
- name: unexported-naming
disabled: false
- name: unexported-return
disabled: false
- name: unnecessary-stmt
disabled: false
- name: unreachable-code
disabled: false
- name: package-comments
disabled: true

linters:
disable-all: true
fast: false
enable:
- tagliatelle
- gocritic
- gofmt
- revive
Expand All @@ -113,4 +147,4 @@ issues:
# it can be disabled by this option. To list all
# excluded by default patterns execute `golangci-lint run --help`.
# Default value for this option is true.
exclude-use-default: false
exclude-use-default: false
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module go.sia.tech/mux

go 1.17
go 1.23

require (
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122
golang.org/x/crypto v0.27.0
lukechampine.com/frand v1.4.2
)

require (
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
golang.org/x/sys v0.25.0 // indirect
)
14 changes: 4 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY=
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122 h1:NvGWuYG8dkDHFSKksI1P9faiVJ9rayE6l0+ouWVIDs8=
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
lukechampine.com/frand v1.4.2 h1:RzFIpOvkMXuPMBb9maa4ND4wjBn71E1Jpf8BzJHMaVw=
lukechampine.com/frand v1.4.2/go.mod h1:4S/TM2ZgrKejMcKMbeLjISpJMO+/eZ1zu3vYX9dtj3s=
3 changes: 1 addition & 2 deletions v1/errors_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import (
// isConnCloseError returns true if the error is from the peer closing the
// connection early.
func isConnCloseError(err error) bool {
const WSAEPROTOTYPE = syscall.Errno(10041)
return errors.Is(err, io.EOF) ||
errors.Is(err, WSAEPROTOTYPE) ||
errors.Is(err, syscall.Errno(10041)) || // WSAEPROTOTYPE
errors.Is(err, syscall.WSAECONNABORTED) ||
errors.Is(err, syscall.WSAECONNRESET)
}
3 changes: 1 addition & 2 deletions v2/errors_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import (
// isConnCloseError returns true if the error is from the peer closing the
// connection early.
func isConnCloseError(err error) bool {
const WSAEPROTOTYPE = syscall.Errno(10041)
return errors.Is(err, io.EOF) ||
errors.Is(err, WSAEPROTOTYPE) ||
errors.Is(err, syscall.Errno(10041)) || // WSAEPROTOTYPE
errors.Is(err, syscall.WSAECONNABORTED) ||
errors.Is(err, syscall.WSAECONNRESET)
}
8 changes: 4 additions & 4 deletions v2/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ func initiateHandshake(conn net.Conn, theirKey ed25519.PublicKey, ourSettings co

// write pubkey
buf := make([]byte, 32+64+connSettingsSize+chachaPoly1305TagSize)
copy(buf[:], xpk[:])
copy(buf, xpk[:])
if _, err := conn.Write(buf[:32]); err != nil {
return nil, connSettings{}, fmt.Errorf("could not write handshake request: %w", err)
}
// read pubkey, signature, and settings
if _, err := io.ReadFull(conn, buf[:]); err != nil {
if _, err := io.ReadFull(conn, buf); err != nil {
return nil, connSettings{}, fmt.Errorf("could not read handshake response: %w", err)
}

Expand Down Expand Up @@ -166,7 +166,7 @@ func initiateHandshake(conn net.Conn, theirKey ed25519.PublicKey, ourSettings co
}

// encrypt + write our settings
encodeConnSettings(buf[:], ourSettings)
encodeConnSettings(buf, ourSettings)
cipher.encryptInPlace(buf[:connSettingsSize+chachaPoly1305TagSize])
if _, err := conn.Write(buf[:connSettingsSize+chachaPoly1305TagSize]); err != nil {
return nil, connSettings{}, fmt.Errorf("could not write settings: %w", err)
Expand Down Expand Up @@ -195,7 +195,7 @@ func acceptHandshake(conn net.Conn, ourKey ed25519.PrivateKey, ourSettings connS
// write pubkey, signature, and settings
sigHash := blake2b.Sum256(append(rxpk[:], xpk[:]...))
sig := ed25519.Sign(ourKey, sigHash[:])
copy(buf[:], xpk[:])
copy(buf, xpk[:])
copy(buf[32:], sig)
encodeConnSettings(buf[32+64:], ourSettings)
cipher.encryptInPlace(buf[32+64:])
Expand Down

0 comments on commit 67b430a

Please sign in to comment.