From ad6b9b1dca039678e7c48fe07e864b614e01158f Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 4 Dec 2019 16:40:12 +0300 Subject: [PATCH] Move everything related to passwords out --- gocheese.go | 12 +++--------- passwd.go | 6 ++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gocheese.go b/gocheese.go index 9b74ee7..02aa225 100644 --- a/gocheese.go +++ b/gocheese.go @@ -66,6 +66,9 @@ along with this program. If not, see .` ) var ( + pkgPyPI = regexp.MustCompile(`^.*]*>(.+)
.*$`) + Version string = "UNKNOWN" + root = flag.String("root", "./packages", "Path to packages directory") bind = flag.String("bind", "[::]:8080", "Address to bind to") tlsCert = flag.String("tls-cert", "", "Path to TLS X.509 certificate") @@ -79,17 +82,8 @@ var ( maxClients = flag.Int("maxclients", 128, "Maximal amount of simultaneous clients") version = flag.Bool("version", false, "Print version information") warranty = flag.Bool("warranty", false, "Print warranty information") - - pkgPyPI = regexp.MustCompile(`^.*]*>(.+)
.*$`) - Version string = "UNKNOWN" - - passwords map[string]Auther = make(map[string]Auther) ) -type Auther interface { - Auth(password string) bool -} - func mkdirForPkg(w http.ResponseWriter, r *http.Request, dir string) bool { path := filepath.Join(*root, dir) if _, err := os.Stat(path); os.IsNotExist(err) { diff --git a/passwd.go b/passwd.go index 6fb75f5..dbdac8c 100644 --- a/passwd.go +++ b/passwd.go @@ -25,6 +25,12 @@ import ( "strings" ) +var passwords map[string]Auther = make(map[string]Auther) + +type Auther interface { + Auth(password string) bool +} + func strToAuther(verifier string) (string, Auther, error) { st := strings.SplitN(verifier, "$", 3) if len(st) != 3 || st[0] != "" { -- 2.44.0