def __init__(self, session): Proxy.__init__(self, session) log(self.session.session_id, CORE_SESSION, 5, "Proxy start") self._detector_config = OrderedDict(session.service.detector_config) self._detector_default_service_name = session.service.detector_default_service_name self.results = {}
def detect(self, side, data): service = None count_nomatch_detectors = 0 for detector_name, service_name in self._detector_config.iteritems(): if (self.results[detector_name] == DetectResult.NOMATCH): count_nomatch_detectors += 1 continue detector = Globals.detectors.get(detector_name, None) if not detector: raise ValueError, "No such detector defined; detector='%s'" % (detector_name,) res = detector.detect(side, data) self.results[detector_name] = res.result if res.result == DetectResult.MATCH: service = Globals.services.get(service_name, None) if not service: raise ValueError, "No such service defined; service='%s'" % (service_name,) log(self.session.session_id, CORE_POLICY, 3, "Detector starting service; service='%s'" % service) return service elif res.result == DetectResult.NOMATCH: count_nomatch_detectors += 1 elif res.result == DetectResult.COPY_CLIENT: self.need_server_connect = TRUE self.copy_client_data = res.bytes_to_copy if len(self._detector_config) == count_nomatch_detectors: self.quit = TRUE return service
def detect(self, side, data): service = None count_nomatch_detectors = 0 for detector_name, service_name in self._detector_config.iteritems(): if (self.results[detector_name] == DetectResult.NOMATCH): count_nomatch_detectors += 1 continue detector = Globals.detectors.get(detector_name, None) if not detector: raise ValueError, "No such detector defined; detector='%s'" % (detector_name,) res = detector.detect(side, data) self.results[detector_name] = res.result if res.result == DetectResult.MATCH: service = Globals.services.get(service_name, None) if not service: raise ValueError, "No such service defined; service='%s'" % (service_name,) log(self.session.session_id, CORE_POLICY, 3, "Detector starting service; service='%s'" % service) return service elif res.result == DetectResult.NOMATCH: count_nomatch_detectors += 1 elif res.result == DetectResult.COPY_CLIENT: self.need_server_connect = TRUE self.copy_client_data = res.bytes_to_copy if len(self._detector_config) == count_nomatch_detectors: service = Globals.services.get(self._detector_default_service_name, None) self.quit = TRUE return service
def _open_lockfile(self, filename): try: try: fd = open(filename, 'r+') except IOError: fd = open(filename, 'w') return fd except IOError, e: log(None, CORE_ERROR, 3, "Error opening lock file; file='%s', error='%s'", (e.filename, e.strerror))
def __init__(self, session): Proxy.__init__(self, session) log(self.session.session_id, CORE_SESSION, 5, "Proxy start") self._detector_config = session.service.detector_config self.results = {}