mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Split ratelimiters in two (one for events, one for registration)
This commit is contained in:
parent
c23e8c3333
commit
d7dbad3526
@ -44,7 +44,7 @@ class BaseHandler(object):
|
|||||||
self.notifier = hs.get_notifier()
|
self.notifier = hs.get_notifier()
|
||||||
self.state_handler = hs.get_state_handler()
|
self.state_handler = hs.get_state_handler()
|
||||||
self.distributor = hs.get_distributor()
|
self.distributor = hs.get_distributor()
|
||||||
self.ratelimiter = hs.get_ratelimiter()
|
self.ratelimiter = hs.get_events_ratelimiter()
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
self.hs = hs
|
self.hs = hs
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ class EventCreationHandler(object):
|
|||||||
self.profile_handler = hs.get_profile_handler()
|
self.profile_handler = hs.get_profile_handler()
|
||||||
self.event_builder_factory = hs.get_event_builder_factory()
|
self.event_builder_factory = hs.get_event_builder_factory()
|
||||||
self.server_name = hs.hostname
|
self.server_name = hs.hostname
|
||||||
self.ratelimiter = hs.get_ratelimiter()
|
self.ratelimiter = hs.get_events_ratelimiter()
|
||||||
self.notifier = hs.get_notifier()
|
self.notifier = hs.get_notifier()
|
||||||
self.config = hs.config
|
self.config = hs.config
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class RegistrationHandler(BaseHandler):
|
|||||||
self.user_directory_handler = hs.get_user_directory_handler()
|
self.user_directory_handler = hs.get_user_directory_handler()
|
||||||
self.captcha_client = CaptchaServerHttpClient(hs)
|
self.captcha_client = CaptchaServerHttpClient(hs)
|
||||||
self.identity_handler = self.hs.get_handlers().identity_handler
|
self.identity_handler = self.hs.get_handlers().identity_handler
|
||||||
self.ratelimiter = hs.get_ratelimiter()
|
self.ratelimiter = hs.get_registration_ratelimiter()
|
||||||
|
|
||||||
self._next_generated_user_id = None
|
self._next_generated_user_id = None
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ class RegisterRestServlet(RestServlet):
|
|||||||
self.identity_handler = hs.get_handlers().identity_handler
|
self.identity_handler = hs.get_handlers().identity_handler
|
||||||
self.room_member_handler = hs.get_room_member_handler()
|
self.room_member_handler = hs.get_room_member_handler()
|
||||||
self.macaroon_gen = hs.get_macaroon_generator()
|
self.macaroon_gen = hs.get_macaroon_generator()
|
||||||
self.ratelimiter = hs.get_ratelimiter()
|
self.ratelimiter = hs.get_registration_ratelimiter()
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
|
|
||||||
@interactive_auth_handler
|
@interactive_auth_handler
|
||||||
|
@ -205,7 +205,8 @@ class HomeServer(object):
|
|||||||
|
|
||||||
self.clock = Clock(reactor)
|
self.clock = Clock(reactor)
|
||||||
self.distributor = Distributor()
|
self.distributor = Distributor()
|
||||||
self.ratelimiter = Ratelimiter()
|
self.events_ratelimiter = Ratelimiter()
|
||||||
|
self.registration_ratelimiter = Ratelimiter()
|
||||||
|
|
||||||
self.datastore = None
|
self.datastore = None
|
||||||
|
|
||||||
@ -248,8 +249,11 @@ class HomeServer(object):
|
|||||||
def get_distributor(self):
|
def get_distributor(self):
|
||||||
return self.distributor
|
return self.distributor
|
||||||
|
|
||||||
def get_ratelimiter(self):
|
def get_events_ratelimiter(self):
|
||||||
return self.ratelimiter
|
return self.events_ratelimiter
|
||||||
|
|
||||||
|
def get_registration_ratelimiter(self):
|
||||||
|
return self.registration_ratelimiter
|
||||||
|
|
||||||
def build_federation_client(self):
|
def build_federation_client(self):
|
||||||
return FederationClient(self)
|
return FederationClient(self)
|
||||||
|
@ -58,7 +58,7 @@ class ProfileTestCase(unittest.TestCase):
|
|||||||
ratelimiter=NonCallableMock(spec_set=["can_do_action"]),
|
ratelimiter=NonCallableMock(spec_set=["can_do_action"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.ratelimiter = hs.get_ratelimiter()
|
self.ratelimiter = hs.get_events_ratelimiter()
|
||||||
self.ratelimiter.can_do_action.return_value = (True, 0)
|
self.ratelimiter.can_do_action.return_value = (True, 0)
|
||||||
|
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
|
@ -34,7 +34,7 @@ class BaseSlavedStoreTestCase(unittest.HomeserverTestCase):
|
|||||||
ratelimiter=NonCallableMock(spec_set=["can_do_action"]),
|
ratelimiter=NonCallableMock(spec_set=["can_do_action"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
hs.get_ratelimiter().can_do_action.return_value = (True, 0)
|
hs.get_events_ratelimiter().can_do_action.return_value = (True, 0)
|
||||||
|
|
||||||
return hs
|
return hs
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class EventStreamPermissionsTestCase(unittest.HomeserverTestCase):
|
|||||||
hs = self.setup_test_homeserver(
|
hs = self.setup_test_homeserver(
|
||||||
config=config, ratelimiter=NonCallableMock(spec_set=["can_do_action"])
|
config=config, ratelimiter=NonCallableMock(spec_set=["can_do_action"])
|
||||||
)
|
)
|
||||||
self.ratelimiter = hs.get_ratelimiter()
|
self.ratelimiter = hs.get_events_ratelimiter()
|
||||||
self.ratelimiter.can_do_action.return_value = (True, 0)
|
self.ratelimiter.can_do_action.return_value = (True, 0)
|
||||||
|
|
||||||
hs.get_handlers().federation_handler = Mock()
|
hs.get_handlers().federation_handler = Mock()
|
||||||
|
@ -47,7 +47,7 @@ class RoomTypingTestCase(unittest.HomeserverTestCase):
|
|||||||
|
|
||||||
self.event_source = hs.get_event_sources().sources["typing"]
|
self.event_source = hs.get_event_sources().sources["typing"]
|
||||||
|
|
||||||
self.ratelimiter = hs.get_ratelimiter()
|
self.ratelimiter = hs.get_events_ratelimiter()
|
||||||
self.ratelimiter.can_do_action.return_value = (True, 0)
|
self.ratelimiter.can_do_action.return_value = (True, 0)
|
||||||
|
|
||||||
hs.get_handlers().federation_handler = Mock()
|
hs.get_handlers().federation_handler = Mock()
|
||||||
|
Loading…
Reference in New Issue
Block a user