Skip to content

Commit 7e4480f

Browse files
committed
IPResponse: GetAnycast returns whether an IP is anycast, independent of underlying response field
IPinfo's IP response indicates whether an IP is anycast using either `anycast` or `is_anycast` fields, depending on the token's capabilities.
1 parent afc8386 commit 7e4480f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/io/ipinfo/api/model/IPResponse.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ public class IPResponse {
66
private final String ip;
77
private final String hostname;
88
private final boolean bogon;
9+
10+
// IPinfo's IP response indicates whether an IP is anycast, using either
11+
// `anycast` or `is_anycast` fields, depending on the token's capabilities.
12+
private final boolean anycast;
913
private final boolean is_anycast;
14+
1015
private final String city;
1116
private final String region;
1217
private final String country;
@@ -26,6 +31,7 @@ public IPResponse(
2631
String ip,
2732
String hostname,
2833
boolean bogon,
34+
boolean anycast,
2935
boolean is_anycast,
3036
String city,
3137
String region,
@@ -44,6 +50,7 @@ public IPResponse(
4450
this.ip = ip;
4551
this.hostname = hostname;
4652
this.bogon = bogon;
53+
this.anycast = anycast;
4754
this.is_anycast = is_anycast;
4855
this.city = city;
4956
this.region = region;
@@ -64,7 +71,7 @@ public IPResponse(
6471
String ip,
6572
boolean bogon
6673
) {
67-
this(ip, null, bogon, false, null, null, null, null, null, null, null, null, null, null, null, null, null);
74+
this(ip, null, bogon, false, false, null, null, null, null, null, null, null, null, null, null, null, null, null);
6875
}
6976

7077
/**
@@ -89,7 +96,7 @@ public boolean getBogon() {
8996
}
9097

9198
public boolean getAnycast() {
92-
return is_anycast;
99+
return anycast || is_anycast;
93100
}
94101

95102
public String getCity() {
@@ -195,6 +202,7 @@ public String toString() {
195202
"IPResponse{" +
196203
"ip='" + ip + '\'' +
197204
", hostname='" + hostname + '\'' +
205+
", anycast=" + anycast +
198206
", is_anycast=" + is_anycast +
199207
", city='" + city + '\'' +
200208
", region='" + region + '\'' +

0 commit comments

Comments
 (0)