Exemplo n.º 1
0
std::string identify_client(peer_id const& p)
{
    peer_id::const_iterator PID = p.begin();
    boost::optional<fingerprint> f;

    if (p.is_all_zeros()) return "Unknown";

    // ----------------------
    // non standard encodings
    // ----------------------

    int num_generic_mappings = sizeof(generic_mappings) / sizeof(generic_mappings[0]);

    for (int i = 0; i < num_generic_mappings; ++i)
    {
        generic_map_entry const& e = generic_mappings[i];
        if (find_string(PID + e.offset, e.id)) return e.name;
    }

    if (find_string(PID, "-BOW") && PID[7] == '-')
        return "Bits on Wheels " + std::string((char const*)PID + 4, (char const*)PID + 7);


    if (find_string(PID, "eX"))
    {
        std::string user((char const*)PID + 2, (char const*)PID + 14);
        return std::string("eXeem ('") + user.c_str() + "')";
    }

    if (std::equal(PID, PID + 13, "\0\0\0\0\0\0\0\0\0\0\0\0\x97"))
        return "Experimental 3.2.1b2";

    if (std::equal(PID, PID + 13, "\0\0\0\0\0\0\0\0\0\0\0\0\0"))
        return "Experimental 3.1";


    // look for azureus style id
    f = parse_az_style(p);
    if (f) return lookup(*f);

    // look for shadow style id
    f = parse_shadow_style(p);
    if (f) return lookup(*f);

    // look for mainline style id
    f = parse_mainline_style(p);
    if (f) return lookup(*f);


    if (std::equal(PID, PID + 12, "\0\0\0\0\0\0\0\0\0\0\0\0"))
        return "Generic";

    std::string unknown("Unknown [");
    for (peer_id::const_iterator i = p.begin(); i != p.end(); ++i)
    {
        unknown += is_print(char(*i))?*i:'.';
    }
    unknown += "]";
    return unknown;
}
	std::string identify_client_impl(peer_id const& p)
	{
		char const* PID = p.data();

		if (p.is_all_zeros()) return "Unknown";

		// ----------------------
		// non standard encodings
		// ----------------------

		for (auto const& e : generic_mappings)
		{
			if (find_string(PID + e.offset, e.id)) return e.name;
		}

		if (find_string(PID, "-BOW") && PID[7] == '-')
			return "Bits on Wheels " + std::string(PID + 4, PID + 7);

		if (find_string(PID, "eX"))
		{
			std::string user(PID + 2, 12);
			return std::string("eXeem ('") + user + "')";
		}
		bool const is_equ_zero = std::equal(PID, PID + 12, "\0\0\0\0\0\0\0\0\0\0\0\0");

		if (is_equ_zero && PID[12] == '\x97')
			return "Experimental 3.2.1b2";

		if (is_equ_zero && PID[12] == '\0')
			return "Experimental 3.1";

		// look for azureus style id
		boost::optional<fingerprint> f = parse_az_style(p);
		if (f) return lookup(*f);

		// look for shadow style id
		f = parse_shadow_style(p);
		if (f) return lookup(*f);

		// look for mainline style id
		f = parse_mainline_style(p);
		if (f) return lookup(*f);


		if (is_equ_zero)
			return "Generic";

		std::string unknown("Unknown [");
		for (unsigned char const c : p)
			unknown += is_print(char(c)) ? char(c) : '.';
		unknown += "]";
		return unknown;
	}
Exemplo n.º 3
0
boost::optional<fingerprint> client_fingerprint(peer_id const& p)
{
    // look for azureus style id
    boost::optional<fingerprint> f;
    f = parse_az_style(p);
    if (f) return f;

    // look for shadow style id
    f = parse_shadow_style(p);
    if (f) return f;

    // look for mainline style id
    f = parse_mainline_style(p);
    if (f) return f;
    return f;
}