If a bridge configures BridgeDistribution https and then changes its mind and configures BridgeDistribution any, BridgeDB won't allow that and keeps thinking that the bridge wants to be distributed over HTTPS. The offending code is here.
This surprised me and I would consider it unexpected behaviour. Bridges should be able to change their distribution mechanism any time.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
This was more work than I expected because in addition to inserting a bridge into a new hashring, the patch required new methods that make it possible to remove a bridge from its previous hashring.
Hey! Looks good, I like the general structure of the changes. Some feedback:
Since we're ignoring the returned distributor from the SQL query here, it makes more sense to modify the query to return only what we need:
cur.execute("SELECT id FROM Bridges WHERE hex_key = ?", (h,))
The logic for removing bridges by finding their index here seems a bit unwieldy to me. I noticed another, similar function of the code here that does the following:
index = 0 logging.debug("Inserting %s into hashring..." % bridge) for old_bridge in self.bridges[:]: if bridge.fingerprint == old_bridge.fingerprint: self.bridges[index] = bridge break index += 1
Is there a better way to handle this? Or a way to be more consistent? Perhaps we could refactor this logic into its own function that takes a bridge and returns its index in self.bridges. Would making self.bridges a map help?
Do the tests also check that bridges were removed from all subrings? Can we do that easily?
The logic for removing bridges by finding their index here seems a bit unwieldy to me. I noticed another, similar function of the code here that does the following:
{{{
index = 0 logging.debug("Inserting %s into hashring..." % bridge) for old_bridge in self.bridges[:]: if bridge.fingerprint == old_bridge.fingerprint: self.bridges[index] = bridge break index += 1
}}}
Is there a better way to handle this? Or a way to be more consistent? Perhaps we could refactor this logic into its own function that takes a bridge and returns its index in self.bridges. Would making self.bridges a map help?