fix: filter name
This commit is contained in:
parent
3aacf82c57
commit
553682d74f
7
main.go
7
main.go
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user