平台:Debian 9
Matrix/synapse 版本:0.22.1-1
我首先安装了必要的依赖项:
$ pip 安装 lxml
$ pip 安装 netaddr
$ pip 安装 twisted
$ sudo apt 安装 libxslt1-dev
然后我编辑了 /etc/matrix-synapse/homeserver.yaml 以便:
url_preview_enabled: true
url_preview_ip_range_blacklist:
- ‘127.0.0.0/8'
- ‘209.58.160.224/32’
- ‘fc00::/7’
因为我的服务器只有一个外部IP而没有内部子网,所以我认为这是没问题的。
Synapse 服务不断重新启动并产生此错误:
Sep 30 01:44:12 hostname python[29155]: config["url_preview_ip_range_blacklist"]
Sep 30 01:44:12 hostname python[29155]: File "/usr/lib/python2.7/dist-packages/netaddr/ip/sets.py", line 121, in __init__
Sep 30 01:44:12 hostname python[29155]: for cidr in cidr_merge(mergeable):
Sep 30 01:44:12 hostname python[29155]: File "/usr/lib/python2.7/dist-packages/netaddr/ip/__init__.py", line 1549, in cidr_merge
Sep 30 01:44:12 hostname python[29155]: cidr = IPNetwork(ip)
Sep 30 01:44:12 hostname python[29155]: File "/usr/lib/python2.7/dist-packages/netaddr/ip/__init__.py", line 933, in __init__
Sep 30 01:44:12 hostname python[29155]: raise AddrFormatError('invalid IPNetwork %s' % addr)
Sep 30 01:44:12 hostname python[29155]: netaddr.core.AddrFormatError: <exception str() failed>
Sep 30 01:44:12 hostname systemd[1]: matrix-synapse.service: Main process exited, code=exited, status=1/FAILURE
我也尝试了这些但它们都产生了相同的错误:
url_preview_ip_range_blacklist:
- ‘127.0.0.0/8'
- ‘209.58.160.224/32’
- ‘fc00::/7’
url_preview_ip_range_blacklist:
- ‘127.0.0.0/8'
- ‘209.58.160.224/32’
#- ‘fc00::/7’
url_preview_ip_range_blacklist:
- ‘127.0.0.0/8'
#- ‘209.58.160.224/32’
#- ‘fc00::/7’
由于相同错误而失败的更多配置:
url_preview_ip_range_blacklist:
- ‘127.0.0.0/8'
# - ‘209.58.160.224/32’
# - ‘fc00::/7’
url_preview_ip_range_blacklist:
- ‘127.0.0.0'
# - ‘209.58.160.224/32’
# - ‘fc00::/7’
url_preview_ip_range_blacklist:
- ‘127.0.0.0/8'
- ‘209.58.160.224’
# - ‘fc00::/7’
最终的解决方案是按照 Max 的建议更改引号:
这有效,最终的语法是:
url_preview_enabled: true
url_preview_ip_range_blacklist:
- '127.0.0.0/8'
- '209.58.160.224/32'
- 'fc00::/7'
答案1
您的某些引号字符不是常规字符,而是“勾选”字符:‘
vs '
,这导致解析失败。