GithubHelp home page GithubHelp logo

vtorri / libpsl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rockdaboot/libpsl

0.0 0.0 0.0 5.06 MB

C library for the Public Suffix List

Home Page: https://rockdaboot.github.io/libpsl

License: MIT License

Shell 6.76% Python 15.54% C 52.88% Emacs Lisp 0.10% Makefile 10.39% Batchfile 0.38% M4 7.54% Roff 1.83% Meson 4.59%

libpsl's Introduction

Travis-CI Status Coverity Scan Coverage Status

Solaris OpenCSW Build Status Solaris amd64 Build Status Solaris i386 Build Status Solaris Sparc Build Status Solaris SparcV9

libpsl - C library to handle the Public Suffix List

A Public Suffix List is a collection of Top Level Domains (TLDs) suffixes. TLDs include Global Top Level Domains (gTLDs) like .com and .net; Country Top Level Domains (ccTLDs) like .de and .cn; and Brand Top Level Domains like .apple and .google. Brand TLDs allows users to register their own top level domain that exist at the same level as ICANN's gTLDs. Brand TLDs are sometimes referred to as Vanity Domains.

Browsers, web clients and other user agents can use a public suffix list to:

  • avoid privacy-leaking "supercookies"
  • avoid privacy-leaking "super domain" certificates (see post from Jeffry Walton)
  • domain highlighting parts of the domain in a user interface
  • sorting domain lists by site

Libpsl...

  • has built-in PSL data for fast access (DAWG/DAFSA reduces size from 180kB to ~32kB)
  • allows to load PSL data from files
  • checks if a given domain is a "public suffix"
  • provides immediate cookie domain verification
  • finds the longest public part of a given domain
  • finds the shortest private part of a given domain
  • works with international domains (UTF-8 and IDNA2008 Punycode)
  • is thread-safe
  • handles IDNA2008 UTS#46 (if libicu is available)

Find more information about the Public Suffix List here.

Download the Public Suffix List here.

The original DAFSA code is from the Chromium Project.

API Documentation

You find the current API documentation here.

Quick API example

#include <stdio.h>
#include <libpsl.h>

int main(int argc, char **argv)
{
	const char *domain = "www.example.com";
	const char *cookie_domain = ".com";
	const psl_ctx_t *psl = psl_builtin();
	int is_public, is_acceptable;

	is_public = psl_is_public_suffix(psl, domain);
	printf("%s %s a public suffix.\n", domain, is_public ? "is" : "is not");

	is_acceptable = psl_is_cookie_domain_acceptable(psl, domain, cookie_domain);
	printf("cookie domain '%s' %s acceptable for domain '%s'.\n",
		cookie_domain, is_acceptable ? "is" : "is not", domain);

	return 0;
}

Command Line Tool

Libpsl comes with a tool 'psl' that gives you access to most of the library API via command line.

$ psl --help

prints the usage.

Convert PSL into DAFSA

The DAFSA format is a compressed representation of strings. Here we use it to reduce the whole PSL to about 32k in size.

Generate psl.dafsa from list/public_suffix_list.dat

$ src/psl-make-dafsa --output-format=binary list/public_suffix_list.dat psl.dafsa

Test the result (example)

$ tools/psl --load-psl-file psl.dafsa aeroclub.aero

License

Libpsl is made available under the terms of the MIT license.
See the LICENSE file that accompanies this distribution for the full text of the license.

src/psl-make-dafsa and src/lookup_string_in_fixed_set.c are licensed under the term written in src/LICENSE.chromium.

Building from tarball

Choose a release from https://github.com/rockdaboot/libpsl/tags an download the tarball named libpsl-{version}.tar.*. Unpack with tar xf <filename>, cd into the libsl* directory.

Build with

./configure
make
make check

Install with

sudo make install

Building from git

You should have python2.7+ installed.

Download project with

	git clone --recursive https://github.com/rockdaboot/libpsl
	cd libpsl

Build with GNU autotools

	./autogen.sh
	./configure
	make
	make check

Build with meson

	meson builddir
	ninja -C builddir
	ninja -C builddir test

There is also an unofficial MSVC nmake build configuration in msvc/. Please see README.MSVC.md on building libpsl with Visual Studio via NMake or Meson.

Mailing List

Mailing List Archive

Mailing List

To join the mailing list send an email to

[email protected]

and follow the instructions provided by the answer mail.

Or click join.

libpsl's People

Contributors

blino avatar carlo-bramini avatar cicku avatar csaavedra avatar dago avatar dkg avatar equeim avatar fanc999-1 avatar giuseppe avatar hwti avatar jcajka avatar kloczek avatar kotnik avatar lgtm-migrator avatar liljenzin avatar mattst88 avatar nacho avatar neheb avatar nirbheek avatar noloader avatar quink-black avatar rockdaboot avatar rossburton avatar steelpangolin avatar sunpoet avatar tp-m avatar xclaesse avatar xhaakon avatar ystreet avatar zhanghai 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.