2017 © Pedro Peláez
 

project mikrotik-hosts-parser

Application for generating ADBlock script for MikroTik routers, based on Lumen framework

image

tarampampam/mikrotik-hosts-parser

Application for generating ADBlock script for MikroTik routers, based on Lumen framework

  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 20 Forks
  • 0 Open issues
  • 9 Versions
  • 13 % Grown

The README.md

Logo , (*1)

MikroTik hosts parser

Release version Build Status ![Coverage][badge_coverage] ![Image size][badge_size_latest] License, (*2)

This application provides HTTP server, that can generate script for RouterOS-based routers for blocking "AD" hosts using 3rd party host-lists (available by HTTP):, (*3)

## Limit: 5000
## Cache lifetime: 30m0s
## Format: routeros
## Redirect to: 127.0.0.1
## Sources list:
##  - <https://adaway.org/hosts.txt>
##  - <https://www.malwaredomainlist.com/hostslist/hosts.txt>
## Excluded hosts:
##  - broadcasthost
##  - ip6-allhosts
##  - ip6-allnodes
##  - ip6-allrouters
## Cache HIT for <https://adaway.org/hosts.txt> (expires after 25m55s)
## Cache miss for <https://www.malwaredomainlist.com/hostslist/hosts.txt>

/ip dns static
add address=127.0.0.1 comment="ADBlock" disabled=no name="1-1ads.com"
add address=127.0.0.1 comment="ADBlock" disabled=no name="101com.com"
add address=127.0.0.1 comment="ADBlock" disabled=no name="101order.com"
add address=127.0.0.1 comment="ADBlock" disabled=no name="123freeavatars.com"

# ...

Hosts file format (example):, (*4)

# Any comments
127.0.0.1   1-1ads.com
127.0.0.1   101com.com 101order.com
0.0.0.0     123freeavatars.com

All what you need is:, (*5)

  • Start current application HTTP server
  • Make an HTTP request to the script generator endpoint /script/source?sources_urls=... with all required parameters (like records limit, hosts file URLs, exclusion list and others)
  • Generated script source execute on your RouterOS-based hardware

More information can be found here., (*6)

Previous version (PHP) can be found in php-version branch., (*7)

Installing

Download latest binary file for your os/arch from releases page or use our docker image (ghcr.io). Also you may need in configuration file ./configs/config.yml and ./web directory content for web UI access., (*8)

Usage

This application supports next sub-commands:, (*9)

Sub-command Description
serve Start HTTP server
healthcheck Health checker for the HTTP server (use case - docker healthcheck) (hidden in CLI help)
version Display application version

And global flags:, (*10)

Flag Description
--verbose, -v Verbose output
--debug Debug output
--log-json Logs in JSON format

HTTP server starting

serve sub-command allows to use next flags:, (*11)

Flag Description Default value Environment variable
--listen, -l IP address to listen on 0.0.0.0 (all interfaces) LISTEN_ADDR
--port, -p TCP port number 8080 LISTEN_PORT
--resources-dir, -r Path to the directory with public assets ./web RESOURCES_DIR
--config, -c Config file path ./configs/config.yml CONFIG_PATH
--caching-engine Caching engine (memory or redis) memory CACHING_ENGINE
--cache-ttl Cached entries lifetime (examples: 50s, 1h30m) 30m CACHE_TTL
--redis-dsn Redis server DSN, required only if redis caching engine is enabled redis://127.0.0.1:6379/0 REDIS_DSN

Environment variables have higher priority then flag values., (*12)

Server starting command example:, (*13)

$ ./mikrotik-hosts-parser serve \
    --config ./configs/config.yml \
    --listen 0.0.0.0 \
    --port 8080 \
    --resources-dir ./web

This command will start HTTP server using configuration from ./configs/config.yml on TCP port 8080 and use directory ./web for serving static files. Configuration file well-documented, so, feel free to change any settings on your choice!, (*14)

Configuration file allows you to use environment variables with default values (used library)!, (*15)

After that you can navigate your browser to http://127.0.0.1:8080/ and you will see something like that:, (*16)

screenshot , (*17)

Special endpoint /script/source?sources_urls=... generates RouterOS-based script using passed http-get parameters (watch examples on index page)., (*18)

Using docker

image stats, (*19)

All supported image tags can be found here and here., (*20)

Just execute in your terminal:, (*21)

$ docker run --rm -p 8080:8080/tcp tarampampam/mikrotik-hosts-parser:X.X.X

Where X.X.X is image tag (application version)., (*22)

Demo

I can't guarantee that this links will available forever, but you can use this application by the following links:, (*23)

Testing

For application testing and building we use built-in golang testing feature and docker-ce + docker-compose as develop environment. So, just write into your terminal after repository cloning:, (*24)

$ make test

Or build the binary file:, (*25)

$ make build

Releasing

New versions publishing is very simple - just make required changes in this repository, update changelog file and "publish" new release using repo releases page., (*26)

Binary files and docker images will be build and published automatically., (*27)

New release will overwrite the latest docker image tag in both registers., (*28)

Changes log

![Release date][badge_release_date] Commits since latest release, (*29)

Changes log can be found here., (*30)

Support

![Issues][badge_issues] Issues, (*31)

If you will find any package errors, please, make an issue in current repository., (*32)

License

This is open-sourced software licensed under the MIT License., (*33)

The Versions

28/07 2018

dev-master

9999999-dev

Application for generating ADBlock script for MikroTik routers, based on Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

lumen mikrotik

24/06 2018

v2.1.2

2.1.2.0

Application for generating ADBlock script for MikroTik routers, based on Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

lumen mikrotik

06/06 2018

v2.1.1

2.1.1.0

Application for generating ADBlock script for MikroTik routers, based on Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

lumen mikrotik

26/04 2018

v2.1.0

2.1.0.0

Application for generating ADBlock script for MikroTik routers, based on Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

lumen mikrotik

26/04 2018

dev-migrate-to-the-docker

dev-migrate-to-the-docker

Application for generating ADBlock script for MikroTik routers, based on Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

lumen mikrotik

07/12 2017

v2.0.3

2.0.3.0

Application for generating ADBlock script for MikroTik routers, based on Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

lumen mikrotik

06/08 2017

v2.0.2

2.0.2.0

Application for generating ADBlock script for MikroTik routers, based on Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

lumen mikrotik

01/08 2017

v1.0.1

1.0.1.0

Application for generating ADBlock script for MikroTik routers, based on Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

lumen mikrotik

01/08 2017

v1.0.0

1.0.0.0

Application for generating ADBlock script for MikroTik routers, based on Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

lumen mikrotik