Verified Commit c78d0b15 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

Revert "A fast experiment with different filters"

This reverts commit 410107dd.
parent 9d9606c1
......@@ -255,13 +255,12 @@ class FlowPlugin(plugin.Plugin, diff_addr_store.DiffAddrStore):
def _broadcast_config(self):
self.__top_filter_cache = {}
self.broadcast(self.__build_config(''), lambda version: version < 2)
self.broadcast(self.__build_config('-diff'), lambda version: version >= 2, lambda client: int(client, 16) >= int('0000000A00000000', 16))
self.broadcast(self.__build_config('-diff'), lambda version: version >= 2)
for a in self._addresses:
self._broadcast_version(a, self._addresses[a][0], self._addresses[a][1])
self.broadcast(self.__build_config('-blue'), lambda client: int(client, 16) < int('0000000A00000000', 16))
def _broadcast_version(self, name, epoch, version):
self.broadcast(self.__build_filter_version(name, epoch, version), lambda version: version >= 2, lambda client: int(client, 16) >= int('0000000A00000000', 16))
self.broadcast(self.__build_filter_version(name, epoch, version), lambda version: version >= 2)
def __build_filter_version(self, name, epoch, version):
return 'U' + struct.pack('!I' + str(len(name)) + 'sII', len(name), name, epoch, version)
......@@ -289,9 +288,7 @@ class FlowPlugin(plugin.Plugin, diff_addr_store.DiffAddrStore):
return
logger.debug('Sending config to %s', client)
self.__delayed_config[client] = False # We know about the client, but it hasn't asked twice yet.
if int(client, 16) < int('0000000A00000000', 16):
self.send(self.__build_config('-blue'), client)
elif self.version(client) < 2:
if self.version(client) < 2:
self.send(self.__build_config(''), client)
else:
self.send(self.__build_config('-diff'), client)
......
......@@ -71,13 +71,13 @@ class Plugin:
"""
pass
def broadcast(self, message, version_check=None, client_check=None):
def broadcast(self, message, version_check=None):
"""
Broadcast a message from this plugin to all the connected
clients.
"""
logger.trace('Broadcasting message to all clients: %s', repr(message))
self.__plugins.broadcast(self.__routed_message(message), self.name(), version_check, client_check)
self.__plugins.broadcast(self.__routed_message(message), self.name(), version_check)
def send(self, message, to):
"""
......@@ -195,15 +195,12 @@ class Plugins:
else:
logger.debug('Not removing client ' + cid)
def broadcast(self, message, from_plugin, version_check=None, client_check=None):
def broadcast(self, message, from_plugin, version_check=None):
"""
Send a message to all the connected clients who has the given plugin, optionally with a version check.
"""
for client in self.__clients:
c = self.__clients[client]
for c in self.__clients.values():
if c.has_plugin(from_plugin):
if client_check and not client_check(client):
continue
if version_check is None or version_check(c.plugin_version(from_plugin)):
c.sendString(message)
else:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment