From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id LCFYNHc91GM8aQAAbAwnHQ (envelope-from ) for ; Fri, 27 Jan 2023 22:09:11 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 4n1AM3c91GOBQAAAauVa8A (envelope-from ) for ; Fri, 27 Jan 2023 22:09:11 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 919AA3856F for ; Fri, 27 Jan 2023 22:09:11 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLVy4-0002c7-Ee; Fri, 27 Jan 2023 16:09:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pLVy2-0002UD-87 for guix-patches@gnu.org; Fri, 27 Jan 2023 16:09:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pLVy1-0003xm-U2 for guix-patches@gnu.org; Fri, 27 Jan 2023 16:09:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pLVy1-0007Ns-Pf for guix-patches@gnu.org; Fri, 27 Jan 2023 16:09:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60735] [PATCH v3 3/3] services: Add block-facebook-hosts-service-type. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 27 Jan 2023 21:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60735 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60735@debbugs.gnu.org Cc: Bruno Victal Received: via spool by 60735-submit@debbugs.gnu.org id=B60735.167485369828315 (code B ref 60735); Fri, 27 Jan 2023 21:09:01 +0000 Received: (at 60735) by debbugs.gnu.org; 27 Jan 2023 21:08:18 +0000 Received: from localhost ([127.0.0.1]:38732 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pLVxK-0007Mc-7e for submit@debbugs.gnu.org; Fri, 27 Jan 2023 16:08:18 -0500 Received: from smtpmciv8.myservices.hosting ([185.26.106.203]:39470) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pLVxH-0007MT-IX for 60735@debbugs.gnu.org; Fri, 27 Jan 2023 16:08:17 -0500 Received: from mail1.netim.hosting (unknown [185.26.106.172]) by smtpmciv8.myservices.hosting (Postfix) with ESMTP id CD3F620D92 for <60735@debbugs.gnu.org>; Fri, 27 Jan 2023 22:08:14 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 8932D80098; Fri, 27 Jan 2023 22:08:14 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-1.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id x7jJuLVD1rGG; Fri, 27 Jan 2023 22:08:14 +0100 (CET) Received: from guix-nuc.home.arpa (bl9-118-236.dsl.telepac.pt [85.242.118.236]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id CB00680097; Fri, 27 Jan 2023 22:08:13 +0100 (CET) From: Bruno Victal Date: Fri, 27 Jan 2023 21:06:13 +0000 Message-Id: <55ce2a77151a50d5e6e179ce53b437a3d0dc6d2b.1674853530.git.mirai@makinata.eu> X-Mailer: git-send-email 2.38.1 In-Reply-To: <23c3ca682838a1722e619148bac0aee88124d212.1674853530.git.mirai@makinata.eu> References: <23c3ca682838a1722e619148bac0aee88124d212.1674853530.git.mirai@makinata.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1674853751; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=FkUckoLC0WyzrwNsn1lzeZErraNwtBvxcfR+rQwWays=; b=HxA2735m0wW8DXiWEhwozgkfdiOZas0c7V6iP/jBHZqG0oNyEHn3VYKAOMp593BQQiF+XU oqr90jiC916wCD7KqsWB2XLjyxENbpZIDWHzdq2a2FUVPxHmVgr+5nRWgRFkR4WKbTvMAE LHryl21PXNQ9dSS0BkVxfZoh+tg9Q6KQK4EIODD3Yg8TbblcMZkHgGvQquB3DXs605K+D+ oGXa7JR7b3XW//jUStdVX/q0Qz5zRo2iJxtCMAvVPjebe6B16MbhAkqr5kS0sKPc2h9lBF fuUdb6MgA9m0roxfDdSyRiZEFy3Yx19w15y1/DqNi5JBRlQSVEum7ZxbbjDpQg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1674853751; a=rsa-sha256; cv=none; b=WvA0m6gVO74t0Yj+ZUzLn3xMwEwSMm5SM0zDVMzqauBIvHMmebJ9weVW7nZOMm+QhVM2Fc bh8hsf7Oy4PLlgR94mqpDpT+ypHA2HWCle6QMYDEw4Zaz8IF7GJAkwvVdUpihLPNo8zAPR HEdLDhX+XmquOuoP5IZ0HxA1RIUREYPGAI86W2VES40qj3E8/xZSg4z1ugCim1ceepdE2S HlNTdpTEwgILCUN4Jy1UPUZwL2bU+bbd/xJi7xYujHXhe8udW4a2Yd50UNS1/QfNi1iPkx B8PS1LndaZRTH2xV3zppHrKGY33r3hWJWciwvr/YsI/Mr6sjid9/WVDGfLt7rA== Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -2.47 X-Spam-Score: -2.47 X-Migadu-Queue-Id: 919AA3856F X-TUID: 98DwcvZ+MC22 Deprecates %facebook-host-aliases in favour of using hosts-service-type service extensions. * gnu/services/networking.scm (block-facebook-hosts-service-type): New variable. (%facebook-host-aliases): Deprecate variable. * doc/guix.texi: Document it. --- doc/guix.texi | 38 +++------------------- gnu/services/networking.scm | 64 ++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 65 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 84afadafdb..fb651f0315 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -20997,42 +20997,14 @@ Networking Services @end table @end deftp -@defvar %facebook-host-aliases -This variable contains a string for use in @file{/etc/hosts} -(@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each -line contains a entry that maps a known server name of the Facebook +@defvar block-facebook-hosts-service-type +This service type adds a list of known Facebook hosts to the +@file{/etc/hosts} file. +(@pxref{Host Names,,, libc, The GNU C Library Reference Manual}) +Each line contains a entry that maps a known server name of the Facebook on-line service---e.g., @code{www.facebook.com}---to the local host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}. -This variable is typically used as a @code{hosts-service-type} -service extension (@pxref{Service Reference, @code{hosts-service-type}}): - -@lisp -(use-modules (gnu) (gnu services) (guix) (srfi srfi-1) (ice-9 match)) -(use-service-modules networking) - -(operating-system - ;; @dots{} - - (service - (simple-service 'block-facebook-hosts hosts-service-type - (let ((host-pairs - (filter-map - (lambda (x) - (and (not (or (string-null? x) - (string-prefix? "#" x))) - (remove string-null? - (string-split - x - char-set:whitespace)))) - (string-split %facebook-host-aliases #\newline)))) - (map (match-lambda - ((addr name) - (host addr name))) - host-pairs))) - ;; @dots{} -@end lisp - This mechanism can prevent programs running locally, such as Web browsers, from accessing Facebook. @end defvar diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 89ce16f6af..dacf64c2d1 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -20,6 +20,7 @@ ;;; Copyright © 2021 Guillaume Le Vaillant ;;; Copyright © 2022, 2023 Andrew Tropin ;;; Copyright © 2023 Declan Tsien +;;; Copyright © 2023 Bruno Victal ;;; ;;; This file is part of GNU Guix. ;;; @@ -80,7 +81,9 @@ (define-module (gnu services networking) #:use-module (json) #:re-export (static-networking-service static-networking-service-type) - #:export (%facebook-host-aliases + #:export (%facebook-host-aliases ;deprecated + block-facebook-hosts-service-type + dhcp-client-service-type dhcp-client-configuration dhcp-client-configuration? @@ -235,39 +238,36 @@ (define-module (gnu services networking) ;;; ;;; Code: -(define %facebook-host-aliases +(define facebook-host-aliases ;; This is the list of known Facebook hosts to be added to /etc/hosts if you ;; are to block it. - "\ -# Block Facebook IPv4. -127.0.0.1 www.facebook.com -127.0.0.1 facebook.com -127.0.0.1 login.facebook.com -127.0.0.1 www.login.facebook.com -127.0.0.1 fbcdn.net -127.0.0.1 www.fbcdn.net -127.0.0.1 fbcdn.com -127.0.0.1 www.fbcdn.com -127.0.0.1 static.ak.fbcdn.net -127.0.0.1 static.ak.connect.facebook.com -127.0.0.1 connect.facebook.net -127.0.0.1 www.connect.facebook.net -127.0.0.1 apps.facebook.com - -# Block Facebook IPv6. -fe80::1%lo0 facebook.com -fe80::1%lo0 login.facebook.com -fe80::1%lo0 www.login.facebook.com -fe80::1%lo0 fbcdn.net -fe80::1%lo0 www.fbcdn.net -fe80::1%lo0 fbcdn.com -fe80::1%lo0 www.fbcdn.com -fe80::1%lo0 static.ak.fbcdn.net -fe80::1%lo0 static.ak.connect.facebook.com -fe80::1%lo0 connect.facebook.net -fe80::1%lo0 www.connect.facebook.net -fe80::1%lo0 apps.facebook.com\n") - + (let ((domains '("facebook.com" "www.facebook.com" + "login.facebook.com" "www.login.facebook.com" + "fbcdn.net" "www.fbcdn.net" "fbcdn.com" "www.fbcdn.com" + "static.ak.fbcdn.net" "static.ak.connect.facebook.com" + "connect.facebook.net" "www.connect.facebook.net" + "apps.facebook.com"))) + (append-map (lambda (name) + (map (lambda (addr) + (host addr name)) + (list "127.0.0.1" "::1"))) domains))) + +(define-deprecated %facebook-host-aliases + block-facebook-hosts-service-type + (string-join + (map (lambda (x) + (string-append (host-address x) "\t" + (host-canonical-name x) "\n")) + facebook-host-aliases))) + +(define block-facebook-hosts-service-type + (service-type + (name 'block-facebook-hosts) + (extensions + (list (service-extension hosts-service-type + (const facebook-host-aliases)))) + (default-value #f) + (description "Add a list of known Facebook hosts to @file{/etc/hosts}"))) (define-record-type* dhcp-client-configuration make-dhcp-client-configuration -- 2.38.1