Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
relay
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Pleroma
relay
Commits
132cd1ea
Commit
132cd1ea
authored
Sep 30, 2019
by
kaniini
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix' into 'master'
Fix db wipe on json error and default config checking See merge request
!19
parents
f3b4fc44
b4f08351
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
5 deletions
+26
-5
relay/__init__.py
relay/__init__.py
+17
-1
relay/actor.py
relay/actor.py
+1
-1
relay/database.py
relay/database.py
+8
-3
No files found.
relay/__init__.py
View file @
132cd1ea
...
...
@@ -9,7 +9,23 @@ import yaml
def
load_config
():
with
open
(
'relay.yaml'
)
as
f
:
return
yaml
.
load
(
f
)
yaml_file
=
yaml
.
load
(
f
)
whitelist
=
yaml_file
[
'ap'
].
get
(
'whitelist'
,
[])
blocked
=
yaml_file
[
'ap'
].
get
(
'blocked_instances'
,
[])
config
=
{
'db'
:
yaml_file
.
get
(
'db'
,
'relay.jsonld'
),
'listen'
:
yaml_file
.
get
(
'listen'
,
'0.0.0.0'
),
'port'
:
int
(
yaml_file
.
get
(
'port'
,
8080
)),
'note'
:
yaml_file
.
get
(
'note'
,
'Make a note about your instance here.'
),
'ap'
:
{
'blocked_instances'
:
[]
if
blocked
is
None
else
blocked
,
'host'
:
yaml_file
[
'ap'
].
get
(
'host'
,
'localhost'
),
'whitelist'
:
[]
if
whitelist
is
None
else
whitelist
,
'whitelist_enabled'
:
yaml_file
[
'ap'
].
get
(
'whitelist_enabled'
,
False
)
}
}
return
config
CONFIG
=
load_config
()
...
...
relay/actor.py
View file @
132cd1ea
...
...
@@ -36,7 +36,7 @@ from . import app, CONFIG
from
.remote_actor
import
fetch_actor
AP_CONFIG
=
CONFIG
.
get
(
'ap'
,
{
'host'
:
'localhost'
,
'blocked_instances'
:[],
'whitelist_enabled'
:
False
,
'whitelist'
:
[]})
AP_CONFIG
=
CONFIG
[
'ap'
]
CACHE_SIZE
=
CONFIG
.
get
(
'cache-size'
,
16384
)
...
...
relay/database.py
View file @
132cd1ea
...
...
@@ -2,19 +2,24 @@ import asyncio
import
logging
import
urllib.parse
import
simplejson
as
json
from
sys
import
exit
from
.
import
CONFIG
AP_CONFIG
=
CONFIG
.
get
(
'ap'
,
{
'blocked_instances'
:[],
'whitelist_enabled'
:
False
,
'whitelist'
:
[]})
AP_CONFIG
=
CONFIG
[
'ap'
]
try
:
with
open
(
CONFIG
[
'db'
])
as
f
:
DATABASE
=
json
.
load
(
f
)
except
:
except
FileNotFoundError
:
logging
.
info
(
'No database was found, making a new one.'
)
DATABASE
=
{}
except
json
.
decoder
.
JSONDecodeError
:
logging
.
info
(
'Invalid JSON in db. Exiting...'
)
exit
(
1
)
following
=
DATABASE
.
get
(
'relay-list'
,
[])
for
inbox
in
following
:
if
urllib
.
parse
.
urlsplit
(
inbox
).
hostname
in
AP_CONFIG
[
'blocked_instances'
]:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment