X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=main.go;h=adc3c774bc05d861b0b88f60a2fd9966034e43a6;hb=afe96d991c820d89b861eb29e2fd6a12184dffc0;hp=0b970838ee83b17f28d1f7db81ed6b9f54735028;hpb=d53db4887bee299339a0ef60558dc4733c3a2fe1;p=uploader.git diff --git a/main.go b/main.go index 0b97083..adc3c77 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,6 @@ /* uploader -- simplest form file uploader -Copyright (C) 2018-2021 Sergey Matveev +Copyright (C) 2018-2023 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,6 @@ import ( "fmt" "html/template" "io" - "io/ioutil" "log" "mime" "net" @@ -40,8 +39,8 @@ import ( "go.cypherpunks.ru/recfile" "go.cypherpunks.ru/tai64n/v2" - "golang.org/x/crypto/blake2b" "golang.org/x/net/netutil" + "lukechampine.com/blake3" ) const ( @@ -58,7 +57,7 @@ var ( Example command line usage:
 $ curl -F file=@somedata.tar.gpg [-F comment="optional comment"] http://.../upload/
-$ b2sum somedata.tar.gpg # to verify BLAKE2b-512 checksum
+$ b3sum somedata.tar.gpg # to verify BLAKE3-256 checksum
 

@@ -94,10 +93,6 @@ func upload(w http.ResponseWriter, r *http.Request) { log.Println(r.RemoteAddr, "non file form field") return } - h, err := blake2b.New512(nil) - if err != nil { - panic(err) - } t := time.Now() ts := new(tai64n.TAI64N) ts.FromTime(t) @@ -109,6 +104,7 @@ func upload(w http.ResponseWriter, r *http.Request) { return } fdBuf := bufio.NewWriterSize(fd, WriteBufSize) + h := blake3.New(32, nil) mw := io.MultiWriter(fdBuf, h) n, err := io.Copy(mw, p) if err != nil { @@ -167,14 +163,14 @@ func upload(w http.ResponseWriter, r *http.Request) { var commentLines []string p, err = mr.NextPart() if err == nil && p.FormName() == CommentFieldName { - comment, err := ioutil.ReadAll(p) + comment, err := io.ReadAll(p) if err == nil && len(comment) > 0 { commentLines = strings.Split(string(comment), "\n") wr.WriteFieldMultiline("Comment", commentLines) } } - ioutil.WriteFile(tai+".rec", rec.Bytes(), os.FileMode(0666)) + os.WriteFile(tai+".rec", rec.Bytes(), os.FileMode(0666)) if *NotifyToAddr == "" { return }