diff options
author | Erik Johnston <erik@matrix.org> | 2014-09-29 15:59:05 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-09-29 15:59:05 +0100 |
commit | f1bdf40dda5eaba622103b64e749b539e5ce6bf1 (patch) | |
tree | a2a09ff016223528aafa4ce50c9b12698e44c6b1 /synapse/server.py | |
parent | No longer need the Freenode verification key file (diff) | |
parent | Unbreak tests after changing storage API (diff) | |
download | synapse-f1bdf40dda5eaba622103b64e749b539e5ce6bf1.tar.xz |
Merge branch 'whois' of github.com:matrix-org/synapse into develop
Diffstat (limited to 'synapse/server.py')
-rw-r--r-- | synapse/server.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/synapse/server.py b/synapse/server.py index cdea49e6ab..e5b048ede0 100644 --- a/synapse/server.py +++ b/synapse/server.py @@ -143,6 +143,18 @@ class BaseHomeServer(object): def serialize_event(self, e): return serialize_event(self, e) + def get_ip_from_request(self, request): + # May be an X-Forwarding-For header depending on config + ip_addr = request.getClientIP() + if self.config.captcha_ip_origin_is_x_forwarded: + # use the header + if request.requestHeaders.hasHeader("X-Forwarded-For"): + ip_addr = request.requestHeaders.getRawHeaders( + "X-Forwarded-For" + )[0] + + return ip_addr + # Build magic accessors for every dependency for depname in BaseHomeServer.DEPENDENCIES: BaseHomeServer._make_dependency_method(depname) |