mikrotik-hosts-parser

module
v1.0.2-0...-4498715 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2021 License: MIT

README

Logo

MikroTik hosts parser

Release version Build Status Coverage Go Report Docker Build License

This application provides HTTP server, that can generate script for RouterOS-based routers for blocking "AD" hosts.

More information can be found here.

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

Usage

// TODO redis server can be used from redis.io

For local application starting using binary file, you must compile application (after repository cloning) using GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ./mikrotik-hosts-parser ./cmd/mikrotik-hosts-parser/ or make build, and then execute:

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

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

Configuration file allows you to use environment variables with default values!

After that you can navigate your browser to http://127.0.0.1:8080/ and you will see something like that:

screenshot

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

Using docker

Just execute in your terminal:

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

Where X.X.X is image tag (application version). All available docker image tags can be found here.

Demo

I can't guarantee that this links will available forever, but you can use this application on following links:

Testing

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

$ make test

Changes log

Release date Commits since latest release

Changes log can be found here.

Support

Issues Issues

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

License

This is open-sourced software licensed under the MIT License.

Directories

Path Synopsis
cmd
mikrotik-hosts-parser command
Main CLI application entrypoint.
Main CLI application entrypoint.
internal
pkg/breaker
Package breaker provides OSSignals struct for OS signals handling (with context).
Package breaker provides OSSignals struct for OS signals handling (with context).
pkg/cache
Package cache contains different byte-cache implementations.
Package cache contains different byte-cache implementations.
pkg/checkers
Package checkers contains different checkers.
Package checkers contains different checkers.
pkg/cli
Package cli contains CLI command handlers.
Package cli contains CLI command handlers.
pkg/cli/healthcheck
Package healthcheck contains CLI `healthcheck` command implementation.
Package healthcheck contains CLI `healthcheck` command implementation.
pkg/cli/serve
Package serve contains CLI `serve` command implementation.
Package serve contains CLI `serve` command implementation.
pkg/cli/version
Package version contains CLI `version` command implementation.
Package version contains CLI `version` command implementation.
pkg/config
Package config contains application configuration struct with the most useful functions.
Package config contains application configuration struct with the most useful functions.
pkg/env
Package env contains all about environment variables, that can be used by current application.
Package env contains all about environment variables, that can be used by current application.
pkg/http
Package http contains HTTP server and all required stuff for HTTP server working.
Package http contains HTTP server and all required stuff for HTTP server working.
pkg/http/fileserver
Package fileserver contains static files server implementation.
Package fileserver contains static files server implementation.
pkg/http/handlers/api/settings
Package settings contains API handler for application settings getting.
Package settings contains API handler for application settings getting.
pkg/http/handlers/api/version
Package version contains version API handler.
Package version contains version API handler.
pkg/http/handlers/generate
Package generate contains RouterOS script generation handler.
Package generate contains RouterOS script generation handler.
pkg/http/handlers/healthz
Package healthz contains healthcheck handler.
Package healthz contains healthcheck handler.
pkg/http/middlewares/logreq
Package logreq contains middleware for HTTP requests logging using "zap" package.
Package logreq contains middleware for HTTP requests logging using "zap" package.
pkg/http/middlewares/nocache
Package nocache contains middleware for HTTP response caching disabling.
Package nocache contains middleware for HTTP response caching disabling.
pkg/http/middlewares/panic
Package panic contains middleware for panics (inside HTTP handlers) logging using "zap" package.
Package panic contains middleware for panics (inside HTTP handlers) logging using "zap" package.
pkg/logger
Package logger contains functions for a working with application logging.
Package logger contains functions for a working with application logging.
pkg/version
Package version is used as a place, where application version defined.
Package version is used as a place, where application version defined.
pkg
hostsfile
Package hostsfile contains basic functions for the hosts file working.
Package hostsfile contains basic functions for the hosts file working.
mikrotik
Package mikrotik contains specific for RouterOS structs and functions.
Package mikrotik contains specific for RouterOS structs and functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL