From 2db8cb45f87b0406e88f6ecf6a46eb15f5238684 Mon Sep 17 00:00:00 2001 From: danieldg Date: Thu, 2 Jul 2009 18:17:26 +0000 Subject: Remove memory-wasting map in ssl_cert git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11428 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/transport.h | 84 +++++++++---------------------------------------- 1 file changed, 14 insertions(+), 70 deletions(-) (limited to 'src/modules/transport.h') diff --git a/src/modules/transport.h b/src/modules/transport.h index db2897508..f4cf3f4a5 100644 --- a/src/modules/transport.h +++ b/src/modules/transport.h @@ -17,14 +17,6 @@ #include #include -/** A generic container for certificate data - */ -typedef std::map ssl_data; - -/** A shorthand way of representing an iterator into ssl_data - */ -typedef ssl_data::iterator ssl_data_iter; - /** ssl_cert is a class which abstracts SSL certificate * and key information. * @@ -34,34 +26,21 @@ typedef ssl_data::iterator ssl_data_iter; * connected local users using Extensible::Extend() and the * key 'ssl_cert'. */ -class ssl_cert : public Extensible +class ssl_cert { - /** Always contains an empty string - */ - const std::string empty; - public: - /** The data for this certificate - */ - ssl_data data; - - /** Default constructor, initializes 'empty' - */ - ssl_cert() : empty("") - { - } + std::string dn; + std::string issuer; + std::string error; + std::string fingerprint; + bool trusted, invalid, unknownsigner, revoked; /** Get certificate distinguished name * @return Certificate DN */ const std::string& GetDN() { - ssl_data_iter ssldi = data.find("dn"); - - if (ssldi != data.end()) - return ssldi->second; - else - return empty; + return dn; } /** Get Certificate issuer @@ -69,12 +48,7 @@ class ssl_cert : public Extensible */ const std::string& GetIssuer() { - ssl_data_iter ssldi = data.find("issuer"); - - if (ssldi != data.end()) - return ssldi->second; - else - return empty; + return issuer; } /** Get error string if an error has occured @@ -83,12 +57,7 @@ class ssl_cert : public Extensible */ const std::string& GetError() { - ssl_data_iter ssldi = data.find("error"); - - if (ssldi != data.end()) - return ssldi->second; - else - return empty; + return error; } /** Get key fingerprint. @@ -96,12 +65,7 @@ class ssl_cert : public Extensible */ const std::string& GetFingerprint() { - ssl_data_iter ssldi = data.find("fingerprint"); - - if (ssldi != data.end()) - return ssldi->second; - else - return empty; + return fingerprint; } /** Get trust status @@ -110,12 +74,7 @@ class ssl_cert : public Extensible */ bool IsTrusted() { - ssl_data_iter ssldi = data.find("trusted"); - - if (ssldi != data.end()) - return (ssldi->second == "1"); - else - return false; + return trusted; } /** Get validity status @@ -124,12 +83,7 @@ class ssl_cert : public Extensible */ bool IsInvalid() { - ssl_data_iter ssldi = data.find("invalid"); - - if (ssldi != data.end()) - return (ssldi->second == "1"); - else - return false; + return invalid; } /** Get signer status @@ -138,12 +92,7 @@ class ssl_cert : public Extensible */ bool IsUnknownSigner() { - ssl_data_iter ssldi = data.find("unknownsigner"); - - if (ssldi != data.end()) - return (ssldi->second == "1"); - else - return false; + return unknownsigner; } /** Get revokation status. @@ -153,12 +102,7 @@ class ssl_cert : public Extensible */ bool IsRevoked() { - ssl_data_iter ssldi = data.find("revoked"); - - if (ssldi != data.end()) - return (ssldi->second == "1"); - else - return false; + return revoked; } }; -- cgit v1.2.3