/// <summary> /// Get the specified TID and t. Returns false if it isn't found. /// </summary> /// <param name="TID">TI.</param> /// <param name="t">T.</param> public bool Get(UInt64 TID, out TunnelBase t) { lReadWriteLock.AcquireReaderLock(READER_LOCK_TIMEOUT_MS); bool ret = this.mTunnels.Find(ref TID, out t); lReadWriteLock.ReleaseLock(); return(ret); }
/*internal bool RegisterTunnelRekey(AbstractTunnel abstractTunnel, UInt64 tid){ * if(this.mTunnelDirectory.TunnelIDExists (tid)){ * return false; * } * this.mTunnelDirectory.InsertTunnel (abstractTunnel, tid); * return true; * }*/ /// <summary> /// Unregisters abstractTunnel. /// </summary> /// <returns><c>true</c>, if register abstractTunnel was uned, <c>false</c> otherwise.</returns> /// <param name="abstractTunnel">SecureAbstractTunnel.</param> internal bool UnRegisterTunnel(TunnelBase abstractTunnel) { if (this.mTunnelDirectory.TunnelIDExists(abstractTunnel.ID)) { this.mTunnelDirectory.RemoveTunnel(abstractTunnel.ID); return(true); } return(false); }
/// <summary> /// Registers the passed abstractTunnel to the socket. Should return true but in extremly rare cases /// where the TID is already taken, it may return false. /// </summary> /// <returns><c>true</c>, if abstractTunnel was registered, <c>false</c> otherwise.</returns> /// <param name="abstractTunnel">SecureAbstractTunnel.</param> public bool RegisterTunnel(TunnelBase abstractTunnel) { if (this.mTunnelDirectory.TunnelIDExists(abstractTunnel.ID)) { return(false); } this.mTunnelDirectory.InsertTunnel(abstractTunnel); return(true); }
public bool InsertTunnel(TunnelBase abstractTunnel, UInt64 id) { bool result = false; lReadWriteLock.AcquireWriterLock(WRITER_LOCK_TIMEOUT_MS); //todo: determine if it makes sense to do a check here or to have the inserter do //the check to see if the TID already exists this.mTunnels.Add(id, abstractTunnel); result = true; lReadWriteLock.ReleaseWriterLock(); return(result); }
internal void HandlePacket(EncryptedPacket packet) { Console.WriteLine(String.Format("GenericPacket received {0}", Encoding.UTF8.GetString(packet.rawBytes, 0, packet.rawBytes.Length))); TunnelBase t = null; if (this.mTunnelDirectory.Get(packet.TID, out t)) { t.HandleIncomingPacket(packet); } else if (packet.HasEPK) { //open a new abstractTunnel //todo: we need some way of specifying which abstractTunnel type we're creating //to be using here.; t = new SecureTunnel(this); t.ID = packet.TID; this.RegisterTunnel(t); t.HandleHelloPacket(packet); } }
/// <summary> /// Removes the abstractTunnel. /// </summary> /// <returns><c>true</c>, if abstractTunnel was removed, <c>false</c> otherwise.</returns> /// <param name="abstractTunnel">SecureAbstractTunnel.</param> public bool RemoveTunnel(TunnelBase abstractTunnel) { return(this.RemoveTunnel(abstractTunnel.ID)); }
public SecureDuplexPipe(TunnelBase tunnel, UInt32 pipeId) : base(tunnel, pipeId) { }
/// <summary> /// Initializes a new instance of the <see cref="Tunneler.SecureDuplexPipe"/> class. /// A SecureDuplexPipe is a pipe with it's own Public Key encryption setup from /// end-to-end. This enables another layer of protection over the encryption /// provided by the tunnel itself /// </summary> public SecureDuplexPipe(TunnelBase tunnel) : base(tunnel) { }