mirror of
				https://github.com/r-smith/deceptifeed.git
				synced 2025-11-04 06:03:37 +00:00 
			
		
		
		
	feat: enable live monitoring when logs are disabled
This change adds live monitoring support when logging on a honeypot is disabled.
This commit is contained in:
		@@ -222,7 +222,6 @@ func validateRegexRules(rules Rules) error {
 | 
				
			|||||||
func (c *Config) InitializeLoggers() error {
 | 
					func (c *Config) InitializeLoggers() error {
 | 
				
			||||||
	const maxSize = 50
 | 
						const maxSize = 50
 | 
				
			||||||
	c.Monitor = logmonitor.New()
 | 
						c.Monitor = logmonitor.New()
 | 
				
			||||||
 | 
					 | 
				
			||||||
	openedLogFiles := make(map[string]*slog.Logger)
 | 
						openedLogFiles := make(map[string]*slog.Logger)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for i := range c.Servers {
 | 
						for i := range c.Servers {
 | 
				
			||||||
@@ -232,14 +231,14 @@ func (c *Config) InitializeLoggers() error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		logPath := c.Servers[i].LogPath
 | 
							logPath := c.Servers[i].LogPath
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// If no log path is specified or if logging is disabled, discard logs.
 | 
							// If no log path is specified or logging is disabled, write to a log
 | 
				
			||||||
 | 
							// monitor for live monitoring. No log data is written to disk.
 | 
				
			||||||
		if len(logPath) == 0 || !c.Servers[i].LogEnabled {
 | 
							if len(logPath) == 0 || !c.Servers[i].LogEnabled {
 | 
				
			||||||
			c.Servers[i].Logger = slog.New(slog.DiscardHandler)
 | 
								c.Servers[i].Logger = slog.New(slog.NewJSONHandler(c.Monitor, nil))
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Check if this log path has already been opened. If so, reuse the
 | 
							// Reuse the logger if this log path has already been opened.
 | 
				
			||||||
		// logger.
 | 
					 | 
				
			||||||
		if logger, exists := openedLogFiles[logPath]; exists {
 | 
							if logger, exists := openedLogFiles[logPath]; exists {
 | 
				
			||||||
			c.Servers[i].Logger = logger
 | 
								c.Servers[i].Logger = logger
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user