<commit_before>
from synapse.crypto.event_signing import verify_signed_event_pdu
from syutil.crypto.jsonsign import verify_signed_json
from syutil.crypto.signing_key import (
    decode_verify_key_bytes, write_signing_keys
)
from syutil.base64util import decode_base64

import urllib2
import json
import sys
import dns.resolver
import pprint
import argparse
import logging

def get_targets(server_name):
    try:
        answers = dns.resolver.query("_matrix._tcp." + server_name, "SRV")
        for srv in answers:
            yield (srv.target, srv.port)
    except dns.resolver.NXDOMAIN:
        yield (server_name, 8480)

def get_server_keys(server_name, target, port):
    url = "https://%s:%i/_matrix/key/v1" % (target, port)
    keys = json.load(urllib2.urlopen(url))
    verify_keys = {}
    for key_id, key_base64 in keys["verify_keys"].items():
        verify_key = decode_verify_key_bytes(key_id, decode_base64(key_base64))
        verify_signed_json(keys, server_name, verify_key)
        verify_keys[key_id] = verify_key
    return verify_keys

def main():

    parser = argparse.ArgumentParser()<commit_msg>handle server names with embeded ports<commit_after>
from synapse.crypto.event_signing import verify_signed_event_pdu
from syutil.crypto.jsonsign import verify_signed_json
from syutil.crypto.signing_key import (
    decode_verify_key_bytes, write_signing_keys
)
from syutil.base64util import decode_base64

import urllib2
import json
import sys
import dns.resolver
import pprint
import argparse
import logging

def get_targets(server_name):
    if ":" in server_name:
        target, port = server_name.split(":")
        yield (target, int(port))
        return
    try:
        answers = dns.resolver.query("_matrix._tcp." + server_name, "SRV")
        for srv in answers:
            yield (srv.target, srv.port)
    except dns.resolver.NXDOMAIN:
        yield (server_name, 8480)

def get_server_keys(server_name, target, port):
    url = "https://%s:%i/_matrix/key/v1" % (target, port)
    keys = json.load(urllib2.urlopen(url))
    verify_keys = {}
    for key_id, key_base64 in keys["verify_keys"].items():
        verify_key = decode_verify_key_bytes(key_id, decode_base64(key_base64))
        verify_signed_json(keys, server_name, verify_key)
        verify_keys[key_id] = verify_key
    return verify_keys

def main():

    parser = argparse.ArgumentParser()
{'fraction_non_alphanumeric': 0.09334449560485558, 'fraction_numerical': 0.014231896190874843, 'mean_word_length': 3.94824016563147, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2457794', 'n_tokens_mistral': 814, 'n_tokens_neox': 795, 'n_words': 176}