Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ooniapi/common/src/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class Settings(BaseSettings):

vpn_credential_refresh_hours: int = 24

# Bucket used to store configuration files
config_bucket: str = ""

# Where the geoip DBs are downloaded to
geoip_db_dir: str = "/var/lib/ooni/geoip"
# Ooniprobe only
Expand Down
14 changes: 13 additions & 1 deletion ooniapi/services/ooniprobe/src/ooniprobe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
from datetime import datetime, timezone
import itertools
import logging
from typing import Dict, List, Mapping, TypedDict, Tuple
from typing import List, TypedDict, Tuple
import io

from fastapi import Request
from mypy_boto3_s3 import S3Client
from sqlalchemy.orm import Session
import pem
import httpx
Expand Down Expand Up @@ -145,3 +147,13 @@ def lookup_probe_network(ipaddr: str, asn_reader: ASNReaderDep) -> Tuple[str, st
"AS{}".format(resp.autonomous_system_number),
resp.autonomous_system_organization or "0",
)

def read_file(s3_client : S3Client, bucket: str, file : str) -> str:
"""
Reads the content of `file` within `bucket` into a string

Useful for reading config files from the s3 bucket
"""
buff = io.BytesIO()
s3_client.download_fileobj(bucket, file, buff)
return buff.getvalue().decode()