mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-18 17:57:41 +03:00
Changed BannedPk to BannedPK, removed bannedIP
This commit is contained in:
parent
86ee6f12c5
commit
ca979b9e72
12
server.go
12
server.go
@ -38,8 +38,7 @@ type Server struct {
|
|||||||
motd string
|
motd string
|
||||||
whitelist map[string]struct{} // fingerprint lookup
|
whitelist map[string]struct{} // fingerprint lookup
|
||||||
admins map[string]struct{} // fingerprint lookup
|
admins map[string]struct{} // fingerprint lookup
|
||||||
bannedPk map[string]*time.Time // fingerprint lookup
|
bannedPK map[string]*time.Time // fingerprint lookup
|
||||||
bannedIP map[net.Addr]*time.Time
|
|
||||||
started time.Time
|
started time.Time
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
@ -59,8 +58,7 @@ func NewServer(privateKey []byte) (*Server, error) {
|
|||||||
motd: "Message of the Day! Modify with /motd",
|
motd: "Message of the Day! Modify with /motd",
|
||||||
whitelist: map[string]struct{}{},
|
whitelist: map[string]struct{}{},
|
||||||
admins: map[string]struct{}{},
|
admins: map[string]struct{}{},
|
||||||
bannedPk: map[string]*time.Time{},
|
bannedPK: map[string]*time.Time{},
|
||||||
bannedIP: map[net.Addr]*time.Time{},
|
|
||||||
started: time.Now(),
|
started: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +282,7 @@ func (s *Server) IsWhitelisted(fingerprint string) bool {
|
|||||||
|
|
||||||
// IsBanned checks if the given fingerprint is banned
|
// IsBanned checks if the given fingerprint is banned
|
||||||
func (s *Server) IsBanned(fingerprint string) bool {
|
func (s *Server) IsBanned(fingerprint string) bool {
|
||||||
ban, hasBan := s.bannedPk[fingerprint]
|
ban, hasBan := s.bannedPK[fingerprint]
|
||||||
if !hasBan {
|
if !hasBan {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -306,14 +304,14 @@ func (s *Server) Ban(fingerprint string, duration *time.Duration) {
|
|||||||
when := time.Now().Add(*duration)
|
when := time.Now().Add(*duration)
|
||||||
until = &when
|
until = &when
|
||||||
}
|
}
|
||||||
s.bannedPk[fingerprint] = until
|
s.bannedPK[fingerprint] = until
|
||||||
s.Unlock()
|
s.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unban unbans a banned fingerprint
|
// Unban unbans a banned fingerprint
|
||||||
func (s *Server) Unban(fingerprint string) {
|
func (s *Server) Unban(fingerprint string) {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
delete(s.bannedPk, fingerprint)
|
delete(s.bannedPK, fingerprint)
|
||||||
s.Unlock()
|
s.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user