Skip to content

Commit 4a5ee0c

Browse files
committed
Add readthedocs documentation
1 parent b3b9cfc commit 4a5ee0c

File tree

10 files changed

+358
-0
lines changed

10 files changed

+358
-0
lines changed

.readthedocs.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the OS, Python version and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.11"
13+
# You can also specify other tool versions:
14+
# nodejs: "19"
15+
# rust: "1.64"
16+
# golang: "1.19"
17+
18+
# Build documentation in the "docs/" directory with Sphinx
19+
sphinx:
20+
configuration: docs/source/conf.py
21+
22+
# Optionally build your docs in additional formats such as PDF and ePub
23+
# formats:
24+
# - pdf
25+
# - epub
26+
27+
# Optional but recommended, declare the Python requirements required
28+
# to build your documentation
29+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
30+
python:
31+
install:
32+
- requirements: docs/requirements.txt

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Defining the exact version will make sure things don't break
2+
sphinx-book-theme==1.0.1
3+
# sphinx-pdj-theme==0.4.0
4+
myst-parser==2.0.0
5+
markdown-it-py==3.0.0
6+
sphinx-copybutton==0.5.2

docs/source/code.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# IP2Proxy Java API
2+
3+
## IP2Proxy Class
4+
```{py:class} IP2Proxy()
5+
Initiate IP2Proxy class.
6+
```
7+
```{py:function} Open(binPath)
8+
Load the IP2Proxy BIN database for lookup.
9+
10+
:param String binPath: (Required) The file path links to IP2Proxy BIN databases.
11+
```
12+
13+
```{py:function} Close()
14+
Close and clean up the file pointer.
15+
```
16+
17+
```{py:function} GetPackageVersion()
18+
Return the database's type, 1 to 10 respectively for PX1 to PX11. Please visit https://www.ip2location.com/databases/ip2proxy for details.
19+
20+
:return: Returns the package version.
21+
:rtype: string
22+
```
23+
24+
```{py:function} GetModuleVersion()
25+
Return the version of module.
26+
27+
:return: Returns the module version.
28+
:rtype: string
29+
```
30+
31+
```{py:function} GetDatabaseVersion()
32+
Return the database's compilation date as a string of the form 'YYYY-MM-DD'.
33+
34+
:return: Returns the database version.
35+
:rtype: string
36+
```
37+
38+
```{py:function} GetAll(ipAddress)
39+
Retrieve geolocation information for an IP address.
40+
41+
:param String ipAddress: (Required) The IP address (IPv4 or IPv6).
42+
:return: Returns the geolocation information in array. Refer below table for the fields avaliable in the array
43+
:rtype: array
44+
45+
**RETURN FIELDS**
46+
47+
| Field Name | Description |
48+
| ---------------- | ------------------------------------------------------------ |
49+
| CountryShort | Two-character country code based on ISO 3166. |
50+
| CountryLong | Country name based on ISO 3166. |
51+
| Region | Region or state name. |
52+
| City | City name. |
53+
| Isp | Internet Service Provider or company\'s name. |
54+
| Domain | Internet domain name associated with IP address range. |
55+
| UsageType | Usage type classification of ISP or company. |
56+
| Asn | Autonomous system number (ASN). |
57+
| As | Autonomous system (AS) name. |
58+
| LastSeen | Proxy last seen in days. |
59+
| Threat | Security threat reported. |
60+
| ProxyType | Type of proxy. |
61+
| Provider | Name of VPN provider if available. |
62+
```

docs/source/conf.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
# Read https://www.sphinx-doc.org/en/master/usage/configuration.html for more options available
3+
4+
# -- Project information
5+
6+
project = 'IP2Proxy Java'
7+
copyright = '2024, IP2Location'
8+
author = 'IP2Location'
9+
10+
release = '0.1.0'
11+
version = '0.1.0'
12+
13+
# -- General configuration
14+
15+
extensions = [
16+
'sphinx.ext.duration',
17+
'sphinx.ext.doctest',
18+
'myst_parser',
19+
'sphinx_copybutton',
20+
]
21+
22+
# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html
23+
24+
myst_enable_extensions = [
25+
"colon_fence",
26+
"deflist",
27+
"fieldlist",
28+
]
29+
30+
# https://myst-parser.readthedocs.io/en/latest/configuration.html#setting-html-metadata
31+
myst_html_meta = {
32+
"description": "IP2Proxy Java Component enables user to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits.",
33+
"keywords": "IP2Proxy, Proxy, IP location, Java",
34+
"google-site-verification": "DeW6mXDyMnMt4i61ZJBNuoADPimo5266DKob7Z7d6i4",
35+
}
36+
37+
# templates_path = ['_templates']
38+
39+
# -- Options for HTML output
40+
41+
html_theme = 'sphinx_book_theme'
42+
43+
html_theme_options = {
44+
"use_edit_page_button": False,
45+
"use_source_button": False,
46+
"use_issues_button": False,
47+
"use_download_button": False,
48+
"use_sidenotes": False,
49+
}
50+
51+
# The name of an image file (relative to this directory) to place at the top
52+
# of the sidebar.
53+
html_logo = 'images/ipl-logo-square-1200.png'
54+
55+
# Favicon
56+
html_favicon = 'images/favicon.ico'
57+
58+
html_title = "IP2Proxy Java"
59+
60+
# html_baseurl = "https://ip2proxy-go.readthedocs.io/en/latest/"

docs/source/images/favicon.ico

14.7 KB
Binary file not shown.
19.8 KB
Loading

docs/source/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# IP2Proxy Java Component
2+
3+
This component 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) and residential (RES). It lookup the proxy IP address from **IP2Proxy BIN Data** file. This data file can be downloaded at
4+
5+
* Free IP2Proxy BIN Data: https://lite.ip2location.com
6+
* Commercial IP2Proxy BIN Data: https://www.ip2location.com/database/ip2proxy
7+
8+
## Table of contents
9+
```{eval-rst}
10+
.. toctree::
11+
12+
self
13+
quickstart
14+
code
15+
```

docs/source/quickstart.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Quickstart
2+
3+
## Dependencies
4+
5+
This library requires IP2Proxy BIN database to function. You may download the BIN database at
6+
7+
- IP2Proxy LITE BIN Data (Free): <https://lite.ip2location.com>
8+
- IP2Proxy Commercial BIN Data (Comprehensive):
9+
<https://www.ip2location.com>
10+
11+
## Compilation
12+
13+
```bash
14+
javac com/ip2proxy/*.java
15+
jar cf ip2proxy.jar com/ip2proxy/*.class
16+
```
17+
18+
## Sample Codes
19+
20+
### Query geolocation information from BIN database
21+
22+
You can query the geolocation information from the IP2Proxy BIN database as below:
23+
24+
```java
25+
import com.ip2proxy.*;
26+
27+
public class Main {
28+
public Main() {
29+
}
30+
31+
public static void main(String[] args) {
32+
try {
33+
IP2Proxy Proxy = new IP2Proxy();
34+
ProxyResult All;
35+
36+
int IsProxy;
37+
String ProxyType;
38+
String CountryShort;
39+
String CountryLong;
40+
String Region;
41+
String City;
42+
String ISP;
43+
String Domain;
44+
String UsageType;
45+
String ASN;
46+
String AS;
47+
String LastSeen;
48+
String Threat;
49+
String Provider;
50+
51+
String IP = "221.121.146.0";
52+
53+
if (Proxy.Open("/usr/data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN", IP2Proxy.IOModes.IP2PROXY_MEMORY_MAPPED) == 0) {
54+
System.out.println("GetModuleVersion: " + Proxy.GetModuleVersion());
55+
System.out.println("GetPackageVersion: " + Proxy.GetPackageVersion());
56+
System.out.println("GetDatabaseVersion: " + Proxy.GetDatabaseVersion());
57+
58+
// reading all available fields
59+
All = Proxy.GetAll(IP);
60+
System.out.println("Is_Proxy: " + String.valueOf(All.Is_Proxy));
61+
System.out.println("Proxy_Type: " + All.Proxy_Type);
62+
System.out.println("Country_Short: " + All.Country_Short);
63+
System.out.println("Country_Long: " + All.Country_Long);
64+
System.out.println("Region: " + All.Region);
65+
System.out.println("City: " + All.City);
66+
System.out.println("ISP: " + All.ISP);
67+
System.out.println("Domain: " + All.Domain);
68+
System.out.println("Usage_Type: " + All.Usage_Type);
69+
System.out.println("ASN: " + All.ASN);
70+
System.out.println("AS: " + All.AS);
71+
System.out.println("Last_Seen: " + All.Last_Seen);
72+
System.out.println("Threat: " + All.Threat);
73+
System.out.println("Provider: " + All.Provider);
74+
75+
// reading individual fields
76+
IsProxy = Proxy.IsProxy(IP);
77+
System.out.println("Is_Proxy: " + String.valueOf(IsProxy));
78+
79+
ProxyType = Proxy.GetProxyType(IP);
80+
System.out.println("Proxy_Type: " + ProxyType);
81+
82+
CountryShort = Proxy.GetCountryShort(IP);
83+
System.out.println("Country_Short: " + CountryShort);
84+
85+
CountryLong = Proxy.GetCountryLong(IP);
86+
System.out.println("Country_Long: " + CountryLong);
87+
88+
Region = Proxy.GetRegion(IP);
89+
System.out.println("Region: " + Region);
90+
91+
City = Proxy.GetCity(IP);
92+
System.out.println("City: " + City);
93+
94+
ISP = Proxy.GetISP(IP);
95+
System.out.println("ISP: " + ISP);
96+
97+
Domain = Proxy.GetDomain(IP);
98+
System.out.println("Domain: " + Domain);
99+
100+
UsageType = Proxy.GetUsageType(IP);
101+
System.out.println("UsageType: " + UsageType);
102+
103+
ASN = Proxy.GetASN(IP);
104+
System.out.println("ASN: " + ASN);
105+
106+
AS = Proxy.GetAS(IP);
107+
System.out.println("AS: " + AS);
108+
109+
LastSeen = Proxy.GetLastSeen(IP);
110+
System.out.println("LastSeen: " + LastSeen);
111+
112+
Threat = Proxy.GetThreat(IP);
113+
System.out.println("Threat: " + Threat);
114+
115+
Provider = Proxy.GetProvider(IP);
116+
System.out.println("Provider: " + Provider);
117+
}
118+
else {
119+
System.out.println("Error reading BIN file.");
120+
}
121+
Proxy.Close();
122+
}
123+
catch(Exception e) {
124+
System.out.println(e);
125+
}
126+
}
127+
}
128+
```

0 commit comments

Comments
 (0)