Changeset 233


Ignore:
Timestamp:
07/11/07 14:36:46 (13 years ago)
Author:
Eoin
Message:

GUI support for Protocol Encryption Completed.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • Halite.pnproj

    r232 r233  
    1 <Project name="Halite"><MagicFolder excludeFolders="CVS;.svn" filter="*.*" name="res" path="res\"><File path="afxres.h"></File><File path="Halite.aps"></File><File path="Halite.ico"></File><File path="Halite.rc"></File><File path="Manifest.xml"></File><File path="toolbar.bmp"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.*" name="src" path="src\"><MagicFolder excludeFolders="CVS;.svn" filter="*.*" name="advtabs" path="advtabs\"><File path="Debug.cpp"></File><File path="Debug.hpp"></File><File path="Peers.cpp"></File><File path="Peers.hpp"></File><File path="ThemeTestDialog.hpp"></File><File path="Torrent.cpp"></File><File path="Torrent.hpp"></File><File path="Tracker.cpp"></File><File path="Tracker.hpp"></File><File path="TrackerAddDialog.hpp"></File><File path="TrackerListView.cpp"></File><File path="TrackerListView.hpp"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.*" name="global" path="global\"><File path="ini.cpp"></File><File path="ini.hpp"></File><File path="ini_adapter.cpp"></File><File path="ini_adapter.hpp"></File><File path="logger.cpp"></File><File path="logger.hpp"></File><File path="string_conv.cpp"></File><File path="string_conv.hpp"></File><File path="tinyxml.cpp"></File><File path="tinyxml.hpp"></File><File path="tinyxmlerror.cpp"></File><File path="tinyxmlparser.cpp"></File><File path="unicode.hpp"></File><File path="utf8.hpp"></File><File path="wtl_app.cpp"></File><File path="wtl_app.hpp"></File></MagicFolder><File path="AdvHaliteDialog.cpp"></File><File path="AdvHaliteDialog.hpp"></File><File path="ConfigOptions.cpp"></File><File path="ConfigOptions.hpp"></File><File path="CSSFileDialog.hpp"></File><File path="DdxEx.hpp"></File><File path="DebugDialog.hpp"></File><File path="DropFileTarget.h"></File><File path="halConfig.cpp"></File><File path="halConfig.hpp"></File><File path="halEvent.cpp"></File><File path="halEvent.hpp"></File><File path="Halite.cpp"></File><File path="Halite.hpp"></File><File path="HaliteDialog.cpp"></File><File path="HaliteDialog.hpp"></File><File path="HaliteDialogBase.hpp"></File><File path="HaliteEditCtrl.hpp"></File><File path="HaliteIni.hpp"></File><File path="HaliteListManager.hpp"></File><File path="HaliteListView.cpp"></File><File path="HaliteListView.hpp"></File><File path="HaliteListViewCtrl.hpp"></File><File path="HaliteTabCtrl.hpp"></File><File path="HaliteTabPage.hpp"></File><File path="HaliteWindow.cpp"></File><File path="HaliteWindow.hpp"></File><File path="halTorrent.cpp"></File><File path="halTorrent.hpp"></File><File path="halTorrentInternal.hpp"></File><File path="halXmlRpc.cpp"></File><File path="halXmlRpc.hpp"></File><File path="NTray.cpp"></File><File path="NTray.hpp"></File><File path="ProgressDialog.hpp"></File><File path="SimpleHtml.h"></File><File path="SplashDialog.hpp"></File><File path="SSFileDialog.hpp"></File><File path="stdAfx.cpp"></File><File path="stdAfx.hpp"></File><File path="UxthemeWrapper.cpp"></File><File path="UxthemeWrapper.hpp"></File><File path="WinAPIMutex.hpp"></File></MagicFolder><File path="Jamfile.v2"></File></Project> 
     1<Project name="Halite"><MagicFolder excludeFolders="CVS;.svn" filter="*.*" name="res" path="res\"><File path="afxres.h"></File><File path="Halite.aps"></File><File path="Halite.ico"></File><File path="Halite.rc"></File><File path="Manifest.xml"></File><File path="resource.h"></File><File path="toolbar.bmp"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.*" name="src" path="src\"><MagicFolder excludeFolders="CVS;.svn" filter="*.*" name="advtabs" path="advtabs\"><File path="Debug.cpp"></File><File path="Debug.hpp"></File><File path="Peers.cpp"></File><File path="Peers.hpp"></File><File path="ThemeTestDialog.hpp"></File><File path="Torrent.cpp"></File><File path="Torrent.hpp"></File><File path="Tracker.cpp"></File><File path="Tracker.hpp"></File><File path="TrackerAddDialog.hpp"></File><File path="TrackerListView.cpp"></File><File path="TrackerListView.hpp"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.*" name="global" path="global\"><File path="ini.cpp"></File><File path="ini.hpp"></File><File path="ini_adapter.cpp"></File><File path="ini_adapter.hpp"></File><File path="logger.cpp"></File><File path="logger.hpp"></File><File path="string_conv.cpp"></File><File path="string_conv.hpp"></File><File path="tinyxml.cpp"></File><File path="tinyxml.hpp"></File><File path="tinyxmlerror.cpp"></File><File path="tinyxmlparser.cpp"></File><File path="unicode.hpp"></File><File path="utf8.hpp"></File><File path="wtl_app.cpp"></File><File path="wtl_app.hpp"></File></MagicFolder><File path="AdvHaliteDialog.cpp"></File><File path="AdvHaliteDialog.hpp"></File><File path="ConfigOptions.cpp"></File><File path="ConfigOptions.hpp"></File><File path="CSSFileDialog.hpp"></File><File path="DdxEx.hpp"></File><File path="DebugDialog.hpp"></File><File path="DropFileTarget.h"></File><File path="halConfig.cpp"></File><File path="halConfig.hpp"></File><File path="halEvent.cpp"></File><File path="halEvent.hpp"></File><File path="Halite.cpp"></File><File path="Halite.hpp"></File><File path="HaliteDialog.cpp"></File><File path="HaliteDialog.hpp"></File><File path="HaliteDialogBase.hpp"></File><File path="HaliteEditCtrl.hpp"></File><File path="HaliteIni.hpp"></File><File path="HaliteListManager.hpp"></File><File path="HaliteListView.cpp"></File><File path="HaliteListView.hpp"></File><File path="HaliteListViewCtrl.hpp"></File><File path="HaliteTabCtrl.hpp"></File><File path="HaliteTabPage.hpp"></File><File path="HaliteWindow.cpp"></File><File path="HaliteWindow.hpp"></File><File path="halTorrent.cpp"></File><File path="halTorrent.hpp"></File><File path="halTorrentInternal.hpp"></File><File path="halXmlRpc.cpp"></File><File path="halXmlRpc.hpp"></File><File path="NTray.cpp"></File><File path="NTray.hpp"></File><File path="ProgressDialog.hpp"></File><File path="SimpleHtml.h"></File><File path="SplashDialog.hpp"></File><File path="SSFileDialog.hpp"></File><File path="stdAfx.cpp"></File><File path="stdAfx.hpp"></File><File path="UxthemeWrapper.cpp"></File><File path="UxthemeWrapper.hpp"></File><File path="WinAPIMutex.hpp"></File></MagicFolder><File path="Jamfile.v2"></File></Project> 
  • res/Halite.rc

    r232 r233  
    7777FONT 8, "MS Shell Dlg", 400, 0, 0x1 
    7878BEGIN 
    79     GROUPBOX        "Security Options",IDC_STATIC,6,6,271,106 
     79    GROUPBOX        "IP Filtering",IDC_STATIC,5,7,271,29 
    8080    CONTROL         "Enable IP filtering.",IDC_BC_FILTERCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,18,102,12 
    8181    PUSHBUTTON      "Import ipfilter.dat",IDC_BC_FILTERLOAD,196,17,75,14,WS_DISABLED 
    8282    PUSHBUTTON      "Clear IP database",IDC_BC_FILTERCLEAR,115,17,75,14,WS_DISABLED 
    83          
    84     CONTROL         "Enable Protocol Encryption.",IDC_SC_ENABLE_PE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,35,104,10 
    85   
    86     GROUPBOX        "Connection Policies",IDC_STATIC,170,37,99,55 
    87     LTEXT           "Incoming",IDC_STATIC,177,46,42,9 
    88     RTEXT           "Outcoming",IDC_STATIC,220,46,42,9 
    89          
    90     CONTROL         "",IDC_SC_PE_CP_IN_FORCED,"Button",BS_AUTORADIOBUTTON|WS_GROUP,178,58,16,10 
    91     CONTROL         "",IDC_SC_PE_CP_IN_ENABLED,"Button",BS_AUTORADIOBUTTON,178,68,16,10 
    92     CONTROL         "",IDC_SC_PE_CP_IN_DISABLED,"Button",BS_AUTORADIOBUTTON,178,78,16,10 
    93     CTEXT           "Forced",IDC_STATIC,198,56,44,8 
    94     CTEXT           "Enabled",IDC_STATIC,198,67,44,8 
    95     CTEXT           "Disablied",IDC_STATIC,198,78,44,8 
    96     CONTROL         "",IDC_SC_PE_CP_OUT_FORCED,"Button",BS_AUTORADIOBUTTON|WS_GROUP,246,58,16,10,WS_EX_RIGHT 
    97     CONTROL         "",IDC_SC_PE_CP_OUT_ENABLED,"Button",BS_AUTORADIOBUTTON,246,68,16,10,WS_EX_RIGHT 
    98     CONTROL         "",IDC_SC_PE_CP_OUT_DISABLED,"Button",BS_AUTORADIOBUTTON,246,78,16,10,WS_EX_RIGHT 
    99          
    100     GROUPBOX        "Encoding Level",IDC_STATIC,31,48,127,44 
    101     CONTROL         "None",IDC_SC_PE_ENC_NONE,"Button",BS_AUTORADIOBUTTON|WS_GROUP,37,58,116,10 
    102     CONTROL         "Plaintext",IDC_SC_PE_ENC_PLAIN,"Button",BS_AUTORADIOBUTTON,37,69,116,10 
    103     CONTROL         "RC4",IDC_SC_PE_ENC_RC4,"Button",BS_AUTORADIOBUTTON,37,80,48,10 
    104     CONTROL         "Prefer RC4",IDC_SC_PE_ENC_RC4_PERFER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,90,80,63,10 
    105     LTEXT           "Need Help? See jldksfdslkfjsdlkfjklsdfjl",IDC_SC_HELP_LINK,13,98,255,8 
     83    GROUPBOX        "Protocol Encryption",IDC_STATIC,5,39,271,75 
     84    CONTROL         "Enable Protocol Encryption.",IDC_SC_ENABLE_PE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,50,104,10 
     85    GROUPBOX        "Connection Policies",IDC_STATIC,170,52,99,55 
     86    LTEXT           "Incoming",IDC_STATIC,177,61,42,9 
     87    RTEXT           "Outcoming",IDC_STATIC,220,61,42,9 
     88    CONTROL         "",IDC_SC_PE_CP_IN_FORCED,"Button",BS_AUTORADIOBUTTON | WS_GROUP,178,73,16,10 
     89    CONTROL         "",IDC_SC_PE_CP_IN_ENABLED,"Button",BS_AUTORADIOBUTTON,178,83,16,10 
     90    CONTROL         "",IDC_SC_PE_CP_IN_DISABLED,"Button",BS_AUTORADIOBUTTON,178,93,16,10 
     91    CTEXT           "Forced",IDC_STATIC,198,71,44,8 
     92    CTEXT           "Enabled",IDC_STATIC,198,82,44,8 
     93    CTEXT           "Disablied",IDC_STATIC,198,93,44,8 
     94    CONTROL         "",IDC_SC_PE_CP_OUT_FORCED,"Button",BS_AUTORADIOBUTTON | WS_GROUP,246,73,16,10,WS_EX_RIGHT 
     95    CONTROL         "",IDC_SC_PE_CP_OUT_ENABLED,"Button",BS_AUTORADIOBUTTON,246,83,16,10,WS_EX_RIGHT 
     96    CONTROL         "",IDC_SC_PE_CP_OUT_DISABLED,"Button",BS_AUTORADIOBUTTON,246,93,16,10,WS_EX_RIGHT 
     97    GROUPBOX        "Encoding Level",IDC_STATIC,12,63,151,44 
     98    CONTROL         "Plaintext",IDC_SC_PE_ENC_PLAIN,"Button",BS_AUTORADIOBUTTON | WS_GROUP,18,73,141,10 
     99    CONTROL         "RC4",IDC_SC_PE_ENC_RC4,"Button",BS_AUTORADIOBUTTON,18,84,141,10 
     100    CONTROL         "Both",IDC_SC_PE_ENC_BOTH,"Button",BS_AUTORADIOBUTTON,18,95,58,10 
     101    CONTROL         "Prefer RC4",IDC_SC_PE_ENC_RC4_PERFER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,79,95,80,10 
     102    LTEXT           "Need Help?",IDC_SC_HELP_LINK,7,138,255,8 
    106103END 
    107104 
     
    434431        HAL_TRACKER_TAB                           "Tracker" 
    435432        HAL_DEBUG_TAB                             "Logging" 
     433        HAL_INCORRECT_ENCODING_LEVEL  "An invalid encoding level, %1%, was passed as an encryption setting." 
     434        HAL_INCORRECT_CONNECT_POLICY  "An invalid connection policy, %1%, was passed as an encryption setting." 
    436435END 
    437436 
  • res/resource.h

    r232 r233  
    132132#define IDC_EDITABOUT                                   1086 
    133133#define IDC_SC_ENABLE_PE                1087 
    134 #define IDC_SC_PE_ENC_NONE              1088 
     134#define IDC_SC_PE_ENC_PLAIN             1088 
    135135#define IDC_SC_PE_ENC_RC4               1089 
    136 #define IDC_SC_PE_ENC_PLAIN             1090 
     136#define IDC_SC_PE_ENC_BOTH              1090 
    137137#define IDC_SC_PE_ENC_RC4_PERFER        1091 
    138138#define IDC_SC_PE_CP_IN_FORCED          1092 
     
    223223#define HAL_TRACKER_TAB                             40084 
    224224#define HAL_DEBUG_TAB                               40085 
     225#define HAL_INCORRECT_ENCODING_LEVEL    40086 
     226#define HAL_INCORRECT_CONNECT_POLICY    40087 
  • src/ConfigOptions.hpp

    r232 r233  
    201201        DDX_CHECK(IDC_BC_FILTERCHECK, hal::config().enableIPFilter) 
    202202        DDX_CHECK(IDC_SC_ENABLE_PE, hal::config().enablePe) 
    203         DDX_RADIO(IDC_SC_PE_ENC_NONE, hal::config().peEncLevel) 
     203        DDX_RADIO(IDC_SC_PE_ENC_PLAIN, hal::config().peEncLevel) 
    204204        DDX_CHECK(IDC_SC_PE_ENC_RC4_PERFER, hal::config().pePerferRc4) 
    205205        DDX_RADIO(IDC_SC_PE_CP_IN_FORCED, hal::config().peConInPolicy) 
     
    247247                if (result == BST_CHECKED) 
    248248                { 
    249                         ::EnableWindow(GetDlgItem(IDC_SC_PE_ENC_NONE), true); 
     249                        ::EnableWindow(GetDlgItem(IDC_SC_PE_ENC_BOTH), true); 
    250250                        ::EnableWindow(GetDlgItem(IDC_SC_PE_ENC_RC4), true); 
    251251                        ::EnableWindow(GetDlgItem(IDC_SC_PE_ENC_PLAIN), true); 
     
    260260                else 
    261261                { 
    262                         ::EnableWindow(GetDlgItem(IDC_SC_PE_ENC_NONE), false); 
     262                        ::EnableWindow(GetDlgItem(IDC_SC_PE_ENC_BOTH), false); 
    263263                        ::EnableWindow(GetDlgItem(IDC_SC_PE_ENC_RC4), false); 
    264264                        ::EnableWindow(GetDlgItem(IDC_SC_PE_ENC_PLAIN), false); 
  • src/halConfig.cpp

    r197 r233  
    3434                hal::event().post(boost::shared_ptr<hal::EventDetail>( 
    3535                                new hal::EventStdException(Event::critical, e, L"settingsThread, Load IP Filter")));  
    36  
    37 //              ::MessageBoxA(0, e.what(), "Loading IP Filter Exception", MB_ICONERROR|MB_OK); 
     36        } 
     37         
     38        try 
     39        { 
     40        if (enablePe) 
     41        { 
     42                bittorrent().ensure_pe_on(peEncLevel, peConInPolicy, peConOutPolicy, pePerferRc4); 
     43        } 
     44        else 
     45                bittorrent().ensure_pe_off(); 
     46        } 
     47        catch(const std::exception& e) 
     48        { 
     49                hal::event().post(boost::shared_ptr<hal::EventDetail>( 
     50                                new hal::EventStdException(Event::critical, e, L"settingsThread, Protocol Encryption")));  
    3851        } 
    3952         
  • src/halEvent.hpp

    r229 r233  
    8888}; 
    8989 
     90class EventGeneral : public EventDetail 
     91{ 
     92public: 
     93        EventGeneral(Event::eventLevel l, Event::codes c, std::wstring m) : 
     94                EventDetail(l, boost::posix_time::second_clock::universal_time(), c), 
     95                msg_(m) 
     96        {} 
     97         
     98        virtual std::wstring msg() 
     99        { 
     100                return (wformat(hal::app().res_wstr(code())) % msg_).str(); 
     101        } 
     102         
     103private: 
     104        std::wstring msg_; 
     105}; 
     106 
    90107class EventPeerAlert : public EventDetail 
    91108{ 
  • src/halTorrent.cpp

    r231 r233  
    369369                theSession.set_max_half_open_connections(10); 
    370370 
    371 #ifndef TORRENT_DISABLE_ENCRYPTION       
    372                 lbt::pe_settings pe_set; 
    373                  
    374                 pe_set.out_enc_policy = lbt::pe_settings::enabled; 
    375                 pe_set.out_enc_policy = lbt::pe_settings::enabled; 
    376                 pe_set.allowed_enc_level = lbt::pe_settings::both; 
    377                 pe_set.prefer_rc4 = true; 
    378                  
    379                 theSession.set_pe_settings(pe_set); 
    380 #endif 
    381                  
    382371                try 
    383372                {        
     
    635624        pimpl->ip_filter_on_ = false; 
    636625} 
     626 
     627#ifndef TORRENT_DISABLE_ENCRYPTION       
     628void BitTorrent::ensure_pe_on(int enc_level, int in_enc_policy, int out_enc_policy, bool prefer_rc4) 
     629{ 
     630        lbt::pe_settings pe; 
     631         
     632        switch (enc_level) 
     633        { 
     634                case 0: 
     635                        pe.allowed_enc_level = lbt::pe_settings::plaintext; 
     636                        break; 
     637                case 1: 
     638                        pe.allowed_enc_level = lbt::pe_settings::rc4; 
     639                        break; 
     640                case 2: 
     641                        pe.allowed_enc_level = lbt::pe_settings::both; 
     642                        break; 
     643                default: 
     644                        pe.allowed_enc_level = lbt::pe_settings::both; 
     645                         
     646                        hal::event().post(shared_ptr<hal::EventDetail>( 
     647                                new hal::EventGeneral(hal::Event::warning, hal::Event::unclassified,  
     648                                        (wformat(hal::app().res_wstr(HAL_INCORRECT_ENCODING_LEVEL)) % enc_level).str()))); 
     649        } 
     650 
     651        switch (in_enc_policy) 
     652        { 
     653                case 0: 
     654                        pe.in_enc_policy = lbt::pe_settings::forced; 
     655                        break; 
     656                case 1: 
     657                        pe.in_enc_policy = lbt::pe_settings::enabled; 
     658                        break; 
     659                case 2: 
     660                        pe.in_enc_policy = lbt::pe_settings::disabled; 
     661                        break; 
     662                default: 
     663                        pe.in_enc_policy = lbt::pe_settings::enabled; 
     664                         
     665                        hal::event().post(shared_ptr<hal::EventDetail>( 
     666                                new hal::EventGeneral(hal::Event::warning, hal::Event::unclassified,  
     667                                        (wformat(hal::app().res_wstr(HAL_INCORRECT_CONNECT_POLICY)) % in_enc_policy).str()))); 
     668        } 
     669 
     670        switch (out_enc_policy) 
     671        { 
     672                case 0: 
     673                        pe.out_enc_policy = lbt::pe_settings::forced; 
     674                        break; 
     675                case 1: 
     676                        pe.out_enc_policy = lbt::pe_settings::enabled; 
     677                        break; 
     678                case 2: 
     679                        pe.out_enc_policy = lbt::pe_settings::disabled; 
     680                        break; 
     681                default: 
     682                        pe.out_enc_policy = lbt::pe_settings::enabled; 
     683                         
     684                        hal::event().post(shared_ptr<hal::EventDetail>( 
     685                                new hal::EventGeneral(hal::Event::warning, hal::Event::unclassified,  
     686                                        (wformat(hal::app().res_wstr(HAL_INCORRECT_CONNECT_POLICY)) % in_enc_policy).str()))); 
     687        } 
     688         
     689        pe.prefer_rc4 = prefer_rc4; 
     690         
     691        pimpl->theSession.set_pe_settings(pe); 
     692} 
     693 
     694void BitTorrent::ensure_pe_off() 
     695{ 
     696        lbt::pe_settings pe; 
     697        pe.out_enc_policy = lbt::pe_settings::disabled; 
     698        pe.in_enc_policy = lbt::pe_settings::disabled; 
     699         
     700        pe.allowed_enc_level = lbt::pe_settings::both; 
     701        pe.prefer_rc4 = true; 
     702         
     703        pimpl->theSession.set_pe_settings(pe); 
     704} 
     705#endif 
    637706 
    638707void BitTorrent::ip_v4_filter_block(asio::ip::address_v4 first, asio::ip::address_v4 last) 
  • src/halTorrent.hpp

    r231 r233  
    199199        void clearIpFilter(); 
    200200         
     201        void ensure_pe_on(int enc_level, int in_enc_policy, int out_enc_policy, bool prefer_rc4); 
     202        void ensure_pe_off(); 
     203         
    201204        void setSessionLimits(int maxConn, int maxUpload); 
    202205        void setSessionSpeed(float download, float upload); 
Note: See TracChangeset for help on using the changeset viewer.