Coder Social home page Coder Social logo

mattlknight / squid-notracking-translator Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 19 KB

Rust application to translate dnsmasq based https://github.com/notracking/hosts-blocklists to squid domain acl blocklist

License: MIT License

Rust 100.00%
rust squid squid3 squid-proxy dnsmasq

squid-notracking-translator's Introduction

squid-notracking-translator

  • Rust application to translate dnsmasq based https://github.com/notracking/hosts-blocklists to squid domain acl blocklist
  • Example Use Case:
    • Clone this repo, sudo git clone https://github.com/mattlknight/squid-notracking-translator.git /opt/squid-notracking-translator
    • Clone the notracking repo, sudo git clone https://github.com/notracking/hosts-blocklists /opt/hosts-blocklists
    • Compile the squid-translator binary per below instructions
    • Symlink the stripped binary to /usr/bin/ sudo ln -s /opt/squid-notracking-translator/target/release/squid-translator /usr/bin/
    • Configure squid appropriately and update with acl config, see example in this repo
    • Edit crontab to update notracking list, translate to squid acl, and then reload squid config
localadmin@squid:~$ cat /etc/squid/squid.conf
[...]
acl notracking dstdomain "/etc/squid/notracking_blocklist.acl"
http_access deny notracking
http_access deny notracking CONNECT
[...]
localadmin@squid:~$ sudo crontab -l
50 * * * * cd /opt/hosts-blocklists/ && git pull > /opt/git_pull.log 2>&1 
55 * * * * squid-translator -d /opt/hosts-blocklists/domains.txt -s /etc/squid/notracking_blocklist.acl
0 * * * * systemctl reload squid.service
  • About squid-translator
loc target/release/squid-translator
--------------------------------------------------------------------------------
 Language             Files        Lines        Blank      Comment         Code
--------------------------------------------------------------------------------
 Rust                     1          105           12            9           84
--------------------------------------------------------------------------------
 Total                    1          105           12            9           84
--------------------------------------------------------------------------------

file target/release/squid-translator
target/release/squid-translator: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=82026bcabea94f4752c5238e8fd210f632a14e28, stripped

size target/release/squid-translator
   text    data     bss     dec     hex filename
   1875027  141224    4456 2020707  1ed563 target/release/squid-translator

ls -alh target/release/squid-translator
   [...] 2.0M Aug 21 10:59 target/release/squid-translator
  • Uses CLI arguments and provides help
localadmin@squid:~$ sudo squid-translator -h
Squid NoTracking Translator 1.0
Matthew Knight <[email protected]>
Converts https://github.com/notracking/hosts-blocklists to Squid compatible blocklist

USAGE:
    squid-translator --domain_blocklist <DOMAIN_BLOCKLIST> --squid_blocklist <SQUID_BLOCKLIST>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -d, --domain_blocklist <DOMAIN_BLOCKLIST>    Sets the filename for the dnsmasq compatible domain blocklist
    -s, --squid_blocklist <SQUID_BLOCKLIST>      Sets the filename for the translated Squid compatible domain blocklist

Building/Compiling

Requires:

  • Rust Nightly from https://rustup.rs/
  • sudo apt install build-essential for Ubuntu based platform, or equivalent

Build

  • Clone this repository
    • git clone https://github.com/mattlknight/squid-notracking-translator.git && cd squid-notracking-translator
  • Compile for release
    • cargo build --release
  • Strip the build target
    • strip target/release/squid-translator
  • Copy the compiled target to wherever
    • cp target/release/squid-translator <wherever>

squid-notracking-translator's People

Contributors

mattlknight avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.