]> Cypherpunks.ru repositories - gocheese.git/commitdiff
daemontools friendliness v2.5.0
authorSergey Matveev <stargrave@stargrave.org>
Sat, 7 Nov 2020 14:20:29 +0000 (17:20 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 7 Nov 2020 14:23:56 +0000 (17:23 +0300)
gocheese.go
gocheese.texi
integrity.go
passwd.go

index 432fb6f76e1ca0f1468baa9fea2c97814fe4439a..d467bba22209ea413be5cc05f6a68d89c5e8d50f 100644 (file)
@@ -43,7 +43,7 @@ import (
 )
 
 const (
-       Version   = "2.4.1"
+       Version   = "2.5.0"
        HTMLBegin = `<!DOCTYPE html>
 <html>
   <head>
@@ -96,6 +96,7 @@ var (
        gpgUpdateURLPath = flag.String("gpgupdate", "/gpgupdate/", "GPG forceful refreshing URL path")
        pypiURL          = flag.String("pypi", "https://pypi.org/simple/", "Upstream PyPI URL")
        passwdPath       = flag.String("passwd", "passwd", "Path to file with authenticators")
+       logTimestamped   = flag.Bool("log-timestamped", false, "Prepend timestmap to log messages")
        passwdCheck      = flag.Bool("passwd-check", false, "Test the -passwd file for syntax errors and exit")
        fsck             = flag.Bool("fsck", false, "Check integrity of all packages (errors are in stderr)")
        maxClients       = flag.Int("maxclients", 128, "Maximal amount of simultaneous clients")
@@ -264,31 +265,39 @@ func main() {
                return
        }
        if *version {
-               fmt.Println("GoCheese version", Version, "built with", runtime.Version())
+               fmt.Println("GoCheese", Version, "built with", runtime.Version())
                return
        }
+
+       if *logTimestamped {
+               log.SetFlags(log.Ldate | log.Lmicroseconds | log.Lshortfile)
+       } else {
+               log.SetFlags(log.Lshortfile)
+       }
+       log.SetOutput(os.Stdout)
+
        if *fsck {
                if !goodIntegrity() {
                        os.Exit(1)
                }
                return
        }
+
        if *passwdCheck {
                refreshPasswd()
                return
        }
+
        if (*tlsCert != "" && *tlsKey == "") || (*tlsCert == "" && *tlsKey != "") {
                log.Fatalln("Both -tls-cert and -tls-key are required")
        }
+
        var err error
        pypiURLParsed, err = url.Parse(*pypiURL)
        if err != nil {
                log.Fatalln(err)
        }
        refreshPasswd()
-       log.Println("root:", *root)
-       log.Println("bind:", *bind)
-       log.Println("pypi:", *pypiURL)
 
        ln, err := net.Listen("tcp", *bind)
        if err != nil {
@@ -325,6 +334,12 @@ func main() {
                cancel()
        }(server)
 
+       log.Println(
+               "GoCheese", Version, "listens:",
+               "root:", *root,
+               "bind:", *bind,
+               "pypi:", *pypiURL,
+       )
        if *tlsCert == "" {
                err = server.Serve(ln)
        } else {
index ee620dc9330c0be0d8ba34c93fca51fd0ae349c5..f4b6f811371e278cf2e003c220c52becfab598fb 100644 (file)
@@ -119,6 +119,9 @@ Pay attention that you have to manually create corresponding private
 package directory! You are not allowed to upload anything explicitly
 flagged as internal package.
 
+It is advisable to run GoCheese under some kind of
+@url{http://cr.yp.to/daemontools.html, daemontools}.
+
 @node Passwords
 @unnumbered Password authentication
 
index dc9c51e1822be43948e08b0b4627e8d5684d67de..f6f39e6d5749baff977e93cfa5460cb7c4be7ec3 100644 (file)
@@ -61,10 +61,10 @@ func goodIntegrity() bool {
                                log.Fatal(err)
                        }
                        if bytes.Compare(hasher.Sum(digest[:0]), data) == 0 {
-                               fmt.Println(pkgName, "GOOD")
+                               fmt.Println("GOOD", pkgName)
                        } else {
                                isGood = false
-                               fmt.Fprintln(os.Stderr, pkgName, "BAD")
+                               fmt.Println("BAD", pkgName)
                        }
                        hasher.Reset()
                }
index dae17a5364b687107f8590caac1231bae71198b3..2a473f6ca5a189ad6e0aa34f5abdb01001f1c6ab 100644 (file)
--- a/passwd.go
+++ b/passwd.go
@@ -77,7 +77,7 @@ func refreshPasswd() {
                        log.Fatalf("%s:%d: %s: %s", *passwdPath, i, login, err)
                }
                passwordsNew[login] = auther
-               log.Println("added password for " + login)
+               log.Println("added password for:", login)
        }
        passwords = passwordsNew
 }