mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Add option to change content repo location
This commit is contained in:
parent
ce5c88006e
commit
bc21350298
@ -74,7 +74,9 @@ class SynapseHomeServer(HomeServer):
|
|||||||
return File("webclient") # TODO configurable?
|
return File("webclient") # TODO configurable?
|
||||||
|
|
||||||
def build_resource_for_content_repo(self):
|
def build_resource_for_content_repo(self):
|
||||||
return ContentRepoResource(self, self.upload_dir, self.auth)
|
return ContentRepoResource(
|
||||||
|
self, self.upload_dir, self.auth, self.content_addr
|
||||||
|
)
|
||||||
|
|
||||||
def build_db_pool(self):
|
def build_db_pool(self):
|
||||||
""" Set up all the dbs. Since all the *.sql have IF NOT EXISTS, so we
|
""" Set up all the dbs. Since all the *.sql have IF NOT EXISTS, so we
|
||||||
@ -248,6 +250,7 @@ def setup():
|
|||||||
db_name=config.database_path,
|
db_name=config.database_path,
|
||||||
tls_context_factory=tls_context_factory,
|
tls_context_factory=tls_context_factory,
|
||||||
config=config,
|
config=config,
|
||||||
|
content_addr=config.content_addr,
|
||||||
)
|
)
|
||||||
|
|
||||||
hs.register_servlets()
|
hs.register_servlets()
|
||||||
|
@ -32,6 +32,14 @@ class ServerConfig(Config):
|
|||||||
self.webclient = True
|
self.webclient = True
|
||||||
self.manhole = args.manhole
|
self.manhole = args.manhole
|
||||||
|
|
||||||
|
if not args.content_addr:
|
||||||
|
host = args.server_name
|
||||||
|
if ':' not in host:
|
||||||
|
host = "%s:%d" % (host, args.bind_port)
|
||||||
|
args.content_addr = "https://%s" % (host,)
|
||||||
|
|
||||||
|
self.content_addr = args.content_addr
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add_arguments(cls, parser):
|
def add_arguments(cls, parser):
|
||||||
super(ServerConfig, cls).add_arguments(parser)
|
super(ServerConfig, cls).add_arguments(parser)
|
||||||
@ -57,6 +65,9 @@ class ServerConfig(Config):
|
|||||||
type=int,
|
type=int,
|
||||||
help="Turn on the twisted telnet manhole"
|
help="Turn on the twisted telnet manhole"
|
||||||
" service on the given port.")
|
" service on the given port.")
|
||||||
|
server_group.add_argument("--content-addr", default=None,
|
||||||
|
help="The host and scheme to use for the "
|
||||||
|
"content repository")
|
||||||
|
|
||||||
def read_signing_key(self, signing_key_path):
|
def read_signing_key(self, signing_key_path):
|
||||||
signing_key_base64 = self.read_file(signing_key_path, "signing_key")
|
signing_key_base64 = self.read_file(signing_key_path, "signing_key")
|
||||||
@ -77,3 +88,4 @@ class ServerConfig(Config):
|
|||||||
with open(args.signing_key_path, "w") as signing_key_file:
|
with open(args.signing_key_path, "w") as signing_key_file:
|
||||||
key = nacl.signing.SigningKey.generate()
|
key = nacl.signing.SigningKey.generate()
|
||||||
signing_key_file.write(encode_base64(key.encode()))
|
signing_key_file.write(encode_base64(key.encode()))
|
||||||
|
|
||||||
|
@ -215,11 +215,12 @@ class ContentRepoResource(resource.Resource):
|
|||||||
"""
|
"""
|
||||||
isLeaf = True
|
isLeaf = True
|
||||||
|
|
||||||
def __init__(self, hs, directory, auth):
|
def __init__(self, hs, directory, auth, external_addr):
|
||||||
resource.Resource.__init__(self)
|
resource.Resource.__init__(self)
|
||||||
self.hs = hs
|
self.hs = hs
|
||||||
self.directory = directory
|
self.directory = directory
|
||||||
self.auth = auth
|
self.auth = auth
|
||||||
|
self.external_addr = external_addr.rstrip('/')
|
||||||
|
|
||||||
if not os.path.isdir(self.directory):
|
if not os.path.isdir(self.directory):
|
||||||
os.mkdir(self.directory)
|
os.mkdir(self.directory)
|
||||||
@ -332,8 +333,8 @@ class ContentRepoResource(resource.Resource):
|
|||||||
# ...plus self-signed SSL won't work to remote clients anyway
|
# ...plus self-signed SSL won't work to remote clients anyway
|
||||||
# ...and we can't assume that it's SSL anyway, as we might want to
|
# ...and we can't assume that it's SSL anyway, as we might want to
|
||||||
# server it via the non-SSL listener...
|
# server it via the non-SSL listener...
|
||||||
url = "https://%s/_matrix/content/%s" % (
|
url = "%s/_matrix/content/%s" % (
|
||||||
self.hs.domain_with_port, file_name
|
self.external_addr, file_name
|
||||||
)
|
)
|
||||||
|
|
||||||
respond_with_json_bytes(request, 200,
|
respond_with_json_bytes(request, 200,
|
||||||
|
Loading…
Reference in New Issue
Block a user