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
Container Registry
Model registry
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
Maunium
synapse
Commits
a04c6bbf
Commit
a04c6bbf
authored
7 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
test federation client: Allow server-name and key-file as options
so that you don't necessarily need a config file.
parent
046b659c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts-dev/federation_client.py
+28
-8
28 additions, 8 deletions
scripts-dev/federation_client.py
with
28 additions
and
8 deletions
scripts-dev/federation_client.py
+
28
−
8
View file @
a04c6bbf
...
...
@@ -160,12 +160,23 @@ def main():
"
Signs and sends a federation request to a matrix homeserver
"
,
)
parser
.
add_argument
(
"
-N
"
,
"
--server-name
"
,
help
=
"
Name to give as the local homeserver. If unspecified, will be
"
"
read from the config file.
"
,
)
parser
.
add_argument
(
"
-k
"
,
"
--signing-key-path
"
,
help
=
"
Path to the file containing the private ed25519 key to sign the
"
"
request with.
"
,
)
parser
.
add_argument
(
"
-c
"
,
"
--config
"
,
type
=
argparse
.
FileType
(
'
r
'
),
default
=
"
homeserver.yaml
"
,
help
=
"
Path to server config file.
Used to
re
a
d i
n
server
name and
key
"
"
file
"
,
help
=
"
Path to server config file.
Igno
red i
f --
server
-
name and
"
"
--signing-key-path are both given.
"
,
)
parser
.
add_argument
(
...
...
@@ -182,19 +193,28 @@ def main():
args
=
parser
.
parse_args
()
config
=
yaml
.
safe_load
(
args
.
config
)
origin_name
=
config
[
'
server_name
'
]
keyfile
=
config
[
'
signing_key_path
'
]
if
not
args
.
server_name
or
not
args
.
signing_key_path
:
read_args_from_config
(
args
)
with
open
(
keyfile
)
as
f
:
with
open
(
args
.
signing_key_path
)
as
f
:
key
=
read_signing_keys
(
f
)[
0
]
result
=
get_json
(
origin
_name
,
key
,
args
.
destination
,
"
/_matrix/federation/v1/
"
+
args
.
path
args
.
server
_name
,
key
,
args
.
destination
,
"
/_matrix/federation/v1/
"
+
args
.
path
)
json
.
dump
(
result
,
sys
.
stdout
)
print
(
""
)
def
read_args_from_config
(
args
):
with
open
(
args
.
config
,
'
r
'
)
as
fh
:
config
=
yaml
.
safe_load
(
fh
)
if
not
args
.
server_name
:
args
.
server_name
=
config
[
'
server_name
'
]
if
not
args
.
signing_key_path
:
args
.
signing_key_path
=
config
[
'
signing_key_path
'
]
if
__name__
==
"
__main__
"
:
main
()
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