def prepare(self, reactor, clock, homeserver): class Authenticator(object): def authenticate_request(self, request, content): return defer.succeed("otherserver.nottld") ratelimiter = FederationRateLimiter(clock, FederationRateLimitConfig()) server.register_servlets(homeserver, self.resource, Authenticator(), ratelimiter)
def prepare(self, reactor, clock, homeserver): class Authenticator(object): def authenticate_request(self, request, content): return defer.succeed("otherserver.nottld") ratelimiter = FederationRateLimiter( clock, FederationRateLimitConfig( window_size=1, sleep_limit=1, sleep_msec=1, reject_limit=1000, concurrent_requests=1000, ), ) server.register_servlets(homeserver, self.resource, Authenticator(), ratelimiter)
def __init__(self, hs: "HomeServer"): super().__init__() self.hs = hs self.registration_handler = hs.get_registration_handler() self.ratelimiter = FederationRateLimiter( hs.get_clock(), FederationRateLimitConfig( # Time window of 2s window_size=2000, # Artificially delay requests if rate > sleep_limit/window_size sleep_limit=1, # Amount of artificial delay to apply sleep_delay=1000, # Error with 429 if more than reject_limit requests are queued reject_limit=1, # Allow 1 request at a time concurrent=1, ), )
def __init__(self, hs): super().__init__(hs) class Authenticator: def authenticate_request(self, request, content): return succeed("other.example.com") authenticator = Authenticator() ratelimiter = FederationRateLimiter( hs.get_clock(), FederationRateLimitConfig( window_size=1, sleep_limit=1, sleep_msec=1, reject_limit=1000, concurrent_requests=1000, ), ) federation_server.register_servlets(hs, self, authenticator, ratelimiter)
def __init__(self, hs): """ Args: hs (synapse.server.HomeServer): server """ super(UsernameAvailabilityRestServlet, self).__init__() self.hs = hs self.registration_handler = hs.get_registration_handler() self.ratelimiter = FederationRateLimiter( hs.get_clock(), FederationRateLimitConfig( # Time window of 2s window_size=2000, # Artificially delay requests if rate > sleep_limit/window_size sleep_limit=1, # Amount of artificial delay to apply sleep_msec=1000, # Error with 429 if more than reject_limit requests are queued reject_limit=1, # Allow 1 request at a time concurrent_requests=1, ))