Module: RobustServerSocket

Extended by:
Configuration
Defined in:
lib/version.rb,
lib/robust_server_socket.rb,
lib/robust_server_socket/cacher.rb,
lib/robust_server_socket/client_token.rb,
lib/robust_server_socket/rate_limiter.rb,
lib/robust_server_socket/configuration.rb,
lib/robust_server_socket/secure_token/decrypt.rb,
lib/robust_server_socket/modules/dos_attack_protection.rb,
lib/robust_server_socket/modules/client_auth_protection.rb,
lib/robust_server_socket/modules/replay_attack_protection.rb

Defined Under Namespace

Modules: Cacher, Configuration, Modules, SecureToken Classes: ClientToken, ConfigStore, RateLimiter

Constant Summary collapse

VERSION =
'0.4.2'

Constants included from Configuration

Configuration::MIN_KEY_SIZE

Instance Attribute Summary

Attributes included from Configuration

#configuration, #configured

Class Method Summary collapse

Methods included from Configuration

_push_bang_modules_check_code, _push_modules_check_code, configure, configured?, correct_configuration?

Class Method Details

.load!Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/robust_server_socket.rb', line 17

def load!
  raise 'You must correctly configure RobustServerSocket first!' unless configured?

  configuration.using_modules.each do |mod|
    raise ArgumentError, 'Module must be a Symbol!' unless mod.is_a?(Symbol)

    require_relative "robust_server_socket/modules/#{mod}"
    ClientToken.include eval(mod.to_s.split('_').map(&:capitalize).unshift('Modules::').join)
  end

  ClientToken.class_eval(<<~METHOD)
    def modules_checks
      #{(RobustServerSocket.configuration._modules_check_rows.empty? ? ['true'] : RobustServerSocket.configuration._modules_check_rows.map(&:strip)).join(' && ')}
    end

    def modules_checks!
      #{(RobustServerSocket.configuration._bang_modules_check_rows.empty? ? ['true'] : RobustServerSocket.configuration._bang_modules_check_rows).join}
    end
  METHOD
end