Class: Msf::RPC::JSON::Client
- Inherits:
-
Object
- Object
- Msf::RPC::JSON::Client
- Defined in:
- lib/msf/core/rpc/json/client.rb
Overview
JSON-RPC Client All client method call requests must be dispatched from within an EventMachine (reactor) run loop.
Instance Attribute Summary collapse
-
#api_token ⇒ Object
readonly
Returns the value of attribute api_token.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#symbolize_names ⇒ Object
readonly
Returns the value of attribute symbolize_names.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri, api_token: nil, namespace: nil, symbolize_names: true, private_key_file: nil, cert_chain_file: nil, verify_peer: nil) ⇒ Client
constructor
Instantiate a Client.
Constructor Details
#initialize(uri, api_token: nil, namespace: nil, symbolize_names: true, private_key_file: nil, cert_chain_file: nil, verify_peer: nil) ⇒ Client
Instantiate a Client. be prepended to the method name with a period separator. Default: nil processing JSON objects; otherwise, strings are used. Default: true from a peer, to be verified by user code. Default: nil
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/msf/core/rpc/json/client.rb', line 26 def initialize(uri, api_token: nil, namespace: nil, symbolize_names: true, private_key_file: nil, cert_chain_file: nil, verify_peer: nil) @uri = URI.parse(uri) @api_token = api_token @namespace = namespace @symbolize_names = symbolize_names @private_key_file = private_key_file @cert_chain_file = cert_chain_file @verify_peer = verify_peer end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args, **keyword_args, &block) ⇒ Msf::RPC::JSON::Request (private)
Invoked by Ruby when obj is sent a message it cannot handle, then processes the call as an RPC method invocation.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/msf/core/rpc/json/client.rb', line 45 def method_missing(symbol, *args, **keyword_args, &block) # assemble method parameters if !args.empty? && !keyword_args.empty? params = args << keyword_args elsif !args.empty? params = args elsif !keyword_args.empty? params = keyword_args else params = nil end process_call_async(symbol, params) end |
Instance Attribute Details
#api_token ⇒ Object (readonly)
Returns the value of attribute api_token.
11 12 13 |
# File 'lib/msf/core/rpc/json/client.rb', line 11 def api_token @api_token end |
#namespace ⇒ Object
Returns the value of attribute namespace.
13 14 15 |
# File 'lib/msf/core/rpc/json/client.rb', line 13 def namespace @namespace end |
#symbolize_names ⇒ Object (readonly)
Returns the value of attribute symbolize_names.
12 13 14 |
# File 'lib/msf/core/rpc/json/client.rb', line 12 def symbolize_names @symbolize_names end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
10 11 12 |
# File 'lib/msf/core/rpc/json/client.rb', line 10 def uri @uri end |