24
24
from zope .interface import implementer
25
25
26
26
from twisted .internet import defer
27
- from twisted .internet .endpoints import HostnameEndpoint , wrapClientTLS
27
+ from twisted .internet .endpoints import (
28
+ HostnameEndpoint ,
29
+ UNIXClientEndpoint ,
30
+ wrapClientTLS ,
31
+ )
28
32
from twisted .internet .interfaces import (
29
33
IProtocol ,
30
34
IProtocolFactory ,
42
46
from twisted .web .http_headers import Headers
43
47
from twisted .web .iweb import IAgent , IBodyProducer , IPolicyForHTTPS , IResponse
44
48
45
- from synapse .config .workers import InstanceLocationConfig , InstanceTcpLocationConfig
49
+ from synapse .config .workers import (
50
+ InstanceLocationConfig ,
51
+ InstanceTcpLocationConfig ,
52
+ InstanceUnixLocationConfig ,
53
+ )
46
54
from synapse .http import redact_uri
47
55
from synapse .http .connectproxyclient import HTTPConnectProxyEndpoint , ProxyCredentials
48
56
from synapse .logging .context import run_in_background
@@ -142,8 +150,9 @@ def __init__(
142
150
143
151
self ._federation_proxy_endpoint : Optional [IStreamClientEndpoint ] = None
144
152
if federation_proxies :
145
- endpoints = []
153
+ endpoints : List [ IStreamClientEndpoint ] = []
146
154
for federation_proxy in federation_proxies :
155
+ endpoint : IStreamClientEndpoint
147
156
if isinstance (federation_proxy , InstanceTcpLocationConfig ):
148
157
endpoint = HostnameEndpoint (
149
158
self .proxy_reactor ,
@@ -160,7 +169,18 @@ def __init__(
160
169
)
161
170
endpoint = wrapClientTLS (tls_connection_creator , endpoint )
162
171
163
- endpoints .append (endpoint )
172
+ elif isinstance (federation_proxy , InstanceUnixLocationConfig ):
173
+ endpoint = UNIXClientEndpoint (
174
+ self .proxy_reactor , federation_proxy .path
175
+ )
176
+
177
+ else :
178
+ # It is supremely unlikely we ever hit this
179
+ raise SchemeNotSupported (
180
+ f"Unknown type of Endpoint requested, check { federation_proxy } "
181
+ )
182
+
183
+ endpoints .append (endpoint )
164
184
165
185
self ._federation_proxy_endpoint = _ProxyEndpoints (endpoints )
166
186
0 commit comments