Changeset 1433 for trunk/CrypP2P


Ignore:
Timestamp:
May 17, 2010, 2:38:37 PM (12 years ago)
Author:
Paul Lelgemann
Message:

o Extracted common classes from PeerToPeerBase plugin into new PeerToPeer plugin as a preparation for the new P2P proxy
o Modified directory properties to ignore the CrypBuild directory

Location:
trunk
Files:
4 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1010bin
        1111obj
         12CrypBuild
  • trunk/CrypP2P/CrypP2P.csproj

    r1432 r1433  
    162162    <Compile Include="Worker\ConnectionWorker.cs" />
    163163    <Compile Include="Worker\WorkerBase.cs" />
    164     <Compile Include="Internal\DHT_CommonManagement.cs" />
    165     <Compile Include="Internal\IP2PControl.cs" />
    166     <Compile Include="Internal\KeySearcherResult.cs" />
    167164    <Compile Include="P2PManager.cs" />
    168165    <Compile Include="Helper\PAPCertificate.cs" />
    169166    <Compile Include="Internal\P2PBase.cs" />
    170167    <Compile Include="Properties\AssemblyInfo.cs" />
    171     <Compile Include="Internal\ResponseWait.cs" />
    172168  </ItemGroup>
    173169  <ItemGroup>
     
    206202      <Private>False</Private>
    207203    </ProjectReference>
    208     <ProjectReference Include="..\CrypPlugins\PeerToPeerJobs\PeerToPeerJobs.csproj">
    209       <Project>{F1258427-AFDF-4DF7-ABF1-758A2325F505}</Project>
    210       <Name>PeerToPeerJobs</Name>
    211       <Private>False</Private>
     204    <ProjectReference Include="..\CrypPlugins\PeerToPeer\PeerToPeer.csproj">
     205      <Project>{12829116-8FAD-4D09-A0AA-D75D88F07626}</Project>
     206      <Name>PeerToPeer</Name>
    212207    </ProjectReference>
    213208  </ItemGroup>
  • trunk/CrypP2P/Internal/P2PBase.cs

    r1374 r1433  
    3232using PeersAtPlay.Util.Logging;
    3333using Gears4Net;
     34using Cryptool.Plugins.PeerToPeer.Internal;
    3435
    3536/* TODO:
     
    687688
    688689    }
    689 
    690     public class PeerId
    691     {
    692         private readonly string stringId;
    693         private readonly byte[] byteId;
    694 
    695         private const uint OFFSET_BASIS = 2166136261;
    696         private const uint PRIME = 16777619; // 2^24 + 2^8 + 0x93
    697         private readonly int hashCode;
    698 
    699         public PeerId(OverlayAddress oAddress)
    700         {
    701             if (oAddress != null)
    702             {
    703                 this.stringId = oAddress.ToString();
    704                 this.byteId = oAddress.ToByteArray();
    705 
    706                 // FNV-1 hashing
    707                 uint fnvHash = OFFSET_BASIS;
    708                 foreach (byte b in byteId)
    709                 {
    710                     fnvHash = (fnvHash * PRIME) ^ b;
    711                 }
    712                 hashCode = (int)fnvHash;
    713             }
    714         }
    715 
    716         /// <summary>
    717         /// Returns true when the byteId content is identical
    718         /// </summary>
    719         /// <param name="right"></param>
    720         /// <returns></returns>
    721         public override bool Equals(object right)
    722         {
    723             /* standard checks for reference types */
    724 
    725             if (right == null)
    726                 return false;
    727 
    728             if (object.ReferenceEquals(this, right))
    729                 return true;
    730 
    731             if (this.GetType() != right.GetType())
    732                 return false;
    733 
    734             // actual content comparison
    735             return this == (PeerId)right;
    736         }
    737 
    738         public static bool operator ==(PeerId left, PeerId right)
    739         {
    740             // because it's possible that one parameter is null, catch this exception
    741             /* Begin add - Christian Arnold, 2009.12.16, must cast the parameters, otherwise --> recursion */
    742             if ((object)left == (object)right)
    743                 return true;
    744 
    745             if ((object)left == null || (object)right == null)
    746                 return false;
    747             /* End add */
    748 
    749             if (left.hashCode != right.hashCode)
    750                 return false;
    751 
    752             if (left.byteId.Length != right.byteId.Length)
    753                 return false;
    754 
    755             for (int i = 0; i < left.byteId.Length; i++)
    756             {
    757                 // uneven pattern content
    758                 if (left.byteId[i] != right.byteId[i])
    759                     return false;
    760             }
    761 
    762             return true;
    763         }
    764 
    765         public static bool operator !=(PeerId left, PeerId right)
    766         {
    767             return !(left == right);
    768         }
    769 
    770         public override int GetHashCode()
    771         {
    772             return hashCode;
    773         }
    774 
    775         public override string ToString()
    776         {
    777             return this.stringId;
    778         }
    779 
    780         public byte[] ToByteArray()
    781         {
    782             return this.byteId;
    783         }
    784     }
    785690}
  • trunk/CrypP2P/P2PManager.cs

    r1378 r1433  
    2727using Cryptool.P2P.Helper;
    2828using Cryptool.P2P.Internal;
     29using Cryptool.Plugins.PeerToPeer;
     30using Cryptool.Plugins.PeerToPeer.Internal;
    2931
    3032namespace Cryptool.P2P
     
    5153
    5254        #region Private variables
    53         private P2PBase P2PBase { get; set; }
     55        public P2PBase P2PBase { get; set; }
    5456        private P2PSettings P2PSettings { get; set; }
    5557        private ButtonDropDown P2PButton { get; set; }
     
    116118        }
    117119
     120        public PeerId GetPeerId(out string userName)
     121        {
     122            return P2PBase.GetPeerID(out userName);
     123        }
     124
    118125        #region DHT operations
    119126        // TODO add error handling, if P2P if not connected
    120127        public static bool Store(string key, byte[] data)
     128        {
     129            return INSTANCE.P2PBase.SynchStore(key, data);
     130        }
     131
     132         public static bool Store(string key, string data)
    121133        {
    122134            return INSTANCE.P2PBase.SynchStore(key, data);
  • trunk/CrypP2P/P2PSettings.cs

    r1374 r1433  
    2121using Cryptool.P2P.Helper;
    2222using Cryptool.P2P.Internal;
     23using Cryptool.Plugins.PeerToPeer.Internal;
    2324
    2425namespace Cryptool.P2P
     
    3839        {
    3940            PeerName = PAPCertificate.CERTIFIED_PEER_NAME;
    40             WorldName = "CrypTool";
     41            WorldName = "CrypTool2";
    4142            Log2Monitor = true;
    4243            LinkManagerType = P2PLinkManagerType.Snal;
Note: See TracChangeset for help on using the changeset viewer.