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

import argparse
import logging
from prettytable import PrettyTable
from dns.flags import DO
from dns.resolver import query, Resolver

class RsnServer(object):
    def __init__(self, server):
        self.logger           = logging.getLogger('RsnServer')
        self.server           = server
        self.ipv4             = query(self.server, 'A')[0].address
        self.ipv6             = query(self.server, 'AAAA')[0].address
        self.resolver         = Resolver()

        self.logger.debug('initiate: {} ({}/{})'.format(self.server, self.ipv4, self.ipv6))
        self.update_sizes()

    def _update_size(self, server, dnssec):
        '''get the response size'''
        self.resolver.nameservers = [ server ]
        if dnssec:
            self.resolver.use_edns(0,DO,4096)
        else:
            self.resolver.use_edns(0,0,4096)
        answer = self.resolver.query('.', 'NS')
        size   = len(answer.response.to_wire())
        self.logger.debug('Size:{}:DNSSEC({}):{}'.format(server, dnssec, size))
        return size

    def update_sizes(self):
        self.size_ipv4        = self._update_size(self.ipv4, False)
        self.size_ipv6        = self._update_size(self.ipv6, False)
        self.size_ipv4_dnssec = self._update_size(self.ipv4, True)
        self.size_ipv6_dnssec = self._update_size(self.ipv6, True)
<commit_msg>add test scrip<commit_after>#!/usr/bin/env python

import argparse
import logging
from prettytable import PrettyTable
from dns.flags import DO
from dns.resolver import query, Resolver

class RsnServer(object):
    def __init__(self, server):
        self.logger      = logging.getLogger('RsnServer')
        self.server      = server
        self.ipv4        = query(self.server, 'A')[0].address
        self.ipv6        = query(self.server, 'AAAA')[0].address
        self.resolver    = Resolver()
        self.round_trips = 0

        self.logger.debug('initiate: {} ({}/{})'.format(self.server, self.ipv4, self.ipv6))
        self.update_sizes()

    def _update_size(self, server, dnssec):
        '''get the response size'''
        self.resolver.nameservers = [ server ]
        if dnssec:
            self.resolver.use_edns(0,DO,4096)
        else:
            self.resolver.use_edns(0,0,4096)
        answer = self.resolver.query('.', 'NS')
        size   = len(answer.response.to_wire())
        self.logger.debug('Size:{}:DNSSEC({}):{}'.format(server, dnssec, size))
        return size

    def update_sizes(self):
        self.size_ipv4        = self._update_size(self.ipv4, False)
        self.size_ipv6        = self._update_size(self.ipv6, False)
        self.size_ipv4_dnssec = self._update_size(self.ipv4, True)
        self.size_ipv6_dnssec = self._update_size(self.ipv6, True)

{'fraction_non_alphanumeric': 0.13060638679583783, 'fraction_numerical': 0.01829924650161464, 'mean_word_length': 2.485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '7165777', 'n_tokens_mistral': 927, 'n_tokens_neox': 933, 'n_words': 164}