Class: Metasploit::Aggregator::GrpcServer

Inherits:
Object
  • Object
show all
Defined in:
lib/metasploit/aggregator.rb

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ GrpcServer

Returns a new instance of GrpcServer.



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'lib/metasploit/aggregator.rb', line 383

def initialize(host, port)
  @host = host
  @port = port

  # TODO: investigate using Core::Channel to secure this communication
  # server = TCPServer.new(@host, @port)
  # sslContext = OpenSSL::SSL::SSLContext.new
  # sslContext.key, sslContext.cert = Metasploit::Aggregator::ConnectionManager.ssl_generate_certificate
  # sslServer = OpenSSL::SSL::SSLServer.new(server, sslContext)

  @svr = GRPC::RpcServer.new
  @svr.add_http2_port("#{@host}:#{@port}", :this_port_is_insecure)
  @svr.handle(ServerImpl)

  @exec = Thread.new do
    GrpcServer.register_for_cleanup(self)
    @svr.run_till_terminated
  end
end

Instance Method Details

#stop(force = false) ⇒ Object



403
404
405
406
# File 'lib/metasploit/aggregator.rb', line 403

def stop(force = false)
  GrpcServer.unregister_for_cleanup(self) unless force
  @svr.stop if @svr.running?
end