Skip to content

Commit

Permalink
Merge pull request #6 from Michielo1/location-detection
Browse files Browse the repository at this point in the history
Initial location collection
  • Loading branch information
Michielo1 authored Oct 17, 2024
2 parents 4fa2199 + c2b464a commit 41f5b6b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/michielo/antivpn/api/impl/KauriAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.michielo.antivpn.api.APIResult;
import com.michielo.antivpn.api.VPNResult;
import com.michielo.antivpn.api.VpnAPI;
import org.bukkit.Bukkit;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down Expand Up @@ -49,12 +50,13 @@ public APIResult checkIP(String ip) {
http.disconnect();

Boolean proxy = Boolean.valueOf(jsonObject.get("proxy").getAsString());
String location = jsonObject.get("latitude").getAsString() + ";" + jsonObject.get("longitude").getAsString();

VPNResult result = VPNResult.NEGATIVE;
if (proxy) result = VPNResult.POSITIVE;

return new APIResult(result);
} catch (IOException e) {
return new APIResult(result, location);
} catch (IOException | NullPointerException e) {
e.printStackTrace();
}
return new APIResult(VPNResult.UNKNOWN);
Expand Down

0 comments on commit 41f5b6b

Please sign in to comment.