Class: Aikido::Zen::RuntimeSettings
- Inherits:
-
Struct
- Object
- Struct
- Aikido::Zen::RuntimeSettings
- Defined in:
- lib/aikido/zen/runtime_settings.rb
Overview
Stores the firewall configuration sourced from the Aikido dashboard. This object is updated by the Agent regularly.
Because the RuntimeSettings object can be modified in runtime, it implements the Observable API, allowing you to subscribe to updates. These are triggered whenever #update_from_json makes a change (i.e. if the settings don’t change, no update is triggered).
You can subscribe to changes with #add_observer(object, func_name), which will call the function passing the settings as an argument.
Defined Under Namespace
Classes: Endpoints, IPSet, ProtectionSettings, RateLimitSettings
Instance Attribute Summary collapse
- #blocked_user_ids ⇒ Array
- #endpoints ⇒ Aikido::Zen::RuntimeSettings::Endpoints
-
#heartbeat_interval ⇒ Integer
Duration in seconds between heartbeat requests to the Aikido server.
-
#received_any_stats ⇒ Boolean
Whether the Aikido server has received any data from this application.
- #skip_protection_for_ips ⇒ Aikido::Zen::RuntimeSettings::IPSet
-
#updated_at ⇒ Time
When these settings were updated in the Aikido dashboard.
Instance Method Summary collapse
-
#initialize ⇒ RuntimeSettings
constructor
A new instance of RuntimeSettings.
-
#update_from_json(data) ⇒ void
Parse and interpret the JSON response from the core API with updated settings, and apply the changes.
Constructor Details
#initialize ⇒ RuntimeSettings
Returns a new instance of RuntimeSettings.
15 16 17 18 19 |
# File 'lib/aikido/zen/runtime_settings.rb', line 15 def initialize(*) super self.endpoints ||= RuntimeSettings::Endpoints.new self.skip_protection_for_ips ||= RuntimeSettings::IPSet.new end |
Instance Attribute Details
#blocked_user_ids ⇒ Array
14 15 16 |
# File 'lib/aikido/zen/runtime_settings.rb', line 14 def blocked_user_ids @blocked_user_ids end |
#endpoints ⇒ Aikido::Zen::RuntimeSettings::Endpoints
14 15 16 |
# File 'lib/aikido/zen/runtime_settings.rb', line 14 def endpoints @endpoints end |
#heartbeat_interval ⇒ Integer
Returns duration in seconds between heartbeat requests to the Aikido server.
14 15 16 |
# File 'lib/aikido/zen/runtime_settings.rb', line 14 def heartbeat_interval @heartbeat_interval end |
#received_any_stats ⇒ Boolean
Returns whether the Aikido server has received any data from this application.
14 15 16 |
# File 'lib/aikido/zen/runtime_settings.rb', line 14 def received_any_stats @received_any_stats end |
#skip_protection_for_ips ⇒ Aikido::Zen::RuntimeSettings::IPSet
14 15 16 |
# File 'lib/aikido/zen/runtime_settings.rb', line 14 def skip_protection_for_ips @skip_protection_for_ips end |
#updated_at ⇒ Time
Returns when these settings were updated in the Aikido dashboard.
14 15 16 |
# File 'lib/aikido/zen/runtime_settings.rb', line 14 def updated_at @updated_at end |
Instance Method Details
#update_from_json(data) ⇒ void
This method returns an undefined value.
Parse and interpret the JSON response from the core API with updated settings, and apply the changes. This will also notify any subscriber to updates
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/aikido/zen/runtime_settings.rb', line 49 def update_from_json(data) last_updated_at = updated_at self.updated_at = Time.at(data["configUpdatedAt"].to_i / 1000) self.heartbeat_interval = (data["heartbeatIntervalInMS"].to_i / 1000) self.endpoints = RuntimeSettings::Endpoints.from_json(data["endpoints"]) self.blocked_user_ids = data["blockedUserIds"] self.skip_protection_for_ips = RuntimeSettings::IPSet.from_json(data["allowedIPAddresses"]) self.received_any_stats = data["receivedAnyStats"] Aikido::Zen.agent.updated_settings! if updated_at != last_updated_at end |