From 95de3790d7b7b10b00701ea2cf2fd75af16d797f Mon Sep 17 00:00:00 2001 From: Prince Date: Tue, 3 Sep 2024 18:27:19 -0700 Subject: [PATCH 1/9] added signal for programme termination --- main.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 65ad69a..b29bb9d 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,9 @@ package main import ( "log" + "os" + "os/signal" + "syscall" "github.com/schollz/croc/v10/src/cli" ) @@ -27,7 +30,24 @@ func main() { // fmt.Println("wrote profile") // } // }() - if err := cli.Run(); err != nil { - log.Fatalln(err) - } + + // Create a channel to receive OS signals + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) + + go func() { + if err := cli.Run(); err != nil { + log.Fatalln(err) + } + }() + + // Wait for a termination signal + sig := <-sigs + log.Println("Received signal:", sig) + + // Perform any necessary cleanup here + log.Println("Performing cleanup...") + + // Exit the program gracefully + os.Exit(0) } From 0d8e4e10d621bb9268a02a9641db0c83b475e1ed Mon Sep 17 00:00:00 2001 From: Prince Date: Tue, 3 Sep 2024 18:56:46 -0700 Subject: [PATCH 2/9] added cleanup function to remove temporary file --- device-a/text.txt | 1 + main.go | 2 ++ src/cli/cli.go | 10 ++++++++-- src/utils/utils.go | 10 ++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 device-a/text.txt diff --git a/device-a/text.txt b/device-a/text.txt new file mode 100644 index 0000000..5e40c08 --- /dev/null +++ b/device-a/text.txt @@ -0,0 +1 @@ +asdf \ No newline at end of file diff --git a/main.go b/main.go index b29bb9d..f36d2e8 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "syscall" "github.com/schollz/croc/v10/src/cli" + "github.com/schollz/croc/v10/src/utils" ) func main() { @@ -47,6 +48,7 @@ func main() { // Perform any necessary cleanup here log.Println("Performing cleanup...") + utils.CleanupTempData() // Exit the program gracefully os.Exit(0) diff --git a/src/cli/cli.go b/src/cli/cli.go index d65281a..fa85608 100644 --- a/src/cli/cli.go +++ b/src/cli/cli.go @@ -446,9 +446,15 @@ func getStdin() (fnames []string, err error) { fnames = []string{f.Name()} return } - +func makeTempFolder() { + path := "temp" + if _, err := os.Stat(path); os.IsNotExist(err) { + os.Mkdir(path, os.ModePerm) + } +} func makeTempFileWithString(s string) (fnames []string, err error) { - f, err := os.CreateTemp(".", "croc-stdin-") + makeTempFolder() + f, err := os.CreateTemp("temp", "croc-stdin-") if err != nil { return } diff --git a/src/utils/utils.go b/src/utils/utils.go index 1f09c2a..f55bb70 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -610,3 +610,13 @@ func ValidFileName(fname string) (err error) { } return } +func CleanupTempData() { + path := "temp" + // Remove the directory and its contents + err := os.RemoveAll(path) + if err != nil { + log.Fatal(err) + } else { + log.Println("Directory and its contents deleted successfully") + } +} From 986d005449ae3589c0437c5f63b0dd04d4dd4619 Mon Sep 17 00:00:00 2001 From: Prince Date: Tue, 3 Sep 2024 19:43:28 -0700 Subject: [PATCH 3/9] removed unnessary file --- device-a/text.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 device-a/text.txt diff --git a/device-a/text.txt b/device-a/text.txt deleted file mode 100644 index 5e40c08..0000000 --- a/device-a/text.txt +++ /dev/null @@ -1 +0,0 @@ -asdf \ No newline at end of file From e663aa90cb640f7e05d0d8bb8aae85845308c04a Mon Sep 17 00:00:00 2001 From: Prince Date: Tue, 3 Sep 2024 19:49:56 -0700 Subject: [PATCH 4/9] updated log message --- src/utils/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/utils.go b/src/utils/utils.go index f55bb70..3538aa8 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -617,6 +617,6 @@ func CleanupTempData() { if err != nil { log.Fatal(err) } else { - log.Println("Directory and its contents deleted successfully") + log.Println("temp directory and its contents deleted successfully") } } From 149d7364fb463b8f2c6e97c6581b95af0718c014 Mon Sep 17 00:00:00 2001 From: Zack Date: Tue, 3 Sep 2024 09:16:07 -0700 Subject: [PATCH 5/9] simplify cleanup --- main.go | 5 ----- src/utils/utils.go | 10 ---------- 2 files changed, 15 deletions(-) diff --git a/main.go b/main.go index f36d2e8..a2e9f8e 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,6 @@ import ( "syscall" "github.com/schollz/croc/v10/src/cli" - "github.com/schollz/croc/v10/src/utils" ) func main() { @@ -46,10 +45,6 @@ func main() { sig := <-sigs log.Println("Received signal:", sig) - // Perform any necessary cleanup here - log.Println("Performing cleanup...") - utils.CleanupTempData() - // Exit the program gracefully os.Exit(0) } diff --git a/src/utils/utils.go b/src/utils/utils.go index 3538aa8..1f09c2a 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -610,13 +610,3 @@ func ValidFileName(fname string) (err error) { } return } -func CleanupTempData() { - path := "temp" - // Remove the directory and its contents - err := os.RemoveAll(path) - if err != nil { - log.Fatal(err) - } else { - log.Println("temp directory and its contents deleted successfully") - } -} From bb74eafd36e07dbd6cbd64cf9315ee8210bd9e1d Mon Sep 17 00:00:00 2001 From: Zack Date: Tue, 3 Sep 2024 09:28:42 -0700 Subject: [PATCH 6/9] Remove Temporary Files if the program terminates abnormal. Fixes #799 --- main.go | 11 +++++--- src/cli/cli.go | 12 +++------ src/croc/croc.go | 1 + src/utils/utils.go | 63 +++++++++++++++++++++++++++++++++++----------- 4 files changed, 61 insertions(+), 26 deletions(-) diff --git a/main.go b/main.go index a2e9f8e..bb220fe 100644 --- a/main.go +++ b/main.go @@ -5,12 +5,13 @@ package main //go:generate git tag -af v$VERSION -m "v$VERSION" import ( - "log" "os" "os/signal" "syscall" "github.com/schollz/croc/v10/src/cli" + "github.com/schollz/croc/v10/src/utils" + log "github.com/schollz/logger" ) func main() { @@ -37,13 +38,17 @@ func main() { go func() { if err := cli.Run(); err != nil { - log.Fatalln(err) + log.Error(err) } + // Exit the program gracefully + utils.RemoveMarkedFiles() + os.Exit(0) }() // Wait for a termination signal sig := <-sigs - log.Println("Received signal:", sig) + log.Debugf("Received signal:", sig) + utils.RemoveMarkedFiles() // Exit the program gracefully os.Exit(0) diff --git a/src/cli/cli.go b/src/cli/cli.go index fa85608..11fcf06 100644 --- a/src/cli/cli.go +++ b/src/cli/cli.go @@ -358,6 +358,7 @@ func send(c *cli.Context) (err error) { if err != nil { return } + utils.MarkFileForRemoval(fnames[0]) defer func() { e := os.Remove(fnames[0]) if e != nil { @@ -369,6 +370,7 @@ func send(c *cli.Context) (err error) { if err != nil { return } + utils.MarkFileForRemoval(fnames[0]) defer func() { e := os.Remove(fnames[0]) if e != nil { @@ -446,15 +448,9 @@ func getStdin() (fnames []string, err error) { fnames = []string{f.Name()} return } -func makeTempFolder() { - path := "temp" - if _, err := os.Stat(path); os.IsNotExist(err) { - os.Mkdir(path, os.ModePerm) - } -} + func makeTempFileWithString(s string) (fnames []string, err error) { - makeTempFolder() - f, err := os.CreateTemp("temp", "croc-stdin-") + f, err := os.CreateTemp(".", "croc-stdin-") if err != nil { return } diff --git a/src/croc/croc.go b/src/croc/croc.go index b5e0ed2..2b3f882 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -388,6 +388,7 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool) (filesInfo [] fpath = filepath.Dir(fpath) dest := filepath.Base(fpath) + ".zip" utils.ZipDirectory(dest, fpath) + utils.MarkFileForRemoval(dest) stat, errStat = os.Lstat(dest) if errStat != nil { err = errStat diff --git a/src/utils/utils.go b/src/utils/utils.go index 1f09c2a..136e147 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -11,7 +11,6 @@ import ( "encoding/hex" "fmt" "io" - "log" "math" "math/big" "net" @@ -26,6 +25,7 @@ import ( "github.com/kalafut/imohash" "github.com/minio/highwayhash" "github.com/pion/stun" + log "github.com/schollz/logger" "github.com/schollz/mnemonicode" "github.com/schollz/progressbar/v3" ) @@ -276,7 +276,8 @@ func PublicIP() (ip string, err error) { func LocalIP() string { conn, err := net.Dial("udp", "8.8.8.8:80") if err != nil { - log.Fatal(err) + log.Error(err) + return "" } defer conn.Close() @@ -477,12 +478,12 @@ func IsLocalIP(ipaddress string) bool { func ZipDirectory(destination string, source string) (err error) { if _, err = os.Stat(destination); err == nil { - log.Fatalf("%s file already exists!\n", destination) + log.Errorf("%s file already exists!\n", destination) } fmt.Fprintf(os.Stderr, "Zipping %s to %s\n", source, destination) file, err := os.Create(destination) if err != nil { - log.Fatalln(err) + log.Error(err) } defer file.Close() writer := zip.NewWriter(file) @@ -493,22 +494,22 @@ func ZipDirectory(destination string, source string) (err error) { defer writer.Close() err = filepath.Walk(source, func(path string, info os.FileInfo, err error) error { if err != nil { - log.Fatalln(err) + log.Error(err) } if info.Mode().IsRegular() { f1, err := os.Open(path) if err != nil { - log.Fatalln(err) + log.Error(err) } defer f1.Close() zipPath := strings.ReplaceAll(path, source, strings.TrimSuffix(destination, ".zip")) zipPath = filepath.ToSlash(zipPath) w1, err := writer.Create(zipPath) if err != nil { - log.Fatalln(err) + log.Error(err) } if _, err := io.Copy(w1, f1); err != nil { - log.Fatalln(err) + log.Error(err) } fmt.Fprintf(os.Stderr, "\r\033[2K") fmt.Fprintf(os.Stderr, "\rAdding %s", zipPath) @@ -516,7 +517,7 @@ func ZipDirectory(destination string, source string) (err error) { return nil }) if err != nil { - log.Fatalln(err) + log.Error(err) } fmt.Fprintf(os.Stderr, "\n") return nil @@ -525,7 +526,7 @@ func ZipDirectory(destination string, source string) (err error) { func UnzipDirectory(destination string, source string) error { archive, err := zip.OpenReader(source) if err != nil { - log.Fatalln(err) + log.Error(err) } defer archive.Close() @@ -537,7 +538,7 @@ func UnzipDirectory(destination string, source string) error { // make sure the filepath does not have ".." filePath = filepath.Clean(filePath) if strings.Contains(filePath, "..") { - log.Fatalf("Invalid file path %s\n", filePath) + log.Errorf("Invalid file path %s\n", filePath) } if f.FileInfo().IsDir() { os.MkdirAll(filePath, os.ModePerm) @@ -545,7 +546,7 @@ func UnzipDirectory(destination string, source string) error { } if err := os.MkdirAll(filepath.Dir(filePath), os.ModePerm); err != nil { - log.Fatalln(err) + log.Error(err) } // check if file exists @@ -560,16 +561,16 @@ func UnzipDirectory(destination string, source string) error { dstFile, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode()) if err != nil { - log.Fatalln(err) + log.Error(err) } fileInArchive, err := f.Open() if err != nil { - log.Fatalln(err) + log.Error(err) } if _, err := io.Copy(dstFile, fileInArchive); err != nil { - log.Fatalln(err) + log.Error(err) } dstFile.Close() @@ -610,3 +611,35 @@ func ValidFileName(fname string) (err error) { } return } + +const crocRemovalFile = "croc-marked-files.txt" + +func MarkFileForRemoval(fname string) { + // append the fname to the list of files to remove + f, err := os.OpenFile(crocRemovalFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o600) + if err != nil { + log.Debug(err) + return + } + defer f.Close() + _, err = f.WriteString(fname + "\n") +} + +func RemoveMarkedFiles() (err error) { + // read the file and remove all the files + f, err := os.Open(crocRemovalFile) + if err != nil { + return + } + defer f.Close() + scanner := bufio.NewScanner(f) + for scanner.Scan() { + fname := scanner.Text() + err = os.Remove(fname) + if err == nil { + log.Tracef("Removed %s", fname) + } + } + os.Remove(crocRemovalFile) + return +} From ca8c36f38bd835b6cd8f0cbe03ab7d2f8983fbb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 08:05:41 +0000 Subject: [PATCH 7/9] build(deps): bump golang.org/x/sys from 0.24.0 to 0.25.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.24.0 to 0.25.0. - [Commits](https://github.com/golang/sys/compare/v0.24.0...v0.25.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b320ec9..c35ace7 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/tscholl2/siec v0.0.0-20240310163802-c2c6f6198406 // indirect github.com/twmb/murmur3 v1.1.8 // indirect - golang.org/x/sys v0.24.0 + golang.org/x/sys v0.25.0 golang.org/x/term v0.23.0 golang.org/x/text v0.17.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect diff --git a/go.sum b/go.sum index dfcf604..7863479 100644 --- a/go.sum +++ b/go.sum @@ -145,8 +145,8 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +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= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= From d6f1a63b7be50314fd9cc4b5ecfdc3400059fbbd Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Thu, 5 Sep 2024 06:48:43 -0700 Subject: [PATCH 8/9] update dependencies --- go.mod | 14 +++----------- go.sum | 44 ++++++-------------------------------------- src/utils/utils.go | 2 +- 3 files changed, 10 insertions(+), 50 deletions(-) diff --git a/go.mod b/go.mod index c35ace7..5b9d1d1 100644 --- a/go.mod +++ b/go.mod @@ -22,15 +22,7 @@ require ( require ( github.com/minio/highwayhash v1.0.3 - github.com/pion/stun v0.6.1 -) - -require ( - github.com/pion/dtls/v2 v2.2.12 // indirect - github.com/pion/logging v0.2.2 // indirect - github.com/pion/transport/v2 v2.2.10 // indirect - github.com/pion/transport/v3 v3.0.6 // indirect - github.com/wlynxg/anet v0.0.3 // indirect + gortc.io/stun v1.23.0 ) require ( @@ -46,8 +38,8 @@ require ( github.com/tscholl2/siec v0.0.0-20240310163802-c2c6f6198406 // indirect github.com/twmb/murmur3 v1.1.8 // indirect golang.org/x/sys v0.25.0 - golang.org/x/term v0.23.0 - golang.org/x/text v0.17.0 // indirect + golang.org/x/term v0.24.0 + golang.org/x/text v0.18.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7863479..e9eaed7 100644 --- a/go.sum +++ b/go.sum @@ -34,19 +34,6 @@ github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= -github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s= -github.com/pion/dtls/v2 v2.2.12 h1:KP7H5/c1EiVAAKUmXyCzPiQe5+bCJrpOeKg/L05dunk= -github.com/pion/dtls/v2 v2.2.12/go.mod h1:d9SYc9fch0CqK90mRk1dC7AkzzpwJj6u2GU3u+9pqFE= -github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= -github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= -github.com/pion/stun v0.6.1 h1:8lp6YejULeHBF8NmV8e2787BogQhduZugh5PdhDyyN4= -github.com/pion/stun v0.6.1/go.mod h1:/hO7APkX4hZKu/D0f2lHzNyvdkTGtIy3NDmLR7kSz/8= -github.com/pion/transport/v2 v2.2.1/go.mod h1:cXXWavvCnFF6McHTft3DWS9iic2Mftcz1Aq29pGcU5g= -github.com/pion/transport/v2 v2.2.4/go.mod h1:q2U/tf9FEfnSBGSW6w5Qp5PFWRLRj3NjLhCCgpRK4p0= -github.com/pion/transport/v2 v2.2.10 h1:ucLBLE8nuxiHfvkFKnkDQRYWYfp8ejf4YBOPfaQpw6Q= -github.com/pion/transport/v2 v2.2.10/go.mod h1:sq1kSLWs+cHW9E+2fJP95QudkzbK7wscs8yYgQToO5E= -github.com/pion/transport/v3 v3.0.6 h1:k1mQU06bmmX143qSWgXFqSH1KUJceQvIUuVH/K5ELWw= -github.com/pion/transport/v3 v3.0.6/go.mod h1:HvJr2N/JwNJAfipsRleqwFoR3t/pWyHeZUs89v3+t5s= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= @@ -73,14 +60,8 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tscholl2/siec v0.0.0-20210707234609-9bdfc483d499/go.mod h1:KL9+ubr1JZdaKjgAaHr+tCytEncXBa1pR6FjbTsOJnw= @@ -89,15 +70,10 @@ github.com/tscholl2/siec v0.0.0-20240310163802-c2c6f6198406/go.mod h1:KL9+ubr1JZ github.com/twmb/murmur3 v1.1.5/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ= github.com/twmb/murmur3 v1.1.8 h1:8Yt9taO/WN3l08xErzjeschgZU2QSrwm1kclYq+0aRg= github.com/twmb/murmur3 v1.1.8/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ= -github.com/wlynxg/anet v0.0.3 h1:PvR53psxFXstc12jelG6f1Lv4MWqE0tI76/hHGjh9rg= -github.com/wlynxg/anet v0.0.3/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= @@ -112,11 +88,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= @@ -136,11 +109,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= @@ -151,28 +121,24 @@ golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXct golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -189,3 +155,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gortc.io/stun v1.23.0 h1:CpRQFjakCZMwVKTwInKbcCzlBklj62LGzD3NPdFyGrE= +gortc.io/stun v1.23.0/go.mod h1:XD5lpONVyjvV3BgOyJFNo0iv6R2oZB4L+weMqxts+zg= diff --git a/src/utils/utils.go b/src/utils/utils.go index 136e147..6a61c8a 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -24,7 +24,7 @@ import ( "github.com/cespare/xxhash" "github.com/kalafut/imohash" "github.com/minio/highwayhash" - "github.com/pion/stun" + "gortc.io/stun" log "github.com/schollz/logger" "github.com/schollz/mnemonicode" "github.com/schollz/progressbar/v3" From 76b1df509676f069d55c5dcb5d29a8b42b386aac Mon Sep 17 00:00:00 2001 From: Zack Date: Thu, 5 Sep 2024 08:00:33 -0700 Subject: [PATCH 9/9] rm logging from main.go --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index bb220fe..17dbe40 100644 --- a/main.go +++ b/main.go @@ -5,13 +5,13 @@ package main //go:generate git tag -af v$VERSION -m "v$VERSION" import ( + "fmt" "os" "os/signal" "syscall" "github.com/schollz/croc/v10/src/cli" "github.com/schollz/croc/v10/src/utils" - log "github.com/schollz/logger" ) func main() { @@ -38,7 +38,8 @@ func main() { go func() { if err := cli.Run(); err != nil { - log.Error(err) + fmt.Println(err) + os.Exit(1) } // Exit the program gracefully utils.RemoveMarkedFiles() @@ -46,8 +47,7 @@ func main() { }() // Wait for a termination signal - sig := <-sigs - log.Debugf("Received signal:", sig) + _ = <-sigs utils.RemoveMarkedFiles() // Exit the program gracefully