Skip to content

Commit dd193b0

Browse files
committed
Added supports for fraud score
1 parent 2c8f4ae commit dd193b0

File tree

5 files changed

+42
-20
lines changed

5 files changed

+42
-20
lines changed

LICENSE.TXT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 IP2Location.com
3+
Copyright (c) 2025 IP2Location.com
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# IP2Proxy Erlang Module
22

3-
This module allows user to query an IP address if it was being used as VPN anonymizer, open proxies, web proxies, Tor exits, data center, web hosting (DCH) range, search engine robots (SES), residential proxies (RES), consumer privacy networks (CPN), and enterprise private networks (EPN). It lookup the proxy IP address from **IP2Proxy BIN Data** file. This data file can be downloaded at
3+
This module allows user to query an IP address if it was being used as VPN anonymizer, open proxies, web proxies, Tor exits, data center, web hosting (DCH) range, search engine robots (SES), residential proxies (RES), consumer privacy networks (CPN), enterprise private networks (EPN) and fraud score. It lookup the proxy IP address from **IP2Proxy BIN Data** file. This data file can be downloaded at
44

55
* Free IP2Proxy BIN Data: https://lite.ip2location.com
66
* Commercial IP2Proxy BIN Data: https://www.ip2location.com/database/ip2proxy

ip2proxy.erl

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-module(ip2proxy).
2-
-export([getpackageversion/0, getmoduleversion/0, getdatabaseversion/0, open/1, getall/1, getproxytype/1, getcountryshort/1, getcountrylong/1, getregion/1, getcity/1, getisp/1, getdomain/1, getusagetype/1, getasn/1, getas/1, getlastseen/1, getthreat/1, getprovider/1, isproxy/1, close/0, openws/3, lookup/1, getcredit/0]).
2+
-export([getpackageversion/0, getmoduleversion/0, getdatabaseversion/0, open/1, getall/1, getproxytype/1, getcountryshort/1, getcountrylong/1, getregion/1, getcity/1, getisp/1, getdomain/1, getusagetype/1, getasn/1, getas/1, getlastseen/1, getthreat/1, getprovider/1, getfraudscore/1, isproxy/1, close/0, openws/3, lookup/1, getcredit/0]).
33
-record(ip2proxyrecord, {
44
country_short = "-",
55
country_long = "-",
@@ -14,6 +14,7 @@
1414
last_seen = "-",
1515
threat = "-",
1616
provider = "-",
17+
fraud_score = "-",
1718
is_proxy = 0
1819
}).
1920
-record(ip2proxyresult, {
@@ -31,6 +32,7 @@
3132
lastSeen = "-",
3233
threat = "-",
3334
provider = "-",
35+
fraudScore = "-",
3436
isProxy = "-"
3537
}).
3638
-define(IF(Cond), (case (Cond) of true -> (0); false -> (1) end)).
@@ -51,7 +53,7 @@ getpackageversion() ->
5153
end.
5254

5355
getmoduleversion() ->
54-
"3.3.3".
56+
"3.4.0".
5557

5658
getdatabaseversion() ->
5759
case ets:info(mymeta) of
@@ -183,18 +185,19 @@ readcolstringrow(S, R, Dbtype, Col) ->
183185
end.
184186

185187
readrecord(S, R, Dbtype, Mode) ->
186-
Country_position = [0, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
187-
Region_position = [0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4],
188-
City_position = [0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5],
189-
Isp_position = [0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6],
190-
Proxytype_position = [0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
191-
Domain_position = [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7],
192-
Usagetype_position = [0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8],
193-
Asn_position = [0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9],
194-
As_position = [0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10],
195-
Lastseen_position = [0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11],
196-
Threat_position = [0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12],
197-
Provider_position = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13],
188+
Country_position = [0, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
189+
Region_position = [0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
190+
City_position = [0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],
191+
Isp_position = [0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6],
192+
Proxytype_position = [0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
193+
Domain_position = [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7],
194+
Usagetype_position = [0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8],
195+
Asn_position = [0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9],
196+
As_position = [0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10],
197+
Lastseen_position = [0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11],
198+
Threat_position = [0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 12],
199+
Provider_position = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 13],
200+
Fraudscore_position = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14],
198201

199202
Countryshort_field = 1,
200203
Countrylong_field = 2,
@@ -210,6 +213,7 @@ readrecord(S, R, Dbtype, Mode) ->
210213
Lastseen_field = 2048,
211214
Threat_field = 4096,
212215
Provider_field = 8192,
216+
Fraudscore_field = 16384,
213217

214218
if
215219
(Mode band Proxytype_field /= 0) or (Mode band Isproxy_field /= 0) ->
@@ -295,6 +299,13 @@ readrecord(S, R, Dbtype, Mode) ->
295299
Provider = ""
296300
end,
297301

302+
if
303+
Mode band Fraudscore_field /= 0 ->
304+
Fraud_Score = readcolstringrow(S, R, Dbtype, Fraudscore_position);
305+
true ->
306+
Fraud_Score = ""
307+
end,
308+
298309
if
299310
(Country_short == "-") or (Proxy_type == "-") ->
300311
Is_proxy = 0;
@@ -321,6 +332,7 @@ readrecord(S, R, Dbtype, Mode) ->
321332
last_seen = Last_seen,
322333
threat = Threat,
323334
provider = Provider,
335+
fraud_score = Fraud_Score,
324336
is_proxy = Is_proxy
325337
}.
326338

@@ -384,6 +396,7 @@ searchtree(S, Ipnum, Dbtype, Low, High, BaseAddr, Colsize, Iptype, Mode) ->
384396
last_seen = X,
385397
threat = X,
386398
provider = X,
399+
fraud_score = X,
387400
is_proxy = -1
388401
}
389402
end.
@@ -435,7 +448,7 @@ search6(S, Ipnum, Dbtype, Low, High, Baseaddr, Indexbaseaddr, Colsize, Mode) ->
435448
end.
436449

437450
getall(Ip) ->
438-
query(Ip, 16383).
451+
query(Ip, 32767).
439452

440453
getcountryshort(Ip) ->
441454
Result = query(Ip, 1),
@@ -489,6 +502,10 @@ getprovider(Ip) ->
489502
Result = query(Ip, 8192),
490503
Result#ip2proxyrecord.provider.
491504

505+
getfraudscore(Ip) ->
506+
Result = query(Ip, 16384),
507+
Result#ip2proxyrecord.fraud_score.
508+
492509
isproxy(Ip) ->
493510
Result = query(Ip, 64),
494511
Result#ip2proxyrecord.is_proxy.
@@ -563,6 +580,7 @@ query(Ip, Mode) ->
563580
last_seen = Z,
564581
threat = Z,
565582
provider = Z,
583+
fraud_score = Z,
566584
is_proxy = -1
567585
}
568586
end
@@ -582,6 +600,7 @@ query(Ip, Mode) ->
582600
last_seen = X,
583601
threat = X,
584602
provider = X,
603+
fraud_score = X,
585604
is_proxy = -1
586605
}
587606
end,
@@ -602,6 +621,7 @@ query(Ip, Mode) ->
602621
last_seen = Y,
603622
threat = Y,
604623
provider = Y,
624+
fraud_score = Y,
605625
is_proxy = -1
606626
}
607627
end

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule IP2ProxyErlang.MixProject do
44
def project() do
55
[
66
app: :ip2proxy_erlang,
7-
version: "3.3.3",
7+
version: "3.4.0",
88
elixir: "~> 1.0",
99
build_embedded: Mix.env == :prod,
1010
start_permanent: Mix.env == :prod,

test.erl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ printme(V) ->
55
case V of
66
{} ->
77
io:format("No results.~n", []);
8-
{ip2proxyrecord, Country_short, Country_long, Region, City, Isp, Proxy_type, Domain, Usage_type, Asn, As, Last_seen, Threat, Provider, Is_proxy} ->
8+
{ip2proxyrecord, Country_short, Country_long, Region, City, Isp, Proxy_type, Domain, Usage_type, Asn, As, Last_seen, Threat, Provider, Fraud_score, Is_proxy} ->
99
io:format("Country_short: ~p~n", [Country_short]),
1010
io:format("Country_long: ~p~n", [Country_long]),
1111
io:format("Region: ~p~n", [Region]),
@@ -19,13 +19,14 @@ printme(V) ->
1919
io:format("Last_seen: ~p~n", [Last_seen]),
2020
io:format("Threat: ~p~n", [Threat]),
2121
io:format("Provider: ~p~n", [Provider]),
22+
io:format("Fraud_score: ~p~n", [Fraud_score]),
2223
io:format("Is_proxy: ~p~n", [Is_proxy])
2324
end,
2425
io:format("===================================================================~n", []).
2526

2627
testme() ->
2728
X = "37.252.228.50",
28-
case ip2proxy:open("./ip2proxy-testdata/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN") of
29+
case ip2proxy:open("./ip2proxy-testdata/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER-FRAUDSCORE.BIN") of
2930
0 ->
3031
io:format("getpackageversion: ~p~n", [ip2proxy:getpackageversion()]),
3132
io:format("getmoduleversion: ~p~n", [ip2proxy:getmoduleversion()]),
@@ -46,6 +47,7 @@ testme() ->
4647
io:format("Last_seen: ~p~n", [ip2proxy:getlastseen(X)]),
4748
io:format("Threat: ~p~n", [ip2proxy:getthreat(X)]),
4849
io:format("Provider: ~p~n", [ip2proxy:getprovider(X)]),
50+
io:format("Fraud_score: ~p~n", [ip2proxy:getfraudscore(X)]),
4951
io:format("Is_proxy: ~p~n", [ip2proxy:isproxy(X)]);
5052
_ ->
5153
io:format("Error reading BIN file~n", [])

0 commit comments

Comments
 (0)