• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[![Travis-CI Status](https://travis-ci.org/rockdaboot/libpsl.png?branch=master)](https://travis-ci.org/rockdaboot/libpsl)
2[![Coverity Scan](https://img.shields.io/coverity/scan/10227.svg)](https://scan.coverity.com/projects/rockdaboot-libpsl)
3[![Coverage Status](https://coveralls.io/repos/github/rockdaboot/libpsl/badge.svg?branch=master)](https://coveralls.io/github/rockdaboot/libpsl?branch=master)
4
5Solaris OpenCSW [![Build Status Solaris amd64](https://buildfarm.opencsw.org/buildbot/png?builder=libpsl-solaris10-amd64)](https://buildfarm.opencsw.org/buildbot/builders/libpsl-solaris10-amd64)
6[![Build Status Solaris i386](https://buildfarm.opencsw.org/buildbot/png?builder=libpsl-solaris10-i386)](https://buildfarm.opencsw.org/buildbot/builders/libpsl-solaris10-i386)
7[![Build Status Solaris Sparc](https://buildfarm.opencsw.org/buildbot/png?builder=libpsl-solaris10-sparc)](https://buildfarm.opencsw.org/buildbot/builders/libpsl-solaris10-sparc)
8[![Build Status Solaris SparcV9](https://buildfarm.opencsw.org/buildbot/png?builder=libpsl-solaris10-sparcv9)](https://buildfarm.opencsw.org/buildbot/builders/libpsl-solaris10-sparcv9)
9
10
11libpsl - C library to handle the Public Suffix List
12===================================================
13
14A *Public Suffix List* is a collection of Top Level Domains (TLDs) suffixes.
15TLDs include *Global Top Level Domains* (gTLDs) like `.com` and `.net`;
16*Country Top Level Domains* (ccTLDs) like `.de` and `.cn`;
17and *[Brand Top Level Domains](https://icannwiki.org/Brand_TLD)* like `.apple` and `.google`.
18Brand TLDs allows users to register their own top level domain that exist at the same level as ICANN's gTLDs.
19Brand TLDs are sometimes referred to as Vanity Domains.
20
21Browsers, web clients and other user agents can use a public suffix list to:
22
23- avoid privacy-leaking "supercookies"
24- avoid privacy-leaking "super domain" certificates ([see post from Jeffry Walton](https://lists.gnu.org/archive/html/bug-wget/2014-03/msg00093.html))
25- domain highlighting parts of the domain in a user interface
26- sorting domain lists by site
27
28Libpsl...
29
30- has built-in PSL data for fast access (DAWG/DAFSA reduces size from 180kB to ~32kB)
31- allows to load PSL data from files
32- checks if a given domain is a "public suffix"
33- provides immediate cookie domain verification
34- finds the longest public part of a given domain
35- finds the shortest private part of a given domain
36- works with international domains (UTF-8 and IDNA2008 Punycode)
37- is thread-safe
38- handles IDNA2008 UTS#46 (if libicu is available)
39
40Find more information about the Public Suffix List [here](https://publicsuffix.org/).
41
42Download the Public Suffix List [here](https://github.com/publicsuffix/list/blob/master/public_suffix_list.dat).
43
44The original DAFSA code is from the [Chromium Project](https://code.google.com/p/chromium/).
45
46
47API Documentation
48-----------------
49
50You find the current API documentation [here](https://rockdaboot.github.io/libpsl).
51
52
53Quick API example
54-----------------
55
56	#include <stdio.h>
57	#include <libpsl.h>
58
59	int main(int argc, char **argv)
60	{
61		const char *domain = "www.example.com";
62		const char *cookie_domain = ".com";
63		const psl_ctx_t *psl = psl_builtin();
64		int is_public, is_acceptable;
65
66		is_public = psl_is_public_suffix(psl, domain);
67		printf("%s %s a public suffix.\n", domain, is_public ? "is" : "is not");
68
69		is_acceptable = psl_is_cookie_domain_acceptable(psl, domain, cookie_domain);
70		printf("cookie domain '%s' %s acceptable for domain '%s'.\n",
71			cookie_domain, is_acceptable ? "is" : "is not", domain);
72
73		return 0;
74	}
75
76Command Line Tool
77-----------------
78
79Libpsl comes with a tool 'psl' that gives you access to most of the
80library API via command line.
81
82	$ psl --help
83
84prints the usage.
85
86Convert PSL into DAFSA
87----------------------
88
89The [DAFSA](https://en.wikipedia.org/wiki/Deterministic_acyclic_finite_state_automaton) format is a compressed
90representation of strings. Here we use it to reduce the whole PSL to about 32k in size.
91
92Generate `psl.dafsa` from `list/public_suffix_list.dat`
93
94	$ src/psl-make-dafsa --output-format=binary list/public_suffix_list.dat psl.dafsa
95
96Test the result (example)
97
98	$ tools/psl --load-psl-file psl.dafsa aeroclub.aero
99
100License
101-------
102
103Libpsl is made available under the terms of the MIT license.<br>
104See the LICENSE file that accompanies this distribution for the full text of the license.
105
106src/psl-make-dafsa and src/lookup_string_in_fixed_set.c are licensed under the term written in
107src/LICENSE.chromium.
108
109Building from git
110-----------------
111
112You should have python2.7+ installed.
113
114Download project and prepare sources with
115
116		git clone https://github.com/rockdaboot/libpsl
117		./autogen.sh
118		./configure
119		make
120		make check
121
122If you prefer a `meson` build
123
124		meson builddir
125		ninja -C builddir
126		ninja -C builddir test
127
128There is also an unofficial MSVC nmake build configuration in `msvc/`.   Please
129see README.MSVC.md on building libpsl with Visual Studio via NMake or Meson.
130
131
132Mailing List
133------------
134
135[Mailing List Archive](https://groups.google.com/forum/#!forum/libpsl-bugs)
136
137[Mailing List](https://groups.google.com/forum/#!forum/libpsl-bugs)
138
139To join the mailing list send an email to
140
141libpsl-bugs+subscribe@googlegroups.com
142
143and follow the instructions provided by the answer mail.
144
145Or click [join](https://groups.google.com/forum/#!forum/libpsl-bugs/join).
146