File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 1- from typing import List
1+ from typing import List , Dict
22from pydantic_settings import BaseSettings
33
44
@@ -41,3 +41,21 @@ class Settings(BaseSettings):
4141 failed_reports_bucket : str = (
4242 "" # for uploading reports that couldn't be sent to fastpath
4343 )
44+
45+ # ooniprobe client configuration
46+ collectors : List [Dict [str , str ]] = [
47+ {"address" : "httpo://guegdifjy7bjpequ.onion" , "type" : "onion" },
48+ {"address" : "https://ams-pg.ooni.org:443" , "type" : "https" },
49+ {
50+ "address" : "https://dkyhjv0wpi2dk.cloudfront.net" ,
51+ "front" : "dkyhjv0wpi2dk.cloudfront.net" ,
52+ "type" : "cloudfront" ,
53+ },
54+ {"address" : "httpo://guegdifjy7bjpequ.onion" , "type" : "onion" },
55+ {"address" : "https://ams-pg.ooni.org:443" , "type" : "https" },
56+ {
57+ "address" : "https://dkyhjv0wpi2dk.cloudfront.net" ,
58+ "front" : "dkyhjv0wpi2dk.cloudfront.net" ,
59+ "type" : "cloudfront" ,
60+ },
61+ ]
Original file line number Diff line number Diff line change @@ -590,3 +590,21 @@ def random_web_test_helpers(th_list: List[str]) -> List[Dict]:
590590 for th_addr in th_list :
591591 out .append ({"address" : th_addr , "type" : "https" })
592592 return out
593+
594+
595+ class CollectorEntry (BaseModel ):
596+ # not actually used but necessary to be compliant with the old API schema
597+ address : str = Field (description = "Address of collector" )
598+ front : Optional [str ] = Field (default = None , description = "Fronted domain" )
599+ type : Optional [str ] = Field (default = None , description = "Type of collector" )
600+
601+ @router .post ("/collectors" , tags = ["ooniprobe" ])
602+ def list_collectors (
603+ settings : Settings = Depends (get_settings ),
604+ ) -> List [CollectorEntry ]:
605+ config_collectors = settings .collectors
606+ collectors_response = []
607+ for entry in config_collectors :
608+ collector = CollectorEntry (** entry )
609+ collectors_response .append (collector )
610+ return collectors_response
Original file line number Diff line number Diff line change 1+ def test_list_collectors (client ):
2+ c = client .post ("/api/v1/collectors" ).json ()
3+ assert len (c ) == 6
4+ for entry in c :
5+ assert "address" in entry
You can’t perform that action at this time.
0 commit comments