# -*- coding: binary -*-1require 'rex'23module Rex45###6#7# The service module is used to extend classes that are passed into the8# service manager start routine. It provides extra methods, such as reference9# counting, that are used to track the service instances more uniformly.10#11###12module Service13include Ref141516#17# Returns the hardcore, as in porno, alias for this service. This is used18# by the service manager to manage singleton services.19#20def self.hardcore_alias(*args)21return "__#{args}"22end2324def deref25rv = super2627# If there's only one reference, then it's the service managers.28if @_references == 129Rex::ServiceManager.stop_service(self)30return true31end3233rv34end3536#37# Calls stop on the service once the ref count drops.38#39def cleanup40stop41end4243attr_accessor :alias4445end4647end484950