~ubuntu-branches/ubuntu/natty/znc/natty-backports

« back to all changes in this revision

Viewing changes to Csocket.h

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Matthäi
  • Date: 2009-05-23 16:17:47 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090523161747-dtgbsub23o1sl7ss
Tags: 0.070-1
* New upstream release.
  - Add new pkgconfig files to znc-dev.
* Fix typo in get-orig-source target.
* Merge 0.058-2~bpo40+1 and 0.058-2~bpo40+2 changelog.
* Add recommends on the new source package znc-extra.
* Add my own copyright for the Debian packaging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
29
*
30
30
*
31
 
* $Revision: 1.205 $
 
31
* $Revision: 1.207 $
32
32
*/
33
33
 
34
34
// note to compile with win32 need to link to winsock2, using gcc its -lws2_32
109
109
#else
110
110
#       define PERROR( f )      (void)0
111
111
#endif /* __DEBUG__ */
112
 
#endif
 
112
#endif /* PERROR */
113
113
 
114
114
#ifndef _NO_CSOCKET_NS // some people may not want to use a namespace
115
115
namespace Csocket
746
746
 
747
747
        //! Returns The Peers Public Key
748
748
        CS_STRING GetPeerPubKey();
749
 
        bool RequiresClientCert();
 
749
        unsigned int GetRequireClientCertFlags();
 
750
        //! legacy, deprecated @see SetRequireClientCertFlags
750
751
        void SetRequiresClientCert( bool bRequiresCert );
 
752
        //! bitwise flags, 0 means don't require cert, SSL_VERIFY_PEER verifies peers, SSL_VERIFY_FAIL_IF_NO_PEER_CERT will cause the connection to fail if no cert 
 
753
        void SetRequireClientCertFlags( unsigned int iRequireClientCertFlags ) { m_iRequireClientCertFlags = iRequireClientCertFlags; }
751
754
 
752
755
#endif /* HAVE_LIBSSL */
753
756
 
955
958
 
956
959
        void SetSkipConnect( bool b ) { m_bSkipConnect = b; }
957
960
 
 
961
        /**
 
962
         * @brief override this call with your own DNS lookup method if you have one. By default this function is blocking
 
963
         * @param sHostname the hostname to resolve
 
964
         * @param csSockAddr the destination sock address info @see CSSockAddr
 
965
         * @return 0 on success, ETIMEDOUT if no lookup was found, EAGAIN if you should check again later for an answer
 
966
         */
 
967
        virtual int GetAddrInfo( const CS_STRING & sHostname, CSSockAddr & csSockAddr );
 
968
 
958
969
private:
959
970
        //! making private for safety
960
971
        Csock( const Csock & cCopy ) {}
963
974
        u_short         m_iport, m_iRemotePort, m_iLocalPort;
964
975
        int                     m_iReadSock, m_iWriteSock, m_itimeout, m_iConnType, m_iMethod, m_iTcount;
965
976
        bool            m_bssl, m_bIsConnected, m_bBLOCK, m_bFullsslAccept;
966
 
        bool            m_bsslEstablished, m_bEnableReadLine, m_bRequireClientCert, m_bPauseRead;
 
977
        bool            m_bsslEstablished, m_bEnableReadLine, m_bPauseRead;
967
978
        CS_STRING       m_shostname, m_sbuffer, m_sSockName, m_sPemFile, m_sCipherType, m_sParentName;
968
979
        CS_STRING       m_sSend, m_sPemPass, m_sLocalIP, m_sRemoteIP;
969
980
        ECloseType      m_eCloseType;
980
991
        SSL                             *m_ssl;
981
992
        SSL_CTX                         *m_ssl_ctx;
982
993
        SSL_METHOD                      *m_ssl_method;
 
994
        unsigned int            m_iRequireClientCertFlags;
983
995
 
984
996
        FPCertVerifyCB          m_pCerVerifyCB;
985
997
 
1108
1120
                m_iAFrequire = CSSockAddr::RAF_ANY;
1109
1121
#ifdef HAVE_LIBSSL
1110
1122
                m_sCipher = "HIGH";
1111
 
                m_bRequiresClientCert = false;
 
1123
                m_iRequireCertFlags = 0;
1112
1124
#endif /* HAVE_LIBSSL */
1113
1125
        }
1114
1126
        virtual ~CSListener() {}
1124
1136
        const CS_STRING & GetCipher() const { return( m_sCipher ); }
1125
1137
        const CS_STRING & GetPemLocation() const { return( m_sPemLocation ); }
1126
1138
        const CS_STRING & GetPemPass() const { return( m_sPemPass ); }
1127
 
        bool GetRequiresClientCert() const { return( m_bRequiresClientCert ); }
 
1139
        unsigned int GetRequireClientCertFlags() const { return( m_iRequireCertFlags ); }
1128
1140
#endif /* HAVE_LIBSSL */
1129
1141
 
1130
1142
        //! sets the port to listen on. Set to 0 to listen on a random port
1149
1161
        void SetPemLocation( const CS_STRING & s ) { m_sPemLocation = s; }
1150
1162
        //! set the pemfile pass
1151
1163
        void SetPemPass( const CS_STRING & s ) { m_sPemPass = s; }
1152
 
        //! set to true if require a client certificate
1153
 
        void SetRequiresClientCert( bool b ) { m_bRequiresClientCert = b; }
 
1164
        //! set to true if require a client certificate (deprecated @see SetRequireClientCertFlags)
 
1165
        void SetRequiresClientCert( bool b ) { m_iRequireCertFlags = ( b ? SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT : 0 ); }
 
1166
        //! bitwise flags, 0 means don't require cert, SSL_VERIFY_PEER verifies peers, SSL_VERIFY_FAIL_IF_NO_PEER_CERT will cause the connection to fail if no cert 
 
1167
        void SetRequireClientCertFlags( unsigned int iRequireCertFlags ) { m_iRequireCertFlags = iRequireCertFlags; }
1154
1168
#endif /* HAVE_LIBSSL */
1155
1169
private:
1156
1170
        u_short         m_iPort;
1162
1176
 
1163
1177
#ifdef HAVE_LIBSSL
1164
1178
        CS_STRING       m_sPemLocation, m_sPemPass, m_sCipher;
1165
 
        bool            m_bRequiresClientCert;
 
1179
        unsigned int            m_iRequireCertFlags;
1166
1180
#endif /* HAVE_LIBSSL */
1167
1181
};
1168
1182
 
1310
1324
                        pcSock->SetPemLocation( cListen.GetPemLocation() );
1311
1325
                        pcSock->SetPemPass( cListen.GetPemPass() );
1312
1326
                        pcSock->SetCipher( cListen.GetCipher() );
1313
 
                        pcSock->SetRequiresClientCert( cListen.GetRequiresClientCert() );
 
1327
                        pcSock->SetRequireClientCertFlags( cListen.GetRequireClientCertFlags() );
1314
1328
                }
1315
1329
#endif /* HAVE_LIBSSL */
1316
1330
 
2057
2071
                                                        NewpcSock->SetCipher( pcSock->GetCipher() );
2058
2072
                                                        NewpcSock->SetPemLocation( pcSock->GetPemLocation() );
2059
2073
                                                        NewpcSock->SetPemPass( pcSock->GetPemPass() );
2060
 
                                                        NewpcSock->SetRequiresClientCert( pcSock->RequiresClientCert() );
 
2074
                                                        NewpcSock->SetRequireClientCertFlags( pcSock->GetRequireClientCertFlags() );
2061
2075
                                                        bAddSock = NewpcSock->AcceptSSL();
2062
2076
                                                }
2063
2077