more work done

This commit is contained in:
ston1th 2021-03-06 16:51:36 +01:00
commit 6fda229a8e
23 changed files with 384 additions and 177 deletions

View file

@ -1,10 +1,12 @@
package server
import (
"git.gitfish.de/ston1th/haproxy-lb/pkg/config"
"git.giftfish.de/ston1th/haproxy-lb/pkg/config"
"golang.org/x/crypto/bcrypt"
weakrand "math/rand"
"net/http"
//"net/http"
"encoding/hex"
"strings"
"sync"
"time"
)
@ -90,7 +92,7 @@ func (a *auth) Auth(user, pass, path string) bool {
a.bcryptMtx.Unlock()
authOk = err == nil
u.cache.set(cacheKey, authOk)
a.cache.set(cacheKey, authOk)
}
return authOk && valid && strings.HasPrefix(path, creds.Prefix)
@ -103,10 +105,10 @@ type creds struct {
func newAuth(conf config.Config) (a *auth) {
a = &auth{
users: make(map[string]creds),
users: make(map[string]*creds),
cache: newCache(),
}
for _, u := range conf.BasicAuth {
for _, u := range conf.Server.BasicAuth {
a.users[u.User] = &creds{u.Hash, u.Prefix}
}
return

View file

@ -2,7 +2,7 @@ package server
import (
//"golang.org/x/crypto/bcrypt"
"net/http"
//"net/http"
"git.giftfish.de/ston1th/haproxy-lb/pkg/api/types"
)
@ -21,3 +21,11 @@ func healthzHandler(ctx *types.Context) {
// TODO maybe report etcd/raft stats
ctx.OK()
}
func lbListHandler(ctx *types.Context) {
ctx.OK()
}
func lbHandler(ctx *types.Context) {
ctx.OK()
}