Skip to content
Tracking protection engine used in the Brave browser for list like disconnectme.
Branch: master
Clone or download
fmarier Merge pull request #37 from fmarier/issue4248-saturn.at
Unbreak saturn.at on Android by whitelisting Google Analytics
Latest commit 60b028a Apr 26, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
brave Fixes Android build Mar 8, 2019
data Unbreak saturn.at on Android by whitelisting Google Analytics Apr 26, 2019
muon Forward declare things that should be Nov 13, 2017
node_addon
scripts Compare numerical keys as integers, not strings (fixes #27) Feb 14, 2019
test Added checks on deserialization Dec 28, 2016
.gitignore Added npm-debug.log to ignore list Nov 12, 2016
FirstPartyHost.cpp Update to use hashset-cpp 2.0.2 Jun 15, 2018
FirstPartyHost.h Update to use new HashSet API Jun 15, 2018
Makefile Initial commit Jan 3, 2016
README.md Update README.md Jun 15, 2018
TPParser.cpp Update to use new HashSet API Jun 15, 2018
TPParser.h Forward declare HashSet Nov 15, 2017
TrackerData.cpp Update to use hashset-cpp 2.0.2 Jun 15, 2018
TrackerData.h Update to use new HashSet API Jun 15, 2018
binding.gyp Fix unresolved externals on npm run install on Windows Aug 13, 2018
install.js Initial commit Jan 3, 2016
main.cpp Added checks on deserialization Dec 28, 2016
package-lock.json Fix npm audit issues by replacing nsp with npm audit Oct 26, 2018
package.json Fix npm audit issues by replacing nsp with npm audit Oct 26, 2018

README.md

tracking-protection

C++ tracking protection filter parser for lists like https://github.com/disconnectme/disconnect-tracking-protection/blob/master/services.json

Setup

npm install --save tracking-protection

Installation

  1. Clone the git repository from GitHub:

     git clone https://github.com/SergeyZhukovsky/tracking-protection
    
  2. Open the working directory:

     cd tracking-protection
    
  3. Install the Node (v5+) dependencies:

     npm install
    

Sample

#include <iostream>
#include "./TPParser.h"

using std::cout;
using std::endl;

int main(int argc, char **argv) {
    CTPParser parser;
    parser.addTracker("facebook.com");
    parser.addTracker("facebook.de");

    // Prints matches
    if (parser.matchesTracker("facebook.com")) {
        cout << "matches" << endl;
    }
    else {
        cout << "does not match" << endl;
    }

    // Prints does not match
    if (parser.matchesTracker("facebook1.com")) {
        cout << "matches" << endl;
    } else {
        cout << "does not match" << endl;
    }

    // Prints does not match
    if (parser.matchesTracker("subdomain.google-analytics.com.")) {
        cout << "matches" << endl;
    } else {
        cout << "does not match" << endl;
    }

    parser.addFirstPartyHosts("facebook.com", "facebook.fr,facebook.de");
    parser.addFirstPartyHosts("google.com", "2mdn.net,admeld.com");
    parser.addFirstPartyHosts("subdomain.google.com", "facebook.fr,facebook.de");

    // Returns combined result of third party hosts for "google.com" and for "subdomain.google.com"
    // "facebook.fr,facebook.de,2mdn.net,admeld.com"
    char* thirdPartyHosts = parser.findFirstPartyHosts("subdomain.google.com");
    if (nullptr != thirdPartyHosts) {
        cout << thirdPartyHosts << endl;
        delete []thirdPartyHosts;
    }

    unsigned int totalSize = 0;
    // Serialize data
    char* data = parser.serialize(&totalSize);

    // Deserialize data
    parser.deserialize(data);

    // Prints matches
    if (parser.matchesTracker("facebook.com")) {
        cout << "matches" << endl;
    }
    else {
        cout << "does not match" << endl;
    }
    // Prints does not match
    if (parser.matchesTracker("facebook1.com")) {
        cout << "matches" << endl;
    } else {
        cout << "does not match" << endl;
    }

    // Prints "2mdn.net,admeld.com"
    thirdPartyHosts = parser.findFirstPartyHosts("google.com");
    if (nullptr != thirdPartyHosts) {
        cout << thirdPartyHosts << endl;
    }

    if (data) {
        delete []data;
    }

    return 0;
}

Build everything in release

make

Build everything in debug

make build-debug

Running sample

make sample

Running tests

make test

Clearing build files

make clean
You can’t perform that action at this time.