From: Sergey Matveev Date: Wed, 4 Dec 2019 13:40:12 +0000 (+0300) Subject: Move everything related to passwords out X-Git-Tag: v2.0.0~10 X-Git-Url: http://www.git.cypherpunks.ru/?p=gocheese.git;a=commitdiff_plain;h=ad6b9b1dca039678e7c48fe07e864b614e01158f Move everything related to passwords out --- 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] != "" {