<commit_before>#!/usr/bin/env python

template = r'''
#!/bin/bash
#
# This script is ***AUTOGENERATED***
#
# This is a script for applying and removing xt_bpf iptable rule. This
# particular rule was created to match packets that look like DNS and
# are against the following domains:
#
#     %(domains)s
#
# To apply the iptables bpf rule run:
#
#    ./%(name)s 1.1.1.1 172.16.17.32
#
# With the ip addresses of flooded name servers - destination IP of
# the packets.
#
# To clean the iptables rule:
#
#    ./%(name)s --delete
#
#
# For the record, here's the BPF assembly:
#
%(assembly)s
#

set -o noclobber
set -o errexit
set -o nounset
set -o pipefail

: ${IPTABLES:="iptables"}
: ${IPSET:="ipset"}
: ${INPUTPLACE:="4"}
: ${DEFAULTINT:=`awk 'BEGIN {n=0} $2 == "00000000" {n=1; print $1; exit} END {if (n=0) {print "eth0"}}' /proc/net/route`}

iptablesrule () {
    ${IPTABLES} \
        ${*} \
        -i ${DEFAULTINT} \
        -p udp --dport 53 \
        -m set --match-set %(name)s dst \
        -m bpf --bytecode "%(bytecode)s" \
        -j DROP
}

if [ "$*" == "--delete" ]; then

    A=`(iptablesrule -C INPUT || echo "error") 2>/dev/null`
    if [ "${A}" != "error" ]; then
        iptablesrule -D INPUT
    fi
    ${IPSET} -exist destroy %(name)s 2>/dev/null

else

    ${IPSET} -exist create %(name)s hash:ip
    while [ "$*" != "" ]; do
        ${IPSET} -exist add %(name)s "$1"
        shift
    done

    A=`(iptablesrule -C INPUT || echo "error") 2>/dev/null`
    if [ "${A}" == "error" ]; then
        iptablesrule -I INPUT ${INPUTPLACE}
    fi<commit_msg>iptables_bpf_dns.py: match on networks, not only host<commit_after>#!/usr/bin/env python

template = r'''
#!/bin/bash
#
# This script is ***AUTOGENERATED***
#
# This is a script for applying and removing xt_bpf iptable rule. This
# particular rule was created to match packets that look like DNS and
# are against the following domains:
#
#     %(domains)s
#
# To apply the iptables bpf rule run:
#
#    ./%(name)s 1.1.1.1/32 172.16.17.32/32
#
# With the ip addresses of flooded name servers - destination IP of
# the packets.
#
# To clean the iptables rule:
#
#    ./%(name)s --delete
#
#
# For the record, here's the BPF assembly:
#
%(assembly)s
#

set -o noclobber
set -o errexit
set -o nounset
set -o pipefail

: ${IPTABLES:="iptables"}
: ${IPSET:="ipset"}
: ${INPUTPLACE:="4"}
: ${DEFAULTINT:=`awk 'BEGIN {n=0} $2 == "00000000" {n=1; print $1; exit} END {if (n=0) {print "eth0"}}' /proc/net/route`}

iptablesrule () {
    ${IPTABLES} \
        ${*} \
        -i ${DEFAULTINT} \
        -p udp --dport 53 \
        -m set --match-set %(name)s dst \
        -m bpf --bytecode "%(bytecode)s" \
        -j DROP
}

if [ "$*" == "--delete" ]; then

    A=`(iptablesrule -C INPUT || echo "error") 2>/dev/null`
    if [ "${A}" != "error" ]; then
        iptablesrule -D INPUT
    fi
    ${IPSET} -exist destroy %(name)s 2>/dev/null

else

    ${IPSET} -exist create %(name)s hash:net
    while [ "$*" != "" ]; do
        ${IPSET} -exist add %(name)s "$1"
        shift
    done

    A=`(iptablesrule -C INPUT || echo "error") 2>/dev/null`
    if [ "${A}" == "error" ]; then
        iptablesrule -I INPUT ${INPUTPLACE}
    fi
{'fraction_non_alphanumeric': 0.18309859154929578, 'fraction_numerical': 0.022535211267605635, 'mean_word_length': 2.6072234762979685, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1832459', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1193, 'n_words': 361}