Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test against 1.20 #11

Merged
merged 6 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,17 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [1.13, 1.14]
go: [1.16, 1.17]
steps:
- name: Set up Go
uses: actions/setup-go@v1
uses: actions/setup-go@331ce1d993939866bb63c32c6cbbfd48fa76fc57 #v2
with:
go-version: ${{ matrix.go }}
- name: Check out source
uses: actions/checkout@v1
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install librsync-dev
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f #v2.3.4
- name: Install Linters
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.25.0"
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.44.0"
- name: Build
env:
GO111MODULE: "on"
run: go build ./...
- name: Lint
env:
GO111MODULE: "on"
run: |
export PATH=${PATH}:$(go env GOPATH)/bin
golangci-lint run --disable-all --deadline=10m --enable=gofmt --enable=golint --enable=govet --enable=gosimple --enable=ineffassign
run: golangci-lint run --disable-all --deadline=10m --enable=gofmt --enable=revive --enable=govet --enable=gosimple --enable=ineffassign
57 changes: 48 additions & 9 deletions backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,56 @@ func backup(ctx context.Context, pubKey *stream.PublicKey, cfg *config) error {
if !bytes.Equal(currentSig.Bytes(), thisSig.Bytes()) {
if currentSig.Len() != 0 {
log.Printf("%q: changed", srcPath)
delta.Reset()
readBuffer.Reset(currentSig.Bytes())
err = rsync.GenDelta(readBuffer, srcFD, info.Size(), delta)
if err != nil {
srcFD.Close()
return err
}
readBuffer.Reset(delta.Bytes())

err = snap.Add(MD, readBuffer, int64(readBuffer.Len()))
readBuffer.Reset(nil)
if info.Size() > memoryLimit*10 {
tmpFile, err := os.CreateTemp(cfg.BackupPath, "delta")
if err != nil {
srcFD.Close()
return err
}
err = rsync.GenDelta(readBuffer, srcFD, info.Size(), tmpFile)
if err != nil {
tmpFile.Close()
os.Remove(tmpFile.Name())
srcFD.Close()
return err
}
if _, err = tmpFile.Seek(0, 0); err != nil {
tmpFile.Close()
os.Remove(tmpFile.Name())
srcFD.Close()
return err
}
tmpFileInfo, err := tmpFile.Stat()
if err != nil {
tmpFile.Close()
os.Remove(tmpFile.Name())
srcFD.Close()
return err
}
err = snap.Add(MD, tmpFile, tmpFileInfo.Size())
if err != nil {
tmpFile.Close()
os.Remove(tmpFile.Name())
srcFD.Close()
return err
}
tmpFile.Close()
os.Remove(tmpFile.Name())
} else {
delta.Reset()
readBuffer.Reset(currentSig.Bytes())
err = rsync.GenDelta(readBuffer, srcFD, info.Size(), delta)
if err != nil {
srcFD.Close()
return err
}
readBuffer.Reset(delta.Bytes())

err = snap.Add(MD, readBuffer, int64(readBuffer.Len()))
readBuffer.Reset(nil)
}
} else {
log.Printf("%q new file", srcPath)
st, err := srcFD.Stat()
Expand Down
20 changes: 13 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
module github.com/companyzero/multus
module multus

go 1.13
go 1.17

require (
github.com/jrick/ss v0.9.1
github.com/smtc/rsync v0.0.0-20151014010438-0a038bb0deb8
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/companyzero/sntrup4591761 v0.0.0-20200131011700-2b0d299dbd22 // indirect
github.com/dchest/blake2b v1.0.0 // indirect
github.com/jrick/ss v0.7.1
github.com/smtc/rollsum v0.0.0-20150721100732-39e98d252100 // indirect
github.com/smtc/rsync v0.0.0-20151014010438-0a038bb0deb8
github.com/smtc/seekbuffer v0.0.0-20151009054628-711359748967 // indirect
golang.org/x/crypto v0.0.0-20200420201142-3c4aac89819a
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
gopkg.in/yaml.v2 v2.2.8
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
)
39 changes: 22 additions & 17 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
github.com/companyzero/sntrup4591761 v0.0.0-20190320150934-1ea2d0911e48 h1:5J5+W6LVdeJeHzqrNARVzXGD/u0jqZ+yiFYWhkHMnts=
github.com/companyzero/sntrup4591761 v0.0.0-20190320150934-1ea2d0911e48/go.mod h1:mqO8bOUjFw4AUP6X5CFkXV4IZJXnDy7oghYhbVsDb2M=
github.com/companyzero/sntrup4591761 v0.0.0-20200131011700-2b0d299dbd22 h1:vfqLMkB1UqwJliW0I/34oscQawInrVfL1uPjGEEt2YY=
github.com/companyzero/sntrup4591761 v0.0.0-20200131011700-2b0d299dbd22/go.mod h1:LoZJNGDWmVPqMEHmeJzj4Weq4Stjc6FKY6FVpY3Hem0=
github.com/dchest/blake2b v1.0.0 h1:KK9LimVmE0MjRl9095XJmKqZ+iLxWATvlcpVFRtaw6s=
github.com/dchest/blake2b v1.0.0/go.mod h1:U034kXgbJpCle2wSk5ybGIVhOSHCVLMDqOzcPEA0F7s=
github.com/jrick/ss v0.7.1 h1:K+jbI52c3EdymccQ3V/9I7Acl0h2BX1LrOshrgQoPhQ=
github.com/jrick/ss v0.7.1/go.mod h1:/91cAb72OoOtQF89O4moKsXZ6cRKO1PH1AdmIROOGT8=
github.com/jrick/ss v0.9.1 h1:rdWjwsHrCiGC947XAQ3hGgzSFNeHjHflRC9X+1Z8uPU=
github.com/jrick/ss v0.9.1/go.mod h1:tA2uBeHeEKpXG3LfCfPo/sMG7Q2yOxP5d2ctIV6Rx8c=
github.com/smtc/rollsum v0.0.0-20150721100732-39e98d252100 h1:i0RlfVCicU2hdE7lSl0e8VxJtJIpfLhvyZXdb4VGHmY=
github.com/smtc/rollsum v0.0.0-20150721100732-39e98d252100/go.mod h1:6sQHUq9MNR2x9+cpk8+oegntSXGnXHopnOv92j2tikk=
github.com/smtc/rsync v0.0.0-20151014010438-0a038bb0deb8 h1:PKRycleyjjrjXOvzSgkM/J6aBg/qv3V5V3QwrqpkC8k=
github.com/smtc/rsync v0.0.0-20151014010438-0a038bb0deb8/go.mod h1:oq5k6hI+1FWgfZnl/CUunoN5tQDJkgX5ziiQFPk2ATA=
github.com/smtc/seekbuffer v0.0.0-20151009054628-711359748967 h1:W1sTuG/sEqqum0BZ6bI1V++UqMJ+dxoeX7Biz7EarmE=
github.com/smtc/seekbuffer v0.0.0-20151009054628-711359748967/go.mod h1:yaoAwyoO9sNREC+8EVI+DgdGfUpMTVR9XzqxS7yGRF4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200420201142-3c4aac89819a h1:y6sBfNd1b9Wy08a6K1Z1DZc4aXABUN5TKjkYhz7UKmo=
golang.org/x/crypto v0.0.0-20200420201142-3c4aac89819a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03iWnKLEWinaScsxF2Vm2o=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce h1:Roh6XWxHFKrPgC/EQhVubSAGQ6Ozk6IdxHSzt1mR0EI=
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
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 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
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=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"strconv"

"github.com/jrick/ss/keyfile"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
)

const FormatVersion = uint16(1)
Expand Down Expand Up @@ -52,7 +52,7 @@ func main() {

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
signals := make(chan os.Signal)
signals := make(chan os.Signal, 1)
signal.Notify(signals, os.Interrupt)
go func() {
for sig := range signals {
Expand Down Expand Up @@ -111,7 +111,7 @@ func main() {
os.Exit(1)
}
fmt.Fprintf(os.Stderr, "%q secret: ", cfg.Restore.SecretFile)
secret, err := terminal.ReadPassword(int(os.Stdin.Fd()))
secret, err := term.ReadPassword(int(os.Stdin.Fd()))
fmt.Fprint(os.Stderr, "\n")
if err != nil {
fmt.Fprintln(os.Stderr, err)
Expand Down Expand Up @@ -161,7 +161,7 @@ func main() {
os.Exit(1)
}
fmt.Fprintf(os.Stderr, "%q secret: ", cfg.Restore.SecretFile)
secret, err := terminal.ReadPassword(int(os.Stdin.Fd()))
secret, err := term.ReadPassword(int(os.Stdin.Fd()))
fmt.Fprint(os.Stderr, "\n")
if err != nil {
fmt.Fprintln(os.Stderr, err)
Expand Down