Changeset 1090


Ignore:
Timestamp:
Jan 19, 2010, 1:11:42 PM (12 years ago)
Author:
arnold
Message:

Buggy P2PManager/Worker classes - don't use at present!

Location:
trunk
Files:
2 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/KeySearcher_IControl/IControlKeySearcher.cs

    r971 r1090  
    3232        /// Initiates bruteforcing, but really starts not until all MasterControls had finished initializing.
    3333        /// </summary>
    34         /// <param name="pattern"></param>
    35         void StartBruteforcing(KeyPattern pattern);
     34        /// <param name="pattern">a valid KeyPattern to bruteforce</param>
     35        /// <param name="encryptedData">encryptedData which are necessary for encrypting and calculating a cost factor</param>
     36        /// <param name="initVector">initVector necessary in some kinds of cipher-block-mode</param>
     37        void StartBruteforcing(KeyPattern pattern, byte[] encryptedData, byte[] initVector);
    3638
    3739        void StopBruteforcing();
  • trunk/CrypPlugins/KeySearcher_IControl/KeySearcher_IControl.cs

    r980 r1090  
    4242        }
    4343
     44        //only change: mandatory = false!!!
     45        [PropertyInfo(Direction.InputData, "Encrypted Data", "Encrypted data out of an Encryption PlugIn", "", false, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, "")]
     46        public override byte[] EncryptedData
     47        {
     48            get
     49            {
     50                return base.EncryptedData;
     51            }
     52            set
     53            {
     54                base.EncryptedData = value;
     55            }
     56        }
     57
     58        //only change: mandatory = false!!!
     59        [PropertyInfo(Direction.InputData, "Initialization Vector", "Initialization vector with which the data were encrypted", "",false,false, DisplayLevel.Beginner,QuickWatchFormat.Hex,"")]
     60        public override byte[] InitVector
     61        {
     62            get
     63            {
     64                return base.InitVector;
     65            }
     66            set
     67            {
     68                base.InitVector = value;
     69            }
     70        }
     71
    4472        #region IKeySearcherControl Members
    4573
     
    72100        public event IsReadyForExecution OnAllMasterControlsInitialized;
    73101
    74         protected override void onStatusChanged(IControl sender, bool readyForExecution)
    75         {
    76             this.ReadyForExec = readyForExecution;
    77             if (readyForExecution)
     102        public override void  Execute()
     103        {
     104            if(this.ControlMaster != null)
     105            {
    78106                if (OnAllMasterControlsInitialized != null)
    79107                    OnAllMasterControlsInitialized();
     108            }
    80109        }
    81110    }
     
    84113    {
    85114        private KeySearcher_IControl keySearcher;
     115
     116        #region for bruteforcing necessary data
    86117        private KeyPattern actualKeyPattern;
     118        private byte[] encryptedData;
     119        private byte[] initVector;
     120        #endregion
     121
    87122        /// <summary>
    88123        /// workaround: Flag which will be set, when the OnAllMasterControlsInitialized
     
    120155        }
    121156
    122         public void StartBruteforcing(KeyPattern pattern)
     157        public void StartBruteforcing(KeyPattern pattern, byte[] encryptedData, byte[] initVector)
    123158        {
    124159            // if not all MasterControls are initialized, store the actual
     
    128163                tryBruteforcingBeforeMastersInitialized = true;
    129164                this.actualKeyPattern = pattern;
     165                this.encryptedData = encryptedData;
     166                this.initVector = initVector;
    130167                return;
    131168            }
    132             Bruteforcing(pattern);
     169            Bruteforcing(pattern, encryptedData, initVector);
    133170        }
    134171
     
    143180            if (this.tryBruteforcingBeforeMastersInitialized)
    144181            {
    145                 Bruteforcing(actualKeyPattern);
    146                 actualKeyPattern = null;
     182                Bruteforcing(this.actualKeyPattern, this.encryptedData, this.initVector);
     183                this.actualKeyPattern = null;
     184                this.encryptedData = null;
     185                this.initVector = null;
     186
    147187                this.tryBruteforcingBeforeMastersInitialized = false;
    148188            }
    149189        }
    150190
    151         private void Bruteforcing(KeyPattern actualKeyPattern)
     191        private void Bruteforcing(KeyPattern actualKeyPattern, byte[] encryptedData, byte[] initVector)
    152192        {
    153193            //because the KeySearcher object uses this property instead of the parameters in some internal methods... Dirty implementation...
     
    156196            this.keySearcher.Pattern.WildcardKey = actualKeyPattern.WildcardKey;
    157197
    158             this.keySearcher.BruteforcePattern(actualKeyPattern, this.keySearcher.ControlMaster, this.keySearcher.CostMaster);
     198            //New stuff because of changing the IControl data flow - Arnie 2010.01.18
     199
     200            this.keySearcher.BruteforcePattern(actualKeyPattern, encryptedData, initVector, this.keySearcher.ControlMaster, this.keySearcher.CostMaster);
    159201        }
    160202
  • trunk/CrypPlugins/PeerToPeerBase/PeerToPeerBase.csproj

    r1066 r1090  
    100100  <ItemGroup>
    101101    <Compile Include="DebugToFile.cs" />
     102    <Compile Include="DHT_CommonManagement.cs" />
    102103    <Compile Include="IP2PControl.cs" />
    103104    <Compile Include="KeySearcherResult.cs" />
  • trunk/CrypPlugins/PeerToPeerManager/P2PManager.cs

    r1068 r1090  
    3535    [Author("Christian Arnold", "arnold@cryptool.org", "Uni Duisburg-Essen", "http://www.uni-due.de")]
    3636    [PluginInfo(false, "P2P_Manager", "Creates a new Manager-Peer", "", "PeerToPeerManager/manager_medium_neutral.png", "PeerToPeerManager/manager_medium_working.png", "PeerToPeerManager/manager_medium_finished.png")]
    37     public class P2PManager : IOutput
     37    public class P2PManager : IInput
    3838    {
    3939        private P2PManagerBase p2pManager;
    4040        private P2PManagerSettings settings;
    41         // IControls
     41        // IInput
     42        private CryptoolStream decryptedData;
     43        private byte[] initVector;
     44        // IControls       
    4245        private IControlEncryption encryptionControl;
    4346        private IP2PControl p2pControl;
     
    5962
    6063        #region In and Output
     64
     65        [PropertyInfo(Direction.InputData, "Encrypted Data","Encrypted data out of an Encryption PlugIn","",true,false,DisplayLevel.Beginner,QuickWatchFormat.Hex,"")]
     66        public CryptoolStream DecryptedData
     67        {
     68            get{ return this.decryptedData; }
     69            set
     70            {
     71                if(value != this.decryptedData)
     72                {
     73                    this.decryptedData = value;
     74                }
     75            }
     76        }
     77
     78        [PropertyInfo(Direction.InputData, "Initialization Vector","Initialization vector with which the data were encrypted","",DisplayLevel.Beginner)]
     79        public byte[] InitVector
     80        {
     81            get{ return this.initVector;}
     82            set
     83            {
     84                if(value != this.initVector)
     85                    this.initVector = value;
     86            }
     87        }
     88
    6189        [PropertyInfo(Direction.ControlMaster, "Control Master", "Used for bruteforcing", "", DisplayLevel.Beginner)]
    6290        public IControlEncryption EncryptionControl
     
    90118        private void encryptionControl_onStatusChanged(IControl sender, bool readyForExecution)
    91119        {
     120            // obsolete stuff
    92121            if (readyForExecution)
    93122            {
     
    191220                    ((P2PManagerQuickWatch)QuickWatchPresentation).txtFinished.Text = "" + jobsFinished;
    192221
     222                    ((P2PManagerQuickWatch)QuickWatchPresentation).txtTotalWorker.Text = "" + (freeWorkers + busyWorkers);
    193223                    ((P2PManagerQuickWatch)QuickWatchPresentation).txtFreeWorker.Text = "" + freeWorkers;
    194224                    ((P2PManagerQuickWatch)QuickWatchPresentation).txtBusyWorker.Text = "" + busyWorkers;
     
    230260        void settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
    231261        {
    232             // storing settings for subscribers in the DHT, so they can load them there
    233             //if (e.PropertyName == "SendAliveMessageInterval")
    234             //{
    235             //    this.p2pControl.DHTstore(settings.TopicName + this.sDHTSettingsPostfix,
    236             //        System.BitConverter.GetBytes(this.settings.SendAliveMessageInterval));
    237             //}
    238             // if TaskName has changed, clear the Lists, because the Subscribers must reconfirm registering
    239262            if (e.PropertyName == "TopicName")
    240263            {
    241264                GuiLogMessage("Topic Name has changed, so all subscribers must reconfirm registering!",NotificationLevel.Warning);
    242265                // stop active publisher and tell all subscribers that topic name isn't valid anymore
    243                 this.p2pManager.Stop(PubSubMessageType.Unregister);
     266                Stop();
     267                //this.p2pManager.Stop(PubSubMessageType.Unregister);
    244268                // start publisher for the changed topic
    245                 this.p2pManager.Start(this.settings.TopicName, (long)this.settings.SendAliveMessageInterval);
     269                process(this.EncryptionControl);
     270                //this.p2pManager.Start(this.settings.TopicName, (long)this.settings.SendAliveMessageInterval);
    246271            }
    247272            if (e.PropertyName == "BtnUnregister")
    248273            {
    249                 this.p2pManager.Stop(PubSubMessageType.Unregister);
     274                Stop();
     275                //this.p2pManager.Stop(PubSubMessageType.Unregister);
    250276                GuiLogMessage("Unregister button pressed, Publisher has stopped!", NotificationLevel.Info);
    251277            }
    252278            if (e.PropertyName == "BtnRegister")
    253279            {
    254                 this.p2pManager.Start(this.settings.TopicName, (long)this.settings.SendAliveMessageInterval);
     280                this.process(this.EncryptionControl);
    255281                GuiLogMessage("Register button pressed, Publisher has been started!", NotificationLevel.Info);
    256282            }
    257283            if (e.PropertyName == "BtnSolutionFound")
    258284            {
    259                 this.p2pManager.Stop(PubSubMessageType.Solution);
     285                Stop();
     286                //this.p2pManager.Stop(PubSubMessageType.Solution);
    260287                GuiLogMessage("TEST: Emulate Solution-Found-message",NotificationLevel.Info);
    261288            }
     
    343370        public void Execute()
    344371        {
     372            if(this.InitVector != null && this.DecryptedData != null)
     373                this.process(this.EncryptionControl);
    345374        }
    346375
     
    353382                return;
    354383            }
     384            if (iControlEncryption == null)
     385            {
     386                GuiLogMessage("No Encryption Control connected with this PlugIn", NotificationLevel.Error);
     387                return;
     388            }
    355389
    356390            string pattern = iControlEncryption.getKeyPattern();
     391
    357392            GuiLogMessage("string pattern = Encrypt.GetKeyPattern() = '" + pattern + "'", NotificationLevel.Debug);
    358393            KeyPattern kp = new KeyPattern(pattern);
     
    385420            }
    386421
    387             this.p2pManager.StartManager(this.settings.TopicName, (long)this.settings.SendAliveMessageInterval, kp, this.settings.KeyPatternSize);
     422            this.p2pManager.StartManager(this.settings.TopicName, (long)this.settings.SendAliveMessageInterval, kp, this.DecryptedData, this.InitVector, this.settings.KeyPatternSize);
    388423
    389424            this.settings.MngStatusChanged(P2PManagerSettings.MngStatus.Working);
  • trunk/CrypPlugins/PeerToPeerManager/P2PManagerBase.cs

    r1068 r1090  
    1212using Cryptool.PluginBase.IO;
    1313
    14 /*bearbeitung
    15  * TODO:
    16  * - Order the results when they arrived as a message! (MessageReceived method)
    17  */
    18 
    1914namespace Cryptool.Plugins.PeerToPeer
    2015{
     
    4338
    4439        private const int MAX_IN_TOP_LIST = 10;
    45         private const string DHT_ENCRYPTED_TEXT = "EncryptedText";
    46         private const string DHT_INIT_VECTOR = "InitializationVector";
     40        //private const string DHT_ENCRYPTED_TEXT = "EncryptedText";
     41        //private const string DHT_INIT_VECTOR = "InitializationVector";
    4742
    4843        private bool managerStarted = false;
     
    7671
    7772        /// <summary>
    78         /// Queue of all left key spaces of the given Key Pattern
    79         /// </summary>
    80         private Queue<KeyPattern> leftKeyPatterns;
     73        /// When the Manager is started, this variable must be set.
     74        /// </summary>
     75        private string sTopic = String.Empty;
     76
     77        /// <summary>
     78        /// Stack of all left key spaces of the given Key Pattern
     79        /// </summary>
     80        private Stack<KeyPattern> leftKeyPatterns;
    8181        /// <summary>
    8282        /// Key = PeerId, Value = Pattern (key space of key pattern)
     
    9797            : base(p2pControl)
    9898        {
    99             this.leftKeyPatterns = new Queue<KeyPattern>();
     99            this.leftKeyPatterns = new Stack<KeyPattern>();
    100100            this.allocatedPatterns = new Dictionary<PeerId, KeyPattern>();
    101101            this.patternResults = new Dictionary<KeyPattern, LinkedList<KeySearcher.KeySearcher.ValueKey>>();
     
    209209            {
    210210                // because actual processing worker was removed, its job must be added to LeftKeyPatterns-List
    211                 this.leftKeyPatterns.Enqueue(this.allocatedPatterns[peerId]);
     211                this.leftKeyPatterns.Push(this.allocatedPatterns[peerId]);
    212212                bool removeResult = this.allocatedPatterns.Remove(peerId);
    213213                GuiLogging("REMOVED worker with ID '" + peerId + "' and enqueue its pattern to the Pattern queue (" + removeResult + " ).", NotificationLevel.Info);
     
    231231                if (iCycle <= iFreePatternAmount)
    232232                {
    233                     KeyPattern actualKeyPattern = this.leftKeyPatterns.Dequeue();
     233                    KeyPattern actualKeyPattern = this.leftKeyPatterns.Pop();
    234234                    this.allocatedPatterns.Add(subscriber, actualKeyPattern);
    235235
     
    308308        /// <param name="keyPatternSize">KeyPatternSize in hundred thousand!</param>
    309309        /// <returns></returns>
    310         public bool StartManager(string sTopic, long aliveMessageInterval, KeyPattern keyPattern, int keyPatternSize)
     310        public bool StartManager(string sTopic, long aliveMessageInterval, KeyPattern keyPattern, CryptoolStream encryptedData, byte[] initVector, int keyPatternSize)
    311311        {
    312312            this.KeyPatternPartSize = (BigInteger)(keyPatternSize * 100000);
    313             return StartManager(sTopic, aliveMessageInterval, keyPattern);
     313            return StartManager(sTopic, aliveMessageInterval, keyPattern,encryptedData,initVector);
    314314        }
    315315
     
    320320        /// <param name="aliveMessageInterval"></param>
    321321        /// <param name="keyPattern">Already initialized (!!!) key pattern</param>
     322        /// <param name="encryptedData">The OutputStream from an Encryption PlugIn</param>
     323        /// <param name="initVector">The initialization vector, which the Encryption PlugIn had used</param>
    322324        /// <returns></returns>
    323         public bool StartManager(string sTopic, long aliveMessageInterval, KeyPattern keyPattern)
    324         {
     325        public bool StartManager(string sTopic, long aliveMessageInterval, KeyPattern keyPattern, CryptoolStream encryptedData, byte[] initVector)
     326        {
     327            this.sTopic = sTopic;
     328
    325329            bool bolStartResult = base.Start(sTopic, aliveMessageInterval);
    326330
     
    338342            //}
    339343
    340             Stack<KeyPattern> keyPatternPool = keyPattern.makeKeySearcherPool(this.keyPatternPartSize);
    341             GuiLogging("Enqueue " + keyPatternPool.Count + " KeyPattern-Parts to the JobList.", NotificationLevel.Debug);
    342             int keyCount = keyPatternPool.Count;
    343             for (int j = 0; j < keyCount; j++)
    344             {
    345                 KeyPattern newPattern = keyPatternPool.Pop();
    346                 if (newPattern != null)
    347                     this.leftKeyPatterns.Enqueue(newPattern);
    348                 else
    349                     break;
    350             }
     344            leftKeyPatterns = keyPattern.makeKeySearcherPool(this.keyPatternPartSize);
     345            GuiLogging("Enqueue " + leftKeyPatterns.Count + " KeyPattern-Parts to the JobList.", NotificationLevel.Debug);
     346            //int keyCount = keyPatternPool.Count;
     347            //for (int j = 0; j < keyCount; j++)
     348            //{
     349            //    KeyPattern newPattern = keyPatternPool.Pop();
     350            //    if (newPattern != null)
     351            //        this.leftKeyPatterns.Enqueue(newPattern);
     352            //    else
     353            //        break;
     354            //}
    351355           
    352356            /* ************************************** */
    353             /* Only for debugging reasons - to delete */     
    354             StreamWriter debugWriter = DebugToFile.GetDebugStreamWriter();
    355             int i = 0;
    356             foreach (KeyPattern patternPart in this.leftKeyPatterns.ToList<KeyPattern>())
    357             {
    358                 debugWriter.WriteLine(i + "\t" + patternPart.ToString());
    359                 i++;
    360             }
    361             debugWriter.Dispose();
    362 
    363             /* Only for debugging reasons - to delete */
     357            /* BEGIN: Only for debugging reasons - to delete */     
     358            //StreamWriter debugWriter = DebugToFile.GetDebugStreamWriter();
     359            //int i = 0;
     360            //foreach (KeyPattern patternPart in this.leftKeyPatterns.ToList<KeyPattern>())
     361            //{
     362            //    debugWriter.WriteLine(i + "\t" + patternPart.ToString());
     363            //    i++;
     364            //}
     365            //debugWriter.Dispose();
     366
     367            /* END: Only for debugging reasons - to delete */
    364368            /* ************************************** */
    365            
    366             /* TODO:
    367              * - Catch Encrypted CryptoolStream and InitVector from the ICryptControl
    368              * - store them in the DHT
    369             // store decrypted stream and initialization vector to DHT
    370             CryptoolStream encryptedStream;
    371             if(encryptedStream.CanRead)
    372             {
    373                 byte[] encryptBuffer;
    374                 int i = encryptedStream.Read(encryptBuffer,0,encryptedStream.Length-1);
    375                 this.p2pControl.DHTstore(sTopic + DHT_ENCRYPTED_TEXT, );
    376             }
    377             */
     369
     370
     371            #region Storing EncryptedData and InitializationVector in DHT
     372            bool encryptedTextStored = DHT_CommonManagement.SetEncryptedData(ref this.p2pControl, sTopic, encryptedData);
     373            bool initVectorStored = DHT_CommonManagement.SetInitializationVector(ref this.p2pControl, sTopic, initVector);
     374
     375            //CryptoolStream newEncryptedData = new CryptoolStream();
     376            //newEncryptedData.OpenRead(encryptedData.FileName);
     377            //if (newEncryptedData.CanRead)
     378            //{
     379            //    // Convert CryptoolStream to an byte Array and store it in the DHT
     380            //    if (newEncryptedData.Length > Int32.MaxValue)
     381            //        throw (new Exception("Encrypted Data are too long for this PlugIn. The maximum size of Data is " + Int32.MaxValue + "!"));
     382            //    byte[] byteEncryptedData = new byte[newEncryptedData.Length];
     383            //    int k = newEncryptedData.Read(byteEncryptedData, 0, (int)newEncryptedData.Length - 1);
     384            //    encryptedTextStored = this.p2pControl.DHTstore(sTopic + DHT_ENCRYPTED_TEXT, byteEncryptedData);
     385            //}
     386            //else
     387            //{
     388            //    GuiLogging("Reading CryptoolStream wasn't possible.", NotificationLevel.Error);
     389            //    return false;
     390            //}
     391            //// Convert  to an byte Array and store Initialization Vector it in the DHT
     392            //initVectorStored = this.p2pControl.DHTstore(sTopic + DHT_INIT_VECTOR, initVector);
     393
     394            GuiLogging("DHT: Encrypted data stored: '" + encryptedTextStored + "', Initialization vector stored: '" + initVectorStored + "'", NotificationLevel.Debug);
     395
     396            #endregion
     397
    378398            this.ManagerStarted = true;
    379399
     
    386406        {
    387407            base.Stop(msgType);
     408            // Remove all Manager specific DHT entries
     409            bool deletedMngrDHT = DHT_CommonManagement.DeleteAllManagersEntries(ref this.p2pControl, this.sTopic);
     410
     411            if (deletedMngrDHT)
     412                GuiLogging("Removed all Manager specific DHT entries", NotificationLevel.Debug);
     413            else
     414                GuiLogging("WARNING: The Manager specific DHT entries weren't removed", NotificationLevel.Debug);
    388415
    389416            this.ManagerStarted = false;
  • trunk/CrypPlugins/PeerToPeerManager/P2PManagerQuickWatch.xaml

    r1071 r1090  
    55        VerticalAlignment="Stretch"
    66        Background="Azure"
    7     Height="300" Width="300">
    8    
    9     <Canvas>   
    10         <Grid Name="Grid" Width="300">
    11             <Grid.RowDefinitions>
    12                 <RowDefinition Height="*"/>
    13                 <RowDefinition Height="*"/>
    14                 <RowDefinition Height="*"/>
    15             </Grid.RowDefinitions>
    16             <Grid.ColumnDefinitions>
    17                 <ColumnDefinition Width="*"/>
    18             </Grid.ColumnDefinitions>
     7    MinHeight="150" MinWidth="100"
     8    Height="Auto" Width="Auto">
    199
    20             <Expander Grid.Row="0" Grid.Column="0" Header="Job Status Info" IsExpanded="True" FontSize="12" Background="Yellow">
    21             <Canvas Height="93">
    22                 <Grid Name="JobGrid">
     10    <Canvas Name="Canvas" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
     11    <Grid Name="Grid" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
     12        <Grid.RowDefinitions>
     13            <RowDefinition Height="Auto"/>
     14            <RowDefinition Height="Auto"/>
     15            <RowDefinition Height="Auto"/>
     16        </Grid.RowDefinitions>
     17        <Grid.ColumnDefinitions>
     18            <ColumnDefinition MinWidth="150" Width="Auto"/>
     19        </Grid.ColumnDefinitions>
     20
     21        <Expander Grid.Row="0" Grid.Column="0" Header="Job Status Info" IsExpanded="True" FontSize="10" Background="Yellow">
     22            <Grid Name="JobGrid">
     23                <Grid.RowDefinitions>
     24                    <RowDefinition/>
     25                    <RowDefinition/>
     26                    <RowDefinition/>
     27                    <RowDefinition/>
     28                </Grid.RowDefinitions>
     29                <Grid.ColumnDefinitions>
     30                    <ColumnDefinition Width="Auto"/>
     31                    <ColumnDefinition MinWidth="20" Width="Auto"/>
     32                    <ColumnDefinition Width="Auto"/>
     33                </Grid.ColumnDefinitions>
     34
     35                <Grid Grid.Row="0" Grid.Column="2" Grid.RowSpan="4">
    2336                    <Grid.RowDefinitions>
    24                         <RowDefinition/>
    25                         <RowDefinition/>
    2637                        <RowDefinition/>
    2738                        <RowDefinition/>
    2839                    </Grid.RowDefinitions>
    2940                    <Grid.ColumnDefinitions>
    30                         <ColumnDefinition Width="70"/>
    31                         <ColumnDefinition Width="50"/>
    32                         <ColumnDefinition Width="*"/>
     41                        <ColumnDefinition/>
    3342                    </Grid.ColumnDefinitions>
    3443
    35                     <Grid Grid.Row="0" Grid.Column="2" Grid.RowSpan="4">
    36                         <Grid.RowDefinitions>
    37                             <RowDefinition/>
    38                             <RowDefinition/>
    39                         </Grid.RowDefinitions>
    40                         <Grid.ColumnDefinitions>
    41                             <ColumnDefinition/>
    42                         </Grid.ColumnDefinitions>
     44                    <Label Grid.Row="0" Grid.Column="0" FontSize="10" FontWeight="Bold" VerticalContentAlignment="Bottom"
     45                           VerticalAlignment="Bottom" HorizontalContentAlignment="Center" Width="AUTO">Total Progress:</Label>
     46                    <TextBox Name="txtProgressInPercent" Grid.Row="1" Grid.Column="0" TextAlignment="Center"
     47                             IsReadOnly="True" TextWrapping="WrapWithOverflow" FontSize="10" FontWeight="Bold"
     48                             BorderThickness="0" VerticalContentAlignment="Top" HorizontalContentAlignment="Center" Background="Yellow"/>
     49                </Grid>
    4350
    44                         <Label Grid.Row="0" Grid.Column="0" FontSize="14" FontWeight="Bold" VerticalContentAlignment="Bottom"
    45                            VerticalAlignment="Bottom" HorizontalContentAlignment="Center" Width="AUTO">Total Progress:</Label>
    46                         <TextBox Name="txtProgressInPercent" Grid.Row="1" Grid.Column="0" TextAlignment="Center"
    47                              IsReadOnly="True" TextWrapping="WrapWithOverflow" FontSize="14" FontWeight="Bold"
    48                              BorderThickness="0" VerticalContentAlignment="Top" HorizontalContentAlignment="Center" Background="Yellow"/>
    49                     </Grid>
     51                <Label Grid.Row="0" Grid.Column="0" FontSize="8" FontWeight="Bold" Background="Azure" VerticalAlignment="Top" Height="23" Width="AUTO">Total:</Label>
     52                <TextBox Name="txtTotal" Grid.Row="0" Grid.Column="1" TextAlignment="Left"
     53                     IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top"
     54                     Height="23" FontSize="8" FontWeight="Bold" BorderThickness="1" />
    5055
    51                     <Label Grid.Row="0" Grid.Column="0" FontSize="10" FontWeight="Bold" Background="Azure" VerticalAlignment="Top" Height="23" Width="AUTO">Total:</Label>
    52                     <TextBox Name="txtTotal" Grid.Row="0" Grid.Column="1" TextAlignment="Left"
    53                      IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top" 
    54                      Height="23" FontSize="10" FontWeight="Bold" BorderThickness="1" />
     56                <Label Grid.Row="1" Grid.Column="0" FontSize="8" Background="Bisque"  VerticalAlignment="Top" Height="23" Width="AUTO">In Progress:</Label>
     57                <TextBox Name="txtInProgress" Grid.Row="1" Grid.Column="1" TextAlignment="Left"
     58                     IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top"
     59                     Height="23" FontSize="8" BorderThickness="1"/>
    5560
    56                     <Label Grid.Row="1" Grid.Column="0" FontSize="10" Background="Bisque"  VerticalAlignment="Top" Height="23" Width="AUTO">In Progress:</Label>
    57                     <TextBox Name="txtInProgress" Grid.Row="1" Grid.Column="1" TextAlignment="Left"
     61                <Label Grid.Row="2" Grid.Column="0" FontSize="8" Background="Azure" VerticalAlignment="Top" Height="23" Width="AUTO">Left:</Label>
     62                <TextBox Name="txtLeft" Grid.Row="2" Grid.Column="1" TextAlignment="Left"
    5863                     IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top"
    59                      Height="23" FontSize="10" BorderThickness="1"/>
     64                     Height="23" FontSize="8" BorderThickness="1"/>
    6065
    61                     <Label Grid.Row="2" Grid.Column="0" FontSize="10" Background="Azure" VerticalAlignment="Top" Height="23" Width="AUTO">Left:</Label>
    62                     <TextBox Name="txtLeft" Grid.Row="2" Grid.Column="1" TextAlignment="Left"
     66                <Label Grid.Row="3" Grid.Column="0" FontSize="8" FontWeight="Bold" Background="Bisque" VerticalAlignment="Top" Height="23" Width="AUTO">Finished:</Label>
     67                <TextBox Name="txtFinished" Grid.Row="3" Grid.Column="1" TextAlignment="Left"
    6368                     IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top"
    64                      Height="23" FontSize="10" BorderThickness="1"/>
     69                     Height="23" FontSize="8" BorderThickness="1"/>
    6570
    66                     <Label Grid.Row="3" Grid.Column="0" FontSize="10" FontWeight="Bold" Background="Bisque" VerticalAlignment="Top" Height="23" Width="AUTO">Finished:</Label>
    67                     <TextBox Name="txtFinished" Grid.Row="3" Grid.Column="1" TextAlignment="Left"
    68                      IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top"
    69                      Height="23" FontSize="10" BorderThickness="1"/>
     71            </Grid>
     72        </Expander>
    7073
    71                 </Grid>
    72             </Canvas>
    73             </Expander>
    74 
    75             <Expander Header="Global Top 10 List" IsExpanded="True" FontSize="12" Background="AliceBlue" Grid.Row="1" Grid.Column="0">
    76             <ListView Name="ListView" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" FontSize="10">
     74        <Expander Header="Global Top 10 List" IsExpanded="True" FontSize="10" Background="AliceBlue" Grid.Row="1" Grid.Column="0">
     75            <ListView Name="ListView" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" FontSize="8">
    7776                <ListView.View>
    7877                    <GridView>
     
    108107                </ListView.View>
    109108            </ListView>
    110             </Expander>
    111            
    112             <Expander Header="Worker Info" IsExpanded="False" FontSize="12" Background="LimeGreen" Grid.Row="2" Grid.Column="0">
    113                 <Grid Name="WorkerGrid">
    114                     <Grid.RowDefinitions>
    115                         <RowDefinition/>
    116                         <RowDefinition/>
    117                     </Grid.RowDefinitions>
    118                     <Grid.ColumnDefinitions>
    119                         <ColumnDefinition Width="70"/>
    120                         <ColumnDefinition Width="50"/>
    121                     </Grid.ColumnDefinitions>
     109        </Expander>
    122110
    123                     <Label Grid.Row="0" Grid.Column="0" FontSize="10" Height="23">Free:</Label>
    124                     <TextBox Name="txtFreeWorker" Grid.Row="0" Grid.Column="1" TextAlignment="Left"
     111        <Expander Header="Worker Info" IsExpanded="False" FontSize="10" Background="LimeGreen" Grid.Row="2" Grid.Column="0">
     112            <Grid Name="WorkerGrid">
     113                <Grid.RowDefinitions>
     114                    <RowDefinition/>
     115                    <RowDefinition/>
     116                    <RowDefinition/>
     117                </Grid.RowDefinitions>
     118                <Grid.ColumnDefinitions>
     119                    <ColumnDefinition Width="75"/>
     120                    <ColumnDefinition Width="50"/>
     121                </Grid.ColumnDefinitions>
     122
     123                <Label Grid.Row="0" Grid.Column="0" FontSize="8" Height="23" FontWeight="Bold">Total Amount:</Label>
     124                <TextBox Name="txtTotalWorker" Grid.Row="0" Grid.Column="1" TextAlignment="Left"
    125125                     IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top"
    126                      Height="23" FontSize="10" BorderThickness="1"/>
    127                    
    128                     <Label Grid.Row="1" Grid.Column="0" FontSize="10" Height="23">Busy:</Label>
    129                     <TextBox Name="txtBusyWorker" Grid.Row="1" Grid.Column="1" TextAlignment="Left"
     126                     Height="23" FontSize="8" BorderThickness="1" FontWeight="Bold"/>
     127
     128                <Label Grid.Row="1" Grid.Column="0" FontSize="8" Height="23" >Free:</Label>
     129                <TextBox Name="txtFreeWorker" Grid.Row="1" Grid.Column="1" TextAlignment="Left"
    130130                     IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top"
    131                      Height="23" FontSize="10" BorderThickness="1"/>
    132                 </Grid>
    133             </Expander>
    134         </Grid>
     131                     Height="23" FontSize="8" BorderThickness="1"/>
     132
     133                <Label Grid.Row="2" Grid.Column="0" FontSize="8" Height="23">Busy:</Label>
     134                <TextBox Name="txtBusyWorker" Grid.Row="2" Grid.Column="1" TextAlignment="Left"
     135                     IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top"
     136                     Height="23" FontSize="8" BorderThickness="1"/>
     137            </Grid>
     138        </Expander>
     139    </Grid>
    135140    </Canvas>
    136141</UserControl>
  • trunk/CrypPlugins/PeerToPeerManager/P2PManagerQuickWatch.xaml.cs

    r1071 r1090  
    3333        void P2PManagerQuickWatch_SizeChanged(object sender, SizeChangedEventArgs e)
    3434        {
    35             double height = this.ActualHeight - this.Grid.ActualHeight;
    36             if (height < 0)
    37             {
    38                 height = 0;
    39             }
    40             this.ListView.Height = height;
    41             this.ListView.Width = this.ActualWidth;
     35            this.Grid.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid.ActualWidth,
     36                                                       this.ActualHeight / this.Grid.ActualHeight); 
     37            //double height = this.ActualHeight - this.Grid.ActualHeight;
     38            //if (height < 0)
     39            //{
     40            //    height = 0;
     41            //}
     42            //this.ListView.Height = height;
     43            //this.ListView.Width = this.ActualWidth;
    4244
    43             double heightTransform = (this.ActualHeight - height) / this.Grid.ActualHeight;
    44             double widthTransform = this.ActualWidth / this.Grid.ActualWidth;
     45            //double heightTransform = (this.ActualHeight - height) / this.Grid.ActualHeight;
     46            //double widthTransform = this.ActualWidth / this.Grid.ActualWidth;
    4547
    46             if (widthTransform > heightTransform)
    47             {
    48                 widthTransform = heightTransform;
    49             }
     48            //if (widthTransform > heightTransform)
     49            //{
     50            //    widthTransform = heightTransform;
     51            //}
    5052
    5153
    52             this.Grid.RenderTransform = new ScaleTransform(widthTransform, heightTransform);
     54            //this.Grid.RenderTransform = new ScaleTransform(widthTransform, heightTransform);
    5355        }
    5456    }
  • trunk/CrypPlugins/PeerToPeerManager/PeerToPeerManager.csproj

    r1068 r1090  
    5858  </ItemGroup>
    5959  <ItemGroup>
    60     <Compile Include="IDistributionManager.cs" />
    6160    <Compile Include="P2PManager.cs" />
    6261    <Compile Include="P2PManagerBase.cs" />
  • trunk/CrypPlugins/PeerToPeerPublisher/P2PPublisherBase.cs

    r1068 r1090  
    2121        #region Variables
    2222
    23         private const string DHT_ALIVE_POSTFIX = "AliveMsg";
    24 
    2523        protected IP2PControl p2pControl;
    2624        protected SubscriberManagement peerManagement;
     
    7876
    7977            // before storing the publishers ID in the DHT, proof whether there already exists an entry
    80             byte[] byRead = this.p2pControl.DHTload(sTopic);
     78            PeerId byRead = DHT_CommonManagement.GetTopicsPublisherId(ref this.p2pControl, sTopic);
     79
    8180            // if byRead is not null, the DHT entry was already written
    8281            if (byRead != null)
    8382            {
    84                 PeerId peerRead = this.p2pControl.GetPeerID(byRead);
    85 
    86                 // if sRead equals sPeerId this Publisher with the same topic had written
    87                 // this entry - no problem! Otherwise abort Starting the publisher!
    88                 if (peerRead != myPeerId)
     83                // this entry? Then no problem! Otherwise abort Starting the publisher!
     84                if (byRead != myPeerId)
    8985                {
    9086                    GuiLogging("Can't store Publisher in the DHT because the Entry was already occupied.", NotificationLevel.Error);
     
    9490            /* END: CHECKING WHETHER THERE HAS ALREADY EXIST ANOTHER PUBLISHER */
    9591
    96             bool bolTopicStored = this.p2pControl.DHTstore(sTopic, myPeerId.ToByteArray());
    97             bool bolSettingsStored = this.p2pControl.DHTstore(sTopic + DHT_ALIVE_POSTFIX,
    98                 System.BitConverter.GetBytes(this.aliveMessageInterval));
     92            bool bolTopicStored = DHT_CommonManagement.SetTopicsPublisherId(ref this.p2pControl, sTopic, myPeerId);
     93            bool bolSettingsStored = DHT_CommonManagement.SetAliveMessageInterval(ref this.p2pControl, sTopic, this.aliveMessageInterval);
    9994
    10095            if (!bolTopicStored || !bolSettingsStored)
     
    140135                GuiLogging("Begin removing the information from the DHT", NotificationLevel.Debug);
    141136
    142                 bool removeTopic = this.p2pControl.DHTremove(this.topic);
    143                 bool removeSettings = this.p2pControl.DHTremove(this.topic + DHT_ALIVE_POSTFIX);
    144                 string removeInfo = String.Empty;
    145                 if (removeTopic && removeSettings)
    146                     removeInfo = "Topic and settings";
    147                 else if (removeTopic)
    148                     removeInfo = "Topic";
    149                 else if (removeSettings)
    150                     removeInfo = "Settings";
    151                 if (removeInfo != String.Empty)
    152                     GuiLogging(removeInfo + " successfully removed from DHT.", NotificationLevel.Debug);
     137                bool removeSettings = DHT_CommonManagement.DeleteAllPublishersEntries(ref this.p2pControl, this.topic);
     138
     139                if (removeSettings)
     140                    GuiLogging("Publishers/Managers ID and Alive Message Interval successfully removed from DHT.", NotificationLevel.Debug);
    153141                else
    154142                    GuiLogging("Neither Topic nor settings were removed from DHT.", NotificationLevel.Debug);
  • trunk/CrypPlugins/PeerToPeerSubscriber/P2PSubscriberBase.cs

    r1068 r1090  
    3131        #region Variables
    3232
    33         private const string DHT_ALIVE_POSTFIX = "AliveMsg";
    34 
    35         private IP2PControl p2pControl;
     33        protected IP2PControl p2pControl;
    3634        private long sendAliveMessageInterval;
    3735        private long checkPublishersAvailability;
     
    279277        private PeerId CheckPublisherAvailability()
    280278        {
    281             PeerId pid;
    282 
    283             byte[] bytePubId = this.p2pControl.DHTload(this.sTopic);
    284             if (bytePubId == null)
     279            PeerId pid = DHT_CommonManagement.GetTopicsPublisherId(ref this.p2pControl, this.sTopic);
     280
     281            if (pid == null)
    285282            {
    286283                if (timerRegisteringNotPossible == null && !this.bolStopped)
     
    294291            }
    295292
    296             byte[] byteISettings = this.p2pControl.DHTload(this.sTopic + DHT_ALIVE_POSTFIX);
    297             if (byteISettings == null)
     293            sendAliveMessageInterval = DHT_CommonManagement.GetAliveMessageInterval(ref this.p2pControl, this.sTopic);
     294
     295            if (sendAliveMessageInterval == 0)
    298296            {
    299297                GuiLogging("Can't find AliveMsg-Settings from Publisher for the Subscriber.", NotificationLevel.Error);
    300298                return null;
    301299            }
    302             sendAliveMessageInterval = System.BitConverter.ToInt32(byteISettings, 0);
    303 
    304             pid = this.p2pControl.GetPeerID(bytePubId);
     300
    305301            if (actualPublisher == null) //first time initialization
    306302            {
  • trunk/CrypPlugins/PeerToPeerWorker/P2PWorker.cs

    r1068 r1090  
    163163        }
    164164
    165         private string sOutputvalue;
    166         [PropertyInfo(Direction.OutputData, "Data from subscribed Publisher", "When you're subscribed to an alive Publisher, receive published data here", "", true, false, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
    167         public string Outputvalue
    168         {
    169             get
    170             {
    171                 return this.sOutputvalue;
    172             }
    173             set
    174             {
    175                 if (value != this.sOutputvalue)
    176                 {
    177                     this.sOutputvalue = value;
    178                     OnPropertyChanged("Outputvalue");
    179                 }
    180             }
    181         }
    182 
    183165        #endregion
    184166
     
    263245            if (this.p2pWorker == null)
    264246            {
    265                 this.p2pWorker = new P2PWorkerBase(this.P2PControl, this.KeySearcherControl);
     247                this.p2pWorker = new P2PWorkerBase(this.P2PControl, this.KeySearcherControl, this.settings.TopicName);
    266248                this.p2pWorker.OnGuiMessage += new P2PWorkerBase.GuiMessage(p2pWorker_OnGuiMessage);
    267                 this.p2pWorker.OnTextArrivedFromPublisher += new P2PWorkerBase.TextArrivedFromPublisher(p2pWorker_OnTextArrivedFromPublisher);
    268249                this.p2pWorker.OnKeyPatternReceived += new P2PWorkerBase.KeyPatternReceived(p2pWorker_OnKeyPatternReceived);
    269250                this.p2pWorker.OnFinishedBruteforcingThePattern += new P2PWorkerBase.FinishedBruteforcingThePattern(p2pWorker_OnFinishedBruteforcingThePattern);
     
    309290        }
    310291
    311         void p2pWorker_OnTextArrivedFromPublisher(byte[] data, PeerId pid)
    312         {
    313             this.Outputvalue = UTF8Encoding.UTF8.GetString(data);
    314         }
    315 
    316292        void p2pWorker_OnGuiMessage(string sData, NotificationLevel notificationLevel)
    317293        {
  • trunk/CrypPlugins/PeerToPeerWorker/P2PWorkerBase.cs

    r1068 r1090  
    4242
    4343        // Variables
     44        private string sTopicName = String.Empty;
    4445        /// <summary>
    4546        /// only goal: validate incoming KeyPatterns
     
    6566        #endregion
    6667
    67         public P2PWorkerBase(IP2PControl p2pControl, IControlKeySearcher keySearcherControl)
     68        public P2PWorkerBase(IP2PControl p2pControl, IControlKeySearcher keySearcherControl, string sTopicName)
    6869            : base(p2pControl)
    6970        {
     71            this.sTopicName = sTopicName;
    7072            this.keySearcherControl = keySearcherControl;
    7173            this.keySearcherControl.OnEndedBruteforcing += new KeySearcher.KeySearcher.BruteforcingEnded(keySearcherControl_OnEndedBruteforcing);
     
    144146                else
    145147                {
    146                     // TODO: to display the incoming KeyPattern in the OutputText, not the perfect way...
    147                     // base.HandleIncomingData(senderId, sData);
    148 
    149                     Thread processingThread = new Thread(new ParameterizedThreadStart(this.StartProcessing));
    150                     processingThread.Start(receivedKeyPattern);
     148                    //Thread processingThread = new Thread(new ParameterizedThreadStart(this.StartProcessing));
     149                    //processingThread.Start(receivedKeyPattern);
     150                    StartProcessing(receivedKeyPattern);
    151151                }
    152152            }
     
    158158
    159159        // necessary, because Thread-starting doesn't allow other parameters than object
    160         private void StartProcessing(object receivedKeyPattern)
    161         {
    162             if (receivedKeyPattern is KeyPattern)
    163                 StartProcessing(receivedKeyPattern as KeyPattern);
    164         }
     160        //private void StartProcessing(object receivedKeyPattern)
     161        //{
     162        //    if (receivedKeyPattern is KeyPattern)
     163        //        StartProcessing(receivedKeyPattern as KeyPattern);
     164        //}
    165165
    166166        /// <summary>
     
    170170        private void StartProcessing(KeyPattern receivedKeyPattern)
    171171        {
    172             GuiLogging("Starting Bruteforcing the incoming WildCardKey: '" + receivedKeyPattern.WildcardKey + "'", NotificationLevel.Info);
     172            GuiLogging("Start Bruteforcing the incoming WildCardKey: '" + receivedKeyPattern.WildcardKey + "'", NotificationLevel.Info);
    173173
    174174            if (OnKeyPatternReceived != null)
     
    177177            // to access this pattern in every method, where it's meaningful for information or processing reasons
    178178            this.actualProcessingPattern = receivedKeyPattern;
     179
     180            /* Begin: New stuff because of changing the IControl data flow - Arnie 2010.01.18 */
     181            byte[] encryptedData = this.p2pControl.DHTload(sTopicName + "EncryptedText");
     182            byte[] initVector = this.p2pControl.DHTload(sTopicName + "InitializationVector");
     183            //byte[] encryptedData = DHT_CommonManagement.GetEncryptedData(ref this.p2pControl, sTopicName);
     184            //byte[] initVector = DHT_CommonManagement.GetInitializationVector(ref this.p2pControl, sTopicName);
     185            /* End: New stuff because of changing the IControl data flow */
     186
    179187            // Commit pattern to the KeySearcherControl and wait for result(s)
    180             this.keySearcherControl.StartBruteforcing(receivedKeyPattern);
     188            this.keySearcherControl.StartBruteforcing(receivedKeyPattern, encryptedData, initVector);
    181189        }
    182190
Note: See TracChangeset for help on using the changeset viewer.