@@ -116,6 +116,47 @@ def probe_geoip(probe_cc: str, asn: str) -> Tuple[Dict, str, int]:
116
116
return resp , probe_cc , asn_int
117
117
118
118
119
+ @probe_services_blueprint .route ("/api/_/discover_probe_ipaddr" , methods = ["GET" ])
120
+ def discover_probe_ipaddr () -> Response :
121
+ """Probe Services: discover probe ipaddr
122
+ ---
123
+ responses:
124
+ '200':
125
+ description: Give a URL test list to a probe running web_connectivity
126
+ tests; additional data for other tests;
127
+ schema:
128
+ type: object
129
+ properties:
130
+ v:
131
+ type: integer
132
+ description: response format version
133
+ cc:
134
+ type: string
135
+ description: probe CC inferred from GeoIP or ZZ
136
+ asn:
137
+ type: string
138
+ description: probe ASN inferred from GeoIP or AS0
139
+ network_name:
140
+ type: string
141
+ description: probe network name inferred from GeoIP or None
142
+ """
143
+ ipaddr = extract_probe_ipaddr ()
144
+ cc = "ZZ"
145
+ asn = "AS0"
146
+ network_name = ""
147
+ try :
148
+ cc = lookup_probe_cc (ipaddr )
149
+ asn , network_name = lookup_probe_network (ipaddr )
150
+ metrics .incr ("geoip_ipaddr_found" )
151
+ except geoip2 .errors .AddressNotFoundError :
152
+ metrics .incr ("geoip_ipaddr_not_found" )
153
+ except Exception as e :
154
+ log = current_app .logger
155
+ log .error (str (e ), exc_info = True )
156
+
157
+ return nocachejson (v = 1 , ipaddr = ipaddr , cc = cc , asn = asn , network_name = network_name )
158
+
159
+
119
160
@probe_services_blueprint .route ("/api/v1/check-in" , methods = ["POST" ])
120
161
def check_in () -> Response :
121
162
"""Probe Services: check-in. Probes ask for tests to be run
0 commit comments