mirror of
				https://github.com/shazow/ssh-chat.git
				synced 2025-11-04 05:25:33 +01:00 
			
		
		
		
	adds /whitelist command for ops
This commit is contained in:
		
							parent
							
								
									e3e46f9b8c
								
							
						
					
					
						commit
						271c0aa082
					
				
							
								
								
									
										11
									
								
								client.go
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								client.go
									
									
									
									
									
								
							@ -31,6 +31,7 @@ const OP_HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available operator comma
 | 
			
		||||
   /op $NAME                 - Promote a user to server operator.
 | 
			
		||||
   /silence $NAME            - Revoke a user's ability to speak.
 | 
			
		||||
   /motd $MESSAGE            - Sets the Message of the Day
 | 
			
		||||
   /whitelist $FINGERPRINT   - Adds pubkey fingerprint to the connection whitelist
 | 
			
		||||
` + RESET
 | 
			
		||||
 | 
			
		||||
const ABOUT_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> ssh-chat is made by @shazow.
 | 
			
		||||
@ -324,6 +325,16 @@ func (c *Client) handleShell(channel ssh.Channel) {
 | 
			
		||||
					c.Server.SetMotd(c, newmotd)
 | 
			
		||||
					c.Server.MotdBroadcast(c)
 | 
			
		||||
				}
 | 
			
		||||
			case "/whitelist": /* whitelist a fingerprint */
 | 
			
		||||
				if !c.Server.IsOp(c) {
 | 
			
		||||
					c.SysMsg("You're not an admin.")
 | 
			
		||||
				} else if len(parts) != 2 {
 | 
			
		||||
					c.SysMsg("Missing $FINGERPRINT from: /whitelist $FINGERPRINT")
 | 
			
		||||
				} else {
 | 
			
		||||
					fingerprint := parts[1]
 | 
			
		||||
					c.Server.Whitelist(fingerprint)
 | 
			
		||||
					c.SysMsg("Added %s to the whitelist", fingerprint)
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			default:
 | 
			
		||||
				c.SysMsg("Invalid command: %s", line)
 | 
			
		||||
 | 
			
		||||
@ -237,9 +237,9 @@ func (s *Server) Op(fingerprint string) {
 | 
			
		||||
 | 
			
		||||
func (s *Server) Whitelist(fingerprint string) {
 | 
			
		||||
	logger.Infof("Adding whitelist: %s", fingerprint)
 | 
			
		||||
	s.lock.Lock()
 | 
			
		||||
	s.Lock()
 | 
			
		||||
	s.whitelist[fingerprint] = struct{}{}
 | 
			
		||||
	s.lock.Unlock()
 | 
			
		||||
	s.Unlock()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Server) Uptime() string {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user