Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
d45f89c9
Commit
d45f89c9
authored
10 years ago
by
Mark Haines
Browse files
Options
Downloads
Patches
Plain Diff
More helpful error messages for missing config
parent
ab0637c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
synapse/config/_base.py
+23
-2
23 additions, 2 deletions
synapse/config/_base.py
synapse/config/server.py
+1
-1
1 addition, 1 deletion
synapse/config/server.py
synapse/config/tls.py
+5
-3
5 additions, 3 deletions
synapse/config/tls.py
with
29 additions
and
6 deletions
synapse/config/_base.py
+
23
−
2
View file @
d45f89c9
...
@@ -21,6 +21,10 @@ import os
...
@@ -21,6 +21,10 @@ import os
import
yaml
import
yaml
class
ConfigError
(
Exception
):
pass
class
Config
(
object
):
class
Config
(
object
):
def
__init__
(
self
,
args
):
def
__init__
(
self
,
args
):
pass
pass
...
@@ -29,8 +33,25 @@ class Config(object):
...
@@ -29,8 +33,25 @@ class Config(object):
def
abspath
(
file_path
):
def
abspath
(
file_path
):
return
os
.
path
.
abspath
(
file_path
)
if
file_path
else
file_path
return
os
.
path
.
abspath
(
file_path
)
if
file_path
else
file_path
@staticmethod
@classmethod
def
read_file
(
file_path
):
def
check_file
(
cls
,
file_path
,
config_name
):
if
file_path
is
None
:
raise
ConfigError
(
"
Missing config for %s.
"
"
Try running again with --generate-config
"
%
(
config_name
,)
)
if
not
os
.
path
.
exists
(
file_path
):
raise
ConfigError
(
"
File % config for %s doesn
'
t exist.
"
"
Try running again with --generate-config
"
%
(
config_name
,)
)
return
cls
.
abspath
(
file_path
)
@classmethod
def
read_file
(
cls
,
file_path
,
config_name
):
cls
.
check_file
(
file_path
,
config_name
)
with
open
(
file_path
)
as
file_stream
:
with
open
(
file_path
)
as
file_stream
:
return
file_stream
.
read
()
return
file_stream
.
read
()
...
...
This diff is collapsed.
Click to expand it.
synapse/config/server.py
+
1
−
1
View file @
d45f89c9
...
@@ -60,7 +60,7 @@ class ServerConfig(Config):
...
@@ -60,7 +60,7 @@ class ServerConfig(Config):
"
service on the given port.
"
)
"
service on the given port.
"
)
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_base64
=
self
.
read_file
(
signing_key_path
,
"
signing_key
"
)
signing_key_bytes
=
decode_base64
(
signing_key_base64
)
signing_key_bytes
=
decode_base64
(
signing_key_base64
)
return
nacl
.
signing
.
SigningKey
(
signing_key_bytes
)
return
nacl
.
signing
.
SigningKey
(
signing_key_bytes
)
...
...
This diff is collapsed.
Click to expand it.
synapse/config/tls.py
+
5
−
3
View file @
d45f89c9
...
@@ -31,7 +31,9 @@ class TlsConfig(Config):
...
@@ -31,7 +31,9 @@ class TlsConfig(Config):
self
.
tls_private_key
=
self
.
read_tls_private_key
(
self
.
tls_private_key
=
self
.
read_tls_private_key
(
args
.
tls_private_key_path
args
.
tls_private_key_path
)
)
self
.
tls_dh_params_path
=
self
.
abspath
(
args
.
tls_dh_params_path
)
self
.
tls_dh_params_path
=
self
.
check_path
(
args
.
tls_dh_params_path
,
"
tls_dh_params
"
)
@classmethod
@classmethod
def
add_arguments
(
cls
,
parser
):
def
add_arguments
(
cls
,
parser
):
...
@@ -45,11 +47,11 @@ class TlsConfig(Config):
...
@@ -45,11 +47,11 @@ class TlsConfig(Config):
help
=
"
PEM dh parameters for ephemeral keys
"
)
help
=
"
PEM dh parameters for ephemeral keys
"
)
def
read_tls_certificate
(
self
,
cert_path
):
def
read_tls_certificate
(
self
,
cert_path
):
cert_pem
=
self
.
read_file
(
cert_path
)
cert_pem
=
self
.
read_file
(
cert_path
,
"
tls_certificate
"
)
return
crypto
.
load_certificate
(
crypto
.
FILETYPE_PEM
,
cert_pem
)
return
crypto
.
load_certificate
(
crypto
.
FILETYPE_PEM
,
cert_pem
)
def
read_tls_private_key
(
self
,
private_key_path
):
def
read_tls_private_key
(
self
,
private_key_path
):
private_key_pem
=
self
.
read_file
(
private_key_path
)
private_key_pem
=
self
.
read_file
(
private_key_path
,
"
tls_private_key
"
)
return
crypto
.
load_privatekey
(
crypto
.
FILETYPE_PEM
,
private_key_pem
)
return
crypto
.
load_privatekey
(
crypto
.
FILETYPE_PEM
,
private_key_pem
)
@classmethod
@classmethod
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment