Skip to content
Merged
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
20 changes: 19 additions & 1 deletion ooniapi/common/src/common/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Dict
from pydantic_settings import BaseSettings


Expand Down Expand Up @@ -41,3 +41,21 @@ class Settings(BaseSettings):
failed_reports_bucket: str = (
"" # for uploading reports that couldn't be sent to fastpath
)

# ooniprobe client configuration
collectors: List[Dict[str, str]] = [
{"address": "httpo://guegdifjy7bjpequ.onion", "type": "onion"},
{"address": "https://ams-pg.ooni.org:443", "type": "https"},
{
"address": "https://dkyhjv0wpi2dk.cloudfront.net",
"front": "dkyhjv0wpi2dk.cloudfront.net",
"type": "cloudfront",
},
{"address": "httpo://guegdifjy7bjpequ.onion", "type": "onion"},
{"address": "https://ams-pg.ooni.org:443", "type": "https"},
{
"address": "https://dkyhjv0wpi2dk.cloudfront.net",
"front": "dkyhjv0wpi2dk.cloudfront.net",
"type": "cloudfront",
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
lookup_probe_network,
)
from ...dependencies import CCReaderDep, ASNReaderDep, ClickhouseDep, SettingsDep
from ...common.dependencies import get_settings
from ...common.routers import BaseModel
from ...common.auth import create_jwt, decode_jwt, jwt
from ...common.config import Settings
Expand Down Expand Up @@ -81,7 +80,7 @@ class ProbeLoginResponse(BaseModel):
def probe_login_post(
probe_login: ProbeLogin,
response: Response,
settings: Settings = Depends(get_settings),
settings: SettingsDep,
) -> ProbeLoginResponse:

if probe_login.username is None or probe_login.password is None:
Expand Down Expand Up @@ -151,7 +150,7 @@ class ProbeRegisterResponse(BaseModel):
def probe_register_post(
probe_register: ProbeRegister,
response: Response,
settings: Settings = Depends(get_settings),
settings: SettingsDep,
) -> ProbeRegisterResponse:
"""Probe Services: Register

Expand Down Expand Up @@ -590,3 +589,21 @@ def random_web_test_helpers(th_list: List[str]) -> List[Dict]:
for th_addr in th_list:
out.append({"address": th_addr, "type": "https"})
return out


class CollectorEntry(BaseModel):
# not actually used but necessary to be compliant with the old API schema
address: str = Field(description="Address of collector")
front: Optional[str] = Field(default=None, description="Fronted domain")
type: Optional[str] = Field(default=None, description="Type of collector")

@router.get("/collectors", tags=["ooniprobe"])
def list_collectors(
settings: SettingsDep,
) -> List[CollectorEntry]:
config_collectors = settings.collectors
collectors_response = []
for entry in config_collectors:
collector = CollectorEntry(**entry)
collectors_response.append(collector)
return collectors_response
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def test_list_collectors(client):
c = client.get("/api/v1/collectors").json()
assert len(c) == 6
for entry in c:
assert "address" in entry
Loading