Esempio n. 1
0
        /// <summary>
        /// creates response to request and sends the response
        /// </summary>
        /// <param name="localPeerId">optional local test node ID, is sent by server to new peers who dont know server's PeerId</param>
        internal static void Respond(PeerHelloPacket requestPacket, PeerHelloRequestStatus status, PeerId localPeerId,
                                     SocketWithReceiver socket, IPEndPoint remoteEndPoint, bool thisPeerRoleAsUser = false)
        {
            var responseData = new PeerHelloPacket(requestPacket, status, localPeerId, thisPeerRoleAsUser).Encode();

            socket.UdpSocket.Send(responseData, responseData.Length, remoteEndPoint);
        }
Esempio n. 2
0
 /// <summary>
 /// creates packet for response
 /// </summary>
 private PeerHelloPacket(PeerHelloPacket requestPacket, PeerHelloRequestStatus status, PeerId localPeerId, bool thisPeerRoleAsUser)
 {
     LibraryVersion  = CompilationInfo.CompilationDateTimeUtc_uint32;
     ProtocolVersion = P2ptpCommon.ProtocolVersion;
     FromPeerId      = localPeerId ?? requestPacket.ToPeerId;
     ToPeerId        = requestPacket.FromPeerId;
     StreamId        = requestPacket.StreamId;
     Status          = status;
     RequestTime32   = requestPacket.RequestTime32;
     RoleFlags       = thisPeerRoleAsUser ? (byte)0x01 : (byte)0x00;
 }
Esempio n. 3
0
        /// <summary>
        /// creates response to request and sends the response
        /// </summary>
        /// <param name="localPeerId">optional local test node ID, is sent by server to new peers who dont know server's PeerId</param>
        internal static void Respond(PeerHelloPacket requestPacket, PeerHelloRequestStatus status, PeerId localPeerId,
                                     SocketWithReceiver socket, IPEndPoint remoteEndPoint, ushort?responseCpuDelayMs = null, bool thisPeerRoleAsUser = false, IpLocationData localIpLocationData = null)
        {
            var responsePacket = new PeerHelloPacket(requestPacket, status, localPeerId, thisPeerRoleAsUser, responseCpuDelayMs, remoteEndPoint.Address.ToString());

            if (localIpLocationData != null && requestPacket.FlagIwantToGetYourIpLocation)
            {
                responsePacket.IpLocationData = localIpLocationData;
            }
            var responseData = responsePacket.Encode();

            socket.UdpSocket.Send(responseData, responseData.Length, remoteEndPoint);
        }
Esempio n. 4
0
 /// <summary>
 /// creates packet for response
 /// </summary>
 private PeerHelloPacket(PeerHelloPacket requestPacket, PeerHelloRequestStatus status, PeerId localPeerId, bool thisPeerRoleAsUser, ushort?responseCpuDelayMs, string requestedFromIp)
 {
     LibraryVersion        = MiscProcedures.CompilationDateTimeUtc_uint32Seconds;
     ProtocolVersion       = P2ptpCommon.ProtocolVersion;
     FromPeerId            = localPeerId ?? requestPacket.ToPeerId;
     ToPeerId              = requestPacket.FromPeerId;
     StreamId              = requestPacket.StreamId;
     Status                = status;
     RequestTime32         = requestPacket.RequestTime32;
     Flags                 = thisPeerRoleAsUser ? (byte)0x01 : (byte)0x00;
     RequestSequenceNumber = requestPacket.RequestSequenceNumber;
     ResponseCpuDelayMs    = responseCpuDelayMs;
     RequestedFromIp       = requestedFromIp;
 }