Class: NewRelic::Security::Agent::Control::GRPCContext
- Inherits:
-
Object
- Object
- NewRelic::Security::Agent::Control::GRPCContext
- Defined in:
- lib/newrelic_security/agent/control/grpc_context.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#client_ip ⇒ Object
Returns the value of attribute client_ip.
-
#client_port ⇒ Object
Returns the value of attribute client_port.
-
#event_counter ⇒ Object
Returns the value of attribute event_counter.
-
#fuzz_files ⇒ Object
Returns the value of attribute fuzz_files.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#is_grpc ⇒ Object
Returns the value of attribute is_grpc.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#method ⇒ Object
Returns the value of attribute method.
-
#mutex ⇒ Object
Returns the value of attribute mutex.
-
#route ⇒ Object
Returns the value of attribute route.
-
#server_name ⇒ Object
Returns the value of attribute server_name.
-
#server_port ⇒ Object
Returns the value of attribute server_port.
-
#time_stamp ⇒ Object
Returns the value of attribute time_stamp.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #current_time_millis ⇒ Object
-
#initialize(grpc_request) ⇒ GRPCContext
constructor
A new instance of GRPCContext.
Constructor Details
#initialize(grpc_request) ⇒ GRPCContext
Returns a new instance of GRPCContext.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 13 def initialize(grpc_request) @time_stamp = current_time_millis @method = grpc_request[:method] @route = "/#{@method}" @headers = grpc_request[:headers] @body = grpc_request[:body] if defined?(::GRPC::RpcServer) ObjectSpace.each_object(::GRPC::RpcServer) do |z| grpc_host = z.instance_variable_get(:@host_nr) grpc_port = z.instance_variable_get(:@port_nr) @server_name = "#{grpc_host}:#{grpc_port}" @server_port = grpc_port @client_ip = grpc_request[:peer].rpartition(COLON)[0] if grpc_request[:peer] @client_port = grpc_request[:peer].rpartition(COLON)[-1] if grpc_request[:peer] @url = "/#{@method}" end end @is_grpc = true @metadata = { :reflectedMetaData => { :isGrpcClientStream => grpc_request[:is_grpc_client_stream], :isGrpcServerStream => grpc_request[:is_grpc_server_stream] } } @cache = {} @fuzz_files = ::Set.new @event_counter = 0 @mutex = Mutex.new NewRelic::Security::Agent.agent.http_request_count.increment end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def body @body end |
#cache ⇒ Object
Returns the value of attribute cache.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def cache @cache end |
#client_ip ⇒ Object
Returns the value of attribute client_ip.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def client_ip @client_ip end |
#client_port ⇒ Object
Returns the value of attribute client_port.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def client_port @client_port end |
#event_counter ⇒ Object
Returns the value of attribute event_counter.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def event_counter @event_counter end |
#fuzz_files ⇒ Object
Returns the value of attribute fuzz_files.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def fuzz_files @fuzz_files end |
#headers ⇒ Object
Returns the value of attribute headers.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def headers @headers end |
#is_grpc ⇒ Object
Returns the value of attribute is_grpc.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def is_grpc @is_grpc end |
#metadata ⇒ Object
Returns the value of attribute metadata.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def @metadata end |
#method ⇒ Object
Returns the value of attribute method.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def method @method end |
#mutex ⇒ Object
Returns the value of attribute mutex.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def mutex @mutex end |
#route ⇒ Object
Returns the value of attribute route.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def route @route end |
#server_name ⇒ Object
Returns the value of attribute server_name.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def server_name @server_name end |
#server_port ⇒ Object
Returns the value of attribute server_port.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def server_port @server_port end |
#time_stamp ⇒ Object
Returns the value of attribute time_stamp.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def time_stamp @time_stamp end |
#url ⇒ Object
Returns the value of attribute url.
11 12 13 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 11 def url @url end |
Class Method Details
.get_context ⇒ Object
43 44 45 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 43 def self.get_context Thread.current[:security_context_data] end |
.reset_context ⇒ Object
51 52 53 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 51 def self.reset_context Thread.current[:security_context_data] = nil if Thread.current[:security_context_data] end |
.set_context(grpc_request) ⇒ Object
47 48 49 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 47 def self.set_context(grpc_request) Thread.current[:security_context_data] = GRPCContext.new(grpc_request) end |
Instance Method Details
#current_time_millis ⇒ Object
39 40 41 |
# File 'lib/newrelic_security/agent/control/grpc_context.rb', line 39 def current_time_millis (Time.now.to_f * 1000).to_i end |