File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -234,8 +234,9 @@ class _MyAppState extends State<MyApp> {
234234 }
235235
236236 Future <Map <String , dynamic >> _geoLookup (String ip) async {
237- final uri = Uri .parse ('https://geoip.grid.tf/?ip=${Uri .encodeQueryComponent (ip )}' );
238- final resp = await http.get (uri, headers: {'Accept' : 'application/json' });
237+ final uri = Uri .parse ('https://geoip.grid.tf/' );
238+ final resp = await http
239+ .get (uri, headers: {'Accept' : 'application/json' , 'X-Real-IP' : ip});
239240 if (resp.statusCode != 200 ) {
240241 throw Exception ('geo lookup failed: ${resp .statusCode }' );
241242 }
@@ -381,7 +382,14 @@ class _MyAppState extends State<MyApp> {
381382 _rawPeersText = v;
382383 _geoDebounce? .cancel ();
383384 _geoDebounce = Timer (const Duration (milliseconds: 500 ), () async {
385+ if (! mounted) return ;
384386 final currentPeers = preprocessPeers (getPeers (_rawPeersText));
387+ if (currentPeers.isEmpty) {
388+ setState (() {
389+ _peerToCountry = {};
390+ });
391+ return ;
392+ }
385393 await _fetchAndGroupPeersByCountry (currentPeers);
386394 if (mounted) setState (() {});
387395 });
You can’t perform that action at this time.
0 commit comments