Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -590,3 +590,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: Settings = Depends(get_settings),
) -> 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