Skip to content

Commit 433608b

Browse files
committed
Added readthedocs documentation.
1 parent 15a7cb4 commit 433608b

File tree

10 files changed

+301
-0
lines changed

10 files changed

+301
-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: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# IP2Proxy PHP API
2+
3+
## Database Class
4+
```{py:function} IP2Proxy_open(database_file_path)
5+
Load the IP2Proxy BIN database.
6+
7+
:param str database_file_path: (Required) The file path links to IP2Proxy BIN databases.
8+
```
9+
10+
```{py:function} IP2Proxy_get_package_version()
11+
Return the database's type, 1 to 10 respectively for PX1 to PX11. Please visit https://www.ip2location.com/databases/ip2proxy for details.
12+
13+
:return: Returns the package version.
14+
:rtype: string
15+
```
16+
17+
```{py:function} IP2Proxy_get_module_version()
18+
Return the version of module.
19+
20+
:return: Returns the module version.
21+
:rtype: string
22+
```
23+
24+
```{py:function} IP2Proxy_get_database_version()
25+
Return the database's compilation date as a string of the form 'YYYY-MM-DD'.
26+
27+
:return: Returns the database version.
28+
:rtype: string
29+
```
30+
31+
```{py:function} IP2Proxy_get_all(ip_address)
32+
Retrieve geolocation information for an IP address.
33+
34+
:param str ip_address: (Required) The IP address (IPv4 or IPv6).
35+
:return: Returns the geolocation information in array. Refer below table for the fields avaliable in the array
36+
:rtype: array
37+
38+
**RETURN FIELDS**
39+
40+
| Field Name | Description |
41+
| ---------------- | ------------------------------------------------------------ |
42+
| country_short | Two-character country code based on ISO 3166. |
43+
| country_long | Country name based on ISO 3166. |
44+
| region | Region or state name. |
45+
| city | City name. |
46+
| isp | Internet Service Provider or company\'s name. |
47+
| domain | Internet domain name associated with IP address range. |
48+
| usage_type | Usage type classification of ISP or company. |
49+
| asn | Autonomous system number (ASN). |
50+
| as_ | Autonomous system (AS) name. |
51+
| last_seen | Proxy last seen in days. |
52+
| threat | Security threat reported. |
53+
| is_proxy | Determine whether if an IP address was a proxy or not. |
54+
| proxy_type | Type of proxy. |
55+
| provider | Name of VPN provider if available. |
56+
```

docs/source/conf.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
# import sphinx_pdj_theme
5+
6+
# -- Project information
7+
8+
project = 'IP2Proxy C'
9+
copyright = '2023, IP2Location'
10+
author = 'IP2Location'
11+
12+
release = '0.1.0'
13+
version = '0.1.0'
14+
15+
# -- General configuration
16+
17+
extensions = [
18+
'sphinx.ext.duration',
19+
'sphinx.ext.doctest',
20+
'myst_parser',
21+
'sphinx_copybutton',
22+
]
23+
24+
# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html
25+
26+
myst_enable_extensions = [
27+
"colon_fence",
28+
"deflist",
29+
"fieldlist",
30+
]
31+
32+
# https://myst-parser.readthedocs.io/en/latest/configuration.html#setting-html-metadata
33+
myst_html_meta = {
34+
"description": "IP2Proxy C library enables user to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits.",
35+
"keywords": "IP2Proxy, Proxy, IP location, C",
36+
"google-site-verification": "DeW6mXDyMnMt4i61ZJBNuoADPimo5266DKob7Z7d6i4",
37+
}
38+
39+
# templates_path = ['_templates']
40+
41+
# -- Options for HTML output
42+
43+
html_theme = 'sphinx_book_theme'
44+
# html_theme_path = [sphinx_pdj_theme.get_html_theme_path()]
45+
46+
# PDJ theme options, see the list of available options here: https://github.com/jucacrispim/sphinx_pdj_theme/blob/master/sphinx_pdj_theme/theme.conf
47+
html_theme_options = {
48+
"use_edit_page_button": False,
49+
"use_source_button": False,
50+
"use_issues_button": False,
51+
"use_download_button": False,
52+
"use_sidenotes": False,
53+
}
54+
55+
# The name of an image file (relative to this directory) to place at the top
56+
# of the sidebar.
57+
html_logo = 'images/ipl-logo-square-1200.png'
58+
59+
# Favicon
60+
html_favicon = 'images/favicon.ico'
61+
62+
html_title = "IP2Proxy C"
63+
64+
# html_baseurl = "https://ip2proxy-c.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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# IP2Proxy C Module
2+
3+
To detect proxy servers with country, region, city, ISP and proxy type information using IP2Proxy binary database.
4+
5+
IP2Proxy database contains a list of daily-updated IP addresses which are being used as VPN anonymizer, open proxies, web proxies and Tor exits. The database includes records for IPv4 addresses.
6+
7+
You can access to the commercial databases from https://www.ip2location.com/proxy-database or use the free IP2Proxy LITE database from http://lite.ip2location.com
8+
9+
For more details, please visit:
10+
[http://www.ip2location.com/ip2proxy/developers/c](http://www.ip2location.com/ip2proxy/developers/c)
11+
12+
13+
## Table of contents
14+
```{eval-rst}
15+
.. toctree::
16+
17+
self
18+
quickstart
19+
code
20+
```

docs/source/quickstart.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
:::{note}
12+
An outdated BIN database was provided in the data folder for your testing. You are recommended to visit the above links to download the latest BIN database.
13+
:::
14+
15+
## Installation
16+
17+
This library can be compiled and installed in different platform. Please refer to different section for the respective platform.
18+
19+
### Unix/Linux
20+
```bash
21+
autoreconf -i -v --force
22+
./configure
23+
make
24+
```
25+
26+
### Windows
27+
```bash
28+
Execute "vcvarsall.bat". (This file is part of Microsoft Visual C, not ip2location code)
29+
nmake -f Makefile.win
30+
```
31+
32+
### MacOS
33+
```bash
34+
autoreconf -i -v --force
35+
export CFLAGS=-I/usr/include/malloc
36+
./configure
37+
make
38+
```
39+
40+
## Sample Codes
41+
42+
### Query geolocation information from BIN database
43+
44+
You can query the geolocation information from the IP2Proxy BIN database as below:
45+
46+
```c
47+
#include "IP2Proxy.h"
48+
49+
IP2Proxy *IP2ProxyObj = IP2Proxy_open("../data/SAMPLE.BIN");
50+
IP2ProxyRecord *record = IP2Proxy_get_all(IP2ProxyObj, "161.11.12.13");
51+
printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
52+
record->country_short,
53+
record->country_long,
54+
record->region,
55+
record->city,
56+
record->isp,
57+
record->is_proxy;
58+
record->proxy_type,
59+
record->domain,
60+
record->usage_type,
61+
record->asn,
62+
record->as_,
63+
record->last_seen,
64+
record->threat,
65+
record->provider);
66+
IP2Proxy_free_record(record);
67+
IP2Proxy_close(IP2ProxyObj);
68+
```

0 commit comments

Comments
 (0)