Removed debug print statements in acl.go file

This commit is contained in:
Kelvin Clement Mwinuka
2024-06-05 21:44:00 +08:00
parent 66b2842e11
commit ee13c29c9a
4 changed files with 1280 additions and 1270 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -101,6 +101,7 @@ type EchoVault struct {
listener atomic.Value // Holds the TCP listener.
quit chan struct{} // Channel that signals the closing of all client connections.
stopTTL chan struct{} // Channel that signals the TTL sampling goroutine to stop execution.
}
// WithContext is an options that for the NewEchoVault function that allows you to
@@ -146,6 +147,7 @@ func NewEchoVault(options ...func(echovault *EchoVault)) (*EchoVault, error) {
return commands
}(),
quit: make(chan struct{}),
stopTTL: make(chan struct{}),
}
for _, option := range options {
@@ -274,10 +276,15 @@ func NewEchoVault(options ...func(echovault *EchoVault)) (*EchoVault, error) {
if echovault.config.EvictionPolicy != constants.NoEviction {
go func() {
ticker := time.NewTicker(echovault.config.EvictionInterval)
for _ = range ticker.C {
for {
select {
case <-ticker.C:
if err := echovault.evictKeysWithExpiredTTL(context.Background()); err != nil {
log.Printf("evict with ttl: %v\n", err)
}
case <-echovault.stopTTL:
break
}
}
}()
}
@@ -555,6 +562,7 @@ func (server *EchoVault) rewriteAOF() error {
func (server *EchoVault) ShutDown() {
if server.listener.Load() != nil {
go func() { server.quit <- struct{}{} }()
go func() { server.stopTTL <- struct{}{} }()
log.Println("closing tcp listener...")
if err := server.listener.Load().(net.Listener).Close(); err != nil {
log.Printf("listener close: %v\n", err)

View File

@@ -435,8 +435,6 @@ func (acl *ACL) AuthorizeConnection(conn *net.Conn, cmd []string, command intern
}
// 9. Check if write keys are in IncludedWriteKeys
fmt.Println("KEYS: ", writeKeys)
fmt.Println("ALLOWED KEYS: ", connection.User.IncludedWriteKeys)
if !slices.ContainsFunc(writeKeys, func(key string) bool {
return slices.ContainsFunc(connection.User.IncludedWriteKeys, func(writeKeyGlob string) bool {
if acl.GlobPatterns[writeKeyGlob].Match(key) {