fix: filter name

This commit is contained in:
Jon Lundy 2021-08-26 13:30:02 -06:00
parent 3aacf82c57
commit 553682d74f
No known key found for this signature in database
GPG Key ID: 13022278CED7D8EC

View File

@ -11,6 +11,7 @@ import (
"os" "os"
"os/signal" "os/signal"
"path/filepath" "path/filepath"
"regexp"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@ -30,6 +31,8 @@ const (
bindHost = "[::1]" bindHost = "[::1]"
) )
var filterName = regexp.MustCompile("[^a-z0-9-]+")
func main() { func main() {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill) ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill)
defer stop() defer stop()
@ -153,7 +156,9 @@ func (srv *server) AddUser(pubkey ssh.PublicKey) *user {
u.pubkey = pubkey u.pubkey = pubkey
babbler := babble.NewBabbler() babbler := babble.NewBabbler()
u.name = strings.ToLower(babbler.Babble()) u.name = babbler.Babble()
u.name = strings.ToLower(u.name)
u.name = filterName.ReplaceAllString(u.name, "")
u.bindPort = srv.nextPort() u.bindPort = srv.nextPort()
u.bindHost = srv.bindHost u.bindHost = srv.bindHost