summary refs log tree commit diff
path: root/synapse/config
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2018-06-28 20:31:53 +0100
committerMatthew Hodgson <matthew@matrix.org>2018-06-28 20:32:00 +0100
commitf4f1cda928911197332a9a8bffcfb67c2b5b81e4 (patch)
tree0e503f9ad56153962096540b3c1a56b18359b0d2 /synapse/config
parentAttempt to be more performant on PyPy (#3462) (diff)
downloadsynapse-f4f1cda928911197332a9a8bffcfb67c2b5b81e4.tar.xz
add ip_range_whitelist parameter to limit where ASes can connect from
Diffstat (limited to 'synapse/config')
-rw-r--r--synapse/config/appservice.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/synapse/config/appservice.py b/synapse/config/appservice.py
index 277305e184..89c07f202f 100644
--- a/synapse/config/appservice.py
+++ b/synapse/config/appservice.py
@@ -17,6 +17,8 @@ from ._base import Config, ConfigError
 from synapse.appservice import ApplicationService
 from synapse.types import UserID
 
+from netaddr import IPSet
+
 import yaml
 import logging
 
@@ -154,6 +156,12 @@ def _load_appservice(hostname, as_info, config_filename):
             " will not receive events or queries.",
             config_filename,
         )
+
+    if as_info.get('ip_range_whitelist'):
+        ip_range_whitelist = IPSet(
+            as_info.get('ip_range_whitelist')
+        )
+
     return ApplicationService(
         token=as_info["as_token"],
         hostname=hostname,
@@ -163,5 +171,6 @@ def _load_appservice(hostname, as_info, config_filename):
         sender=user_id,
         id=as_info["id"],
         protocols=protocols,
-        rate_limited=rate_limited
+        rate_limited=rate_limited,
+        ip_range_whitelist=ip_range_whitelist,
     )