Skip to content

Latest commit

 

History

History
261 lines (228 loc) · 14.3 KB

README.en.md

File metadata and controls

261 lines (228 loc) · 14.3 KB

IP Address Collection and Management Service

This service is designed for collecting and updating IP addresses (IPv4 and IPv6) and their CIDR zones for specified domains. It is implemented as a web server using asynchronous PHP 8.1+ with the AMPHP library and integrates with Linux utilities like whois and ipcalc. The service provides interfaces for retrieving lists of domains, IPv4 addresses, IPv6 addresses, as well as CIDRv4 and CIDRv6 zones in various formats, including plain text, JSON, and scripts for adding to "Address List" on Mikrotik routers (RouterOS), Keenetic KVAS\BAT, SwitchyOmega, Amnezia and more.

Demo URL: https://iplist.opencck.org

iplist

Key Features

  • Collection and automatic update of IP addresses and CIDR zones for domains.
  • Support for outputting data in various formats (JSON, lst, MikroTik, OpenWRT, ipset, etc.).
  • Integration with external data sources (support for importing initial data from external URLs).
  • Easy deployment using Docker Compose.
  • Configuration through JSON files for domain management.

Technologies Used

  • PHP 8.1+ (amphp, revolt)
  • whois, ipcalc (Linux utilities)

Formats of Output

format description
json JSON format
text Newline-separated
comma Comma-separated
mikrotik MikroTik Script
switchy SwitchyOmega RuleList
nfset Dnsmasq nfset
ipset Dnsmasq ipset
clashx ClashX
kvas Keenetic KVAS
bat Keenetic Routes .bat
amnezia Amnezia filter list
pac Proxy Auto-Configuration file

Configuration

Configuration files are stored in the config/<group>/<site>.json. Each JSON file represents a configuration for a specific portal, defining the domains to monitor and the sources of initial data for IP and CIDR.

{
  "domains": [
    "youtube.com",
    "www.youtube.com",
    "m.youtube.com",
    "www.m.youtube.com",
    "googlevideo.com",
    "www.googlevideo.com",
    "ytimg.com",
    "i.ytimg.com"
  ],
  "dns": ["127.0.0.11:53", "77.88.8.88:53", "8.8.8.8:53"],
  "timeout": 43200,
  "ip4": [],
  "ip6": [],
  "cidr4": [],
  "cidr6": [],
  "external": {
    "domains": ["https://raw.githubusercontent.com/nickspaargaren/no-google/master/categories/youtubeparsed"],
    "ip4": ["https://raw.githubusercontent.com/touhidurrr/iplist-youtube/main/ipv4_list.txt"],
    "ip6": ["https://raw.githubusercontent.com/touhidurrr/iplist-youtube/main/ipv6_list.txt"],
    "cidr4": ["https://raw.githubusercontent.com/touhidurrr/iplist-youtube/main/cidr4.txt"],
    "cidr6": ["https://raw.githubusercontent.com/touhidurrr/iplist-youtube/main/cidr6.txt"]
  }
}
property type description
domains string[] List of portal domains
dns string[] List of DNS servers for updating IP addresses
timeout int Time interval between domain IP address updates (seconds)
ip4 string[] Initial list of IPv4 addresses
ip6 string[] Initial list of IPv6 addresses
cidr4 string[] Initial list of CIDRv4 zones of IPv4 addresses
cidr6 string[] Initial list of CIDRv6 zones of IPv6 addresses
external object Lists of URLs to retrieve data from external sources
property type description
domains string[] List of URLs for replenishing portal domains
ip4 string[] List of URLs for replenishing ipv4 addresses
ip6 string[] List of URLs for replenishing IPv6 addresses
cidr4 string[] List of URLs for replenishing CIDRv4 zones of IPv4 addresses
cidr6 string[] List of URLs for replenishing CIDRv6 zones of IPv6 addresses

Setting Up and Running in Docker

git clone https://github.com/rekryt/iplist.git
cd iplist
cp .env.example .env

If needed, edit the .env file:

property default value description
COMPOSE_PROJECT_NAME iplist Name of the compose project
STORAGE_SAVE_INTERVAL 120 Cache save interval for whois (seconds)
SYS_DNS_RESOLVE_IP4 true Resolve IPv4 addresses
SYS_DNS_RESOLVE_IP6 true Resolve IPv6 addresses
SYS_DNS_RESOLVE_CHUNK_SIZE 10 Chunk size for retrieving DNS records
SYS_DNS_RESOLVE_DELAY 100 Delay between receiving dns records (milliseconds)
SYS_MEMORY_LIMIT 1024M Memory limit
SYS_TIMEZONE Europe/Moscow List of URLs to obtain initial CIDRv4 zones for IPv4 addresses
HTTP_HOST 0.0.0.0 IP of network interface (default is all interfaces)
HTTP_PORT 8080 Server network port (default 8080)
DEBUG true Determines the logging level

You can access the service in your browser via the HTTP protocol on port 8080:

http://0.0.0.0:8080/
http://0.0.0.0:8080/?format=json
http://0.0.0.0:8080/?format=json&site=youtube.com&data=domains
http://0.0.0.0:8080/?format=text&site=youtube.com&data=ip4
http://0.0.0.0:8080/?format=mikrotik&data=cidr4
http://0.0.0.0:8080/?format=mikrotik&site=youtube.com&data=cidr4
http://0.0.0.0:8080/?format=comma&data=cidr4
GET Parameter Description Example
format Data export format ?format=text
data Data for export ?data=cidr4
site Portal for data export ?site=youtube.com
group Group for data export ?group=youtube
exclude[ip4] Exclude IPv4 addresses ?exclude[ip4]=1.1.1.1&exclude[ip4]=2.2.2.2
exclude[ip6] Exclude IPv6 addresses ?exclude[ip6]=2a06:98c1:3121::a
exclude[cidr4] Exclude CIDRv4 zones ?exclude[cidr4]=1.1.1.0/24
exclude[cidr6] Exclude CIDRv6 zones ?exclude[cidr6]=2a06:98c1::/32
exclude[group] Exclude groups ?exclude[group]=youtube&exclude[group]=casino
exclude[site] Exclude portals ?exclude[site]=youtube.com
exclude[domain] Exclude domains ?exclude[domain]=youtube.com
wildcard Keep only wildcard domains ?wildcard=1
filesave Save as a file ?filesave=1
template Custom output format ?format=custom&template=more

SSL Setup

  • Install and configure a reverse proxy, for example, NginxProxyManager.
  • Create a Docker virtual network:
docker network create web
  • Configure it in the docker-compose.yml files of both the reverse proxy and this project:
services:
    ...
    app:
        networks:
            - web
networks:
    web:
        external: true
        name: web
  • Remove the ports property from this project's docker-compose.yml file.
  • Apply the changes:
docker compose up -d
  • You can view the container name with the command docker compose ps.
  • In the reverse proxy administration panel, configure the domain to point to iplist-app-1 on port 8080 and enable SSL.
  • NginxProxyManager will automatically renew the SSL certificate.

Manual Launch (PHP 8.1+)

apt-get install -y ntp whois dnsutils ipcalc
cp .env.example .env
composer install
php index.php

Custom Output Format

To export data according to a specified template, use format=custom and template=template, where the template can include patterns such as:

свойство описание
{group} Group name
{site} Site name
{data} Selected data
{shortmask} Subnet mask (short) (for IP and CIDR)
{mask} Subnet mask (full) (for IP and CIDR)

Examples:

Wildcard domains for Twitter DNS static add on MikroTik for forward-to=localhost:
https://iplist.opencck.org/?format=custom&data=domains&site=x.com&wildcard=1&template=%2Fip%20dns%20static%20add%20name%3D%7Bdata%7D%20type%3DFWD%20address-list%3D%7Bgroup%7D_%7Bsite%7D%20match-subdomain%3Dyes%20forward-to%3Dlocalhost

Wildcard domains in custom format:
https://iplist.opencck.org/?format=custom&data=domains&wildcard=1&template=data%3A%20%7Bdata%7D%20group%3A%20%7Bgroup%7D%20site%3A%20%7Bsite%7D

Subnet mask in custom format:
https://iplist.opencck.org/?format=custom&data=cidr4&template=data%3A%20%7Bdata%7D%20group%3A%20%7Bgroup%7D%20site%3A%20%7Bsite%7D%20shortmask%3A%20%7Bshortmask%7D%20mask%3A%20%7Bmask%7D

Setting up Mikrotik

  • In the router's admin panel (or via winbox), navigate to System -> Scripts.
  • Create a new script by clicking "Add new" and give it a name, for example iplist_v4_cidr
  • In the Source field, enter the following code (replace url with your server's address, and the protocol in mode may differ):
/tool fetch url="https://iplist.opencck.org/?format=mikrotik&data=cidr4&append=timeout%3D1d" mode=https dst-path=iplist_v4_cidr.rsc
:delay 5s
:log info "Downloaded iplist_v4_cidr.rsc succesfully";

/import file-name=iplist_v4_cidr.rsc
:delay 10s
:log info "New iplist_v4_cidr added successfully";
  • 1
  • Save the script
  • Go to System -> Scheduler
  • Create a new task with a name of your choice, for example iplist_v4_cidr
  • Set the Start time for the task (e.g., 00:05:00). For Interval, enter 1d 00:00:00.
  • In the On event field, enter the script name
iplist_v4_cidr
  • 2
  • Open the script in System -> Scripts and run it by clicking the Run Script button
  • In the Logs section, you should see the message New iplist_v4_cidr added successfully
  • 3
  • In IP -> Firewall -> Address Lists, a new lists should appear (in this example, named youtube)
  • 4

Setting up HomeProxy (sing-box)

Enable "Routing mode" in "Only proxy mainland China": 1 Connect to the router via SSH and execute the following commands:

# Rename the old update script
mv /etc/homeproxy/scripts/update_resources.sh /etc/homeproxy/scripts/update_resources.sh.origin

# Download the new script
wget https://iplist.opencck.org/scripts/homeproxy/update_resources.sh -O /etc/homeproxy/scripts/update_resources.sh

# Add execution permissions
chmod +x /etc/homeproxy/scripts/update_resources.sh

# Did you host this solution? - then uncomment the following line and replace "example.com" with your domain
# sed -i 's/iplist.opencck.org/example.com/g' /etc/homeproxy/scripts/update_resources.sh

Open the administrative panel in OpenWRT, go to the "System" - "Startup" - "Local Startup" section. Add the following lines before "exit 0" to automatically run the update script at startup, as well as at 00:05:00 and 12:05:00

sleep 15

/etc/homeproxy/scripts/update_crond.sh

echo "5 0,12 * * * /etc/homeproxy/scripts/update_crond.sh" > /etc/crontabs/root
/etc/init.d/cron enable
/etc/init.d/cron start

2

Setting up the Chrome extension - Proxy SwitchySharp

You can install it via the link 1

More about the Switchy RuleList

License

The MIT License (MIT). Please see LICENSE for more information.