MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / SharedData

Class SharedData

shared.py:193–2021  ·  view source on GitHub ↗

Shared data between the different modules.

Source from the content-addressed store, hash-verified

191 # joystick). Square panel: use a square reference so the layout isn't
192 # stretched; the on-screen frame/stat pages scale to fit 128x128.
193 "st7735s": {"ref_width": 128, "ref_height": 128, "default_flip": False},
194 # Whisplay HAT 1.69" ST7789 240x280 colour TFT LCD (ref height keeps the
195 # 240:280 aspect so the layout isn't stretched: 122 * 280/240 = 142)
196 "whisplay": {"ref_width": DESIGN_REF_WIDTH, "ref_height": 142, "default_flip": False},
197 # SSD1306 0.96" 128x64 monochrome OLED
198 "ssd1306": {"ref_width": 128, "ref_height": 64, "default_flip": False},
199 # LCD1602 16x2 character LCD (I2C via PCF8574 backpack)
200 "lcd1602": {"ref_width": 16, "ref_height": 2, "default_flip": False},
201 # MAX7219 LED matrix displays
202 "max7219_4panel": {"ref_width": 32, "ref_height": 8, "default_flip": False},
203 "max7219_8panel": {"ref_width": 64, "ref_height": 8, "default_flip": False},
204}
205
206
207logger = Logger(name="shared.py", level=logging.DEBUG) # Create a logger object
208
209class SharedData:
210 """Shared data between the different modules."""
211 def __init__(self):
212 # Detect Pager mode (set by pager_payload.sh before Python launch)
213 self._pager_mode = os.environ.get('RAGNAR_PAGER_MODE') == '1'
214
215 self.initialize_paths() # Initialize the paths used by the application
216
217 # --- Network storage & context (not available on Pager) ---
218 if not self._pager_mode and NetworkStorageManager is not None:
219 self.storage_manager = NetworkStorageManager(self.datadir)
220 else:
221 self.storage_manager = None
222 self.active_network_ssid = None
223 self.active_network_slug = None
224 self.current_network_dir = None
225 self.current_network_db_path = None
226 self.network_intelligence_dir = None
227 self.network_threat_dir = None
228 if self.storage_manager is not None:
229 self._apply_network_context(
230 self.storage_manager.get_active_context(),
231 configure_db=False
232 )
233 if not self._pager_mode and NetworkContextRegistry is not None:
234 self.context_registry = NetworkContextRegistry(self)
235 else:
236 self.context_registry = None
237
238 self.status_list = []
239 self.last_comment_time = time.time() # Last time a comment was displayed
240 self._stats_lock = threading.Lock() # Thread-safe lock for update_stats()
241 self._config_lock = threading.RLock() # Serializes save_config() vs mutations
242 self.default_config = self.get_default_config() # Default configuration of the application
243 self.config = self.default_config.copy() # Configuration of the application
244 # Load existing configuration first
245 self.load_config()
246
247 if not self._pager_mode and MultiInterfaceState is not None:
248 self.multi_interface_state = MultiInterfaceState(self)
249 else:
250 self.multi_interface_state = None

Callers 15

init_shared.pyFile · 0.90
steal_files_ftp.pyFile · 0.90
ftp_connector.pyFile · 0.90
steal_files_ssh.pyFile · 0.90
sql_connector.pyFile · 0.90
steal_files_smb.pyFile · 0.90
scanning.pyFile · 0.90
rdp_connector.pyFile · 0.90
ssh_connector.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected