public CreateSession ( byte cookieValue ) : Session | ||
cookieValue | byte | |
return | Session |
public Session CreateSession(byte[] cookieValue)
{
var temp = cookieValue.BytesToString();
if (!_cookies.ContainsKey(temp))
{
Logger.WARN("Creating session for an unknown cookie '{0}' (CPU congestion?)",temp);
return null;
}
var cookie = _cookies[temp];
Peer.Id = (byte[]) cookie.PeerId.Clone();
RtmfpUtils.UnpackUrl(cookie.QueryUrl,out Peer.Path,out Peer.Properties);
FarId = cookie.FarId;
Peer.Address = cookie.PeerAddress;
var session = Handler.CreateSession(Peer, cookie);
cookie.Id = session.Id;
cookie.Write();
if(cookie.Target != null)
{
//cookie.Target.InitiatorNonce = cookie.CookieComputing.InitiatorNonce.Clone() as byte[];
cookie.Target.SharedSecret = cookie.CookieComputing.SharedSecret;
}
Writer.Write((byte)0x78);
Writer.Write(cookie.Length);
cookie.Read(Writer.BaseStream);
Flush(0x0b);
FarId = 0;
return session;
}
public void Run() { if (DH == null) { DH = RtmfpUtils.BeginDiffieHellman(ref Nonce); return; } // Compute Diffie-Hellman secret SharedSecret = DH.CreateSharedKey(InitiatorKey); // Compute Keys RtmfpUtils.ComputeAsymetricKeys(SharedSecret, InitiatorNonce, Nonce, out DecryptKey, out EncryptKey); var pSession = _handshake?.CreateSession(Value); if (pSession != null) { pSession.Peer.UserState = this; } }