]> Sergey Matveev's repositories - uploader.git/blobdiff - main.go
Updated dependencies
[uploader.git] / main.go
diff --git a/main.go b/main.go
index 23a3accbe2046619267e52bebb7c6d653e8b5934..f97f4df68647fcd4ce7b5a18a17d997577b2a86a 100644 (file)
--- a/main.go
+++ b/main.go
@@ -1,6 +1,6 @@
 /*
 uploader -- simplest form file uploader
-Copyright (C) 2018-2020 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2018-2021 Sergey Matveev <stargrave@stargrave.org>
 
 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
@@ -38,7 +38,7 @@ import (
        "time"
 
        "go.cypherpunks.ru/recfile"
-       "go.cypherpunks.ru/tai64n"
+       "go.cypherpunks.ru/tai64n/v2"
        "golang.org/x/crypto/blake2b"
        "golang.org/x/net/netutil"
 )
@@ -54,11 +54,10 @@ const (
 var (
        Index = template.Must(template.New("index").Parse(`<html>
 <head><title>Upload</title></head><body>
-<pre>
 Example command line usage:
-
-    $ curl -F file=@somedata.tar.gpg [-F comment="optional comment"] http://.../upload/
-    $ b2sum -a blake2b somedata.tar.gpg # to verify checksum
+<pre>
+$ curl -F file=@somedata.tar.gpg [-F comment="optional comment"] http://.../upload/
+$ b2sum -a blake2b somedata.tar.gpg # to verify checksum
 </pre>
 <form enctype="multipart/form-data" action="/upload/" method="post">
 <label for="file">File to upload:</label><br/>
@@ -131,8 +130,8 @@ func upload(w http.ResponseWriter, r *http.Request) {
        }
        t := time.Now()
        ts := new(tai64n.TAI64N)
-       tai64n.FromTime(t, ts)
-       tai := ts.Encode()[1:]
+       ts.FromTime(t)
+       tai := tai64n.Encode(ts[:])[1:]
        fnOrig := p.FileName()
        fd, err := os.OpenFile(tai+".part", os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0666)
        if err != nil {
@@ -199,9 +198,11 @@ func upload(w http.ResponseWriter, r *http.Request) {
 func main() {
        bind := flag.String("bind", "[::]:8086", "Address to bind to")
        conns := flag.Int("conns", 2, "Maximal number of connections")
-       NotifyFromAddr = flag.String("notify-from", "uploader@example.com", "Address notifications are send to")
-       NotifyToAddr = flag.String("notify-to", "", "Address notifications are send from")
+       NotifyFromAddr = flag.String("notify-from", "uploader@example.com", "Address notifications are sent to")
+       NotifyToAddr = flag.String("notify-to", "", "Address notifications are sent from")
        flag.Parse()
+       log.SetFlags(log.Lshortfile)
+       log.SetOutput(os.Stdout)
        if len(*NotifyFromAddr) == 0 && len(*NotifyToAddr) > 0 {
                log.Fatalln("notify-from address can not be empty, if notify-to is set")
        }