public static IBus CreateFakeBus(int busReceptionPort, string busName, PeerId busId, int directoryServicePort, string directoryServiceName,PeerId directoryServiceId, IAssemblyScanner assemblyScanner = null, IPeerConfiguration peerconfig = null, IContainer container = null) { container = container ?? new Container(); return BusFactory.CreateBus(container, containerConfigurationExpression: ctx => { ctx.For <ZmqTransportConfiguration>() .Use( new DummyTransportConfig( busReceptionPort)); ctx.For <IBusBootstrapperConfiguration >().Use(new DummyBootstrapperConfig { DirectoryServiceEndpoint = "tcp://localhost:" + directoryServicePort, DirectoryServiceName = directoryServiceName, DirectoryServiceId = directoryServiceId }); ctx.For<IPeerConfiguration>().Use( peerconfig ?? new DummyPeerConfig(busName,busId, null)); ctx.For<IAssemblyScanner>().Use( assemblyScanner ?? new AssemblyScanner()); }); }
internal override void Handle(PeerId id) { if (!ClientEngine.SupportsFastPeer) throw new MessageException("Libtorrent extension messages not supported"); // FIXME: Do nothing for the moment - Maybe raise an event in the future? }
public ZmqOutboundSocket(ZmqContext context, PeerId peerId, string endPoint, IZmqSocketOptions options) { _context = context; _peerId = peerId; _options = options; EndPoint = endPoint; }
public ServicePeer(string peerName, PeerId peerId, List<MessageSubscription> handledMessages, List<ShadowedPeerConfiguration> shadowedPeers) { PeerName = peerName; PeerId = peerId; HandledMessages = handledMessages; ShadowedPeers = shadowedPeers; }
public OriginatorInfo(PeerId senderId, string senderEndPoint, string senderMachineName, string initiatorUserName) { SenderId = senderId; SenderEndPoint = senderEndPoint; SenderMachineName = senderMachineName; InitiatorUserName = initiatorUserName; }
public Peer(PeerId id, string endPoint, bool isUp, bool isResponding) { Id = id; EndPoint = endPoint; IsUp = isUp; IsResponding = isResponding; }
public PeerDescriptor(PeerId id, string endPoint, bool isPersistent, bool isUp, bool isResponding, DateTime timestampUtc, params Subscription[] subscriptions) { Peer = new Peer(id, endPoint, isUp, isResponding); Subscriptions = subscriptions; IsPersistent = isPersistent; TimestampUtc = timestampUtc; }
public MessageWireData(string messageType, Guid messageIdentity, PeerId sendingPeer, byte[] data) { MessageType = messageType; MessageIdentity = messageIdentity; Data = data; SendingPeerId = sendingPeer; }
internal Peer(PeerId id, string hostNameOrAddress, int port) { _id = id; _ip = null; _hostNameOrAddress = hostNameOrAddress; _port = port; }
public ShadowMessageCommand(MessageWireData message, PeerId primaryRecipient, bool primaryWasOnline, IEndpoint targetEndpoint) { Message = message; PrimaryRecipient = primaryRecipient; PrimaryWasOnline = primaryWasOnline; TargetEndpoint = targetEndpoint; }
public void should_get_peer_id() { var peerId = new PeerId("Abc.Foo.0"); _busMock.SetupGet(x => x.PeerId).Returns(peerId); _bus.PeerId.ShouldEqual(peerId); }
public BusFactory(IContainer container) { PeerId = new PeerId("Abc.Testing." + Guid.NewGuid()); _scanTargets.Add(new ScanTarget(typeof(IBus).Assembly, null)); Container = container; }
public ZmqInboundSocket(ZmqContext context, PeerId peerId, ZmqEndPoint originalEndpoint, IZmqSocketOptions options, string environment) { _context = context; _peerId = peerId; _originalEndpoint = originalEndpoint; _options = options; _environment = environment; }
public void ResetSequenceNumbersForPeer(PeerId peer) { var keysToRemove = _sequenceNumber.Keys.Where(x => x.Peer == peer).ToList(); foreach (var key in keysToRemove) { _sequenceNumber.Remove(key); } }
public MessageSubscription(Type messageType, PeerId peer, IEndpoint endpoint, ISubscriptionFilter subscriptionFilter, ReliabilityLevel reliabilityLevel) { MessageType = messageType; Peer = peer; Endpoint = endpoint; SubscriptionFilter = (subscriptionFilter); ReliabilityLevel = reliabilityLevel; }
internal static IAsyncResult BeginCheckEncryption(PeerId id, int bytesToReceive, AsyncCallback callback, object state, InfoHash[] sKeys) { EncryptorAsyncResult result = new EncryptorAsyncResult(id, callback, state); result.SKeys = sKeys; IConnection c = id.Connection; ClientEngine.MainLoop.QueueTimeout(TimeSpan.FromSeconds(10), delegate { if (id.Encryptor == null || id.Decryptor == null) id.CloseConnection(); return false; }); try { // If the connection is incoming, receive the handshake before // trying to decide what encryption to use if (id.Connection.IsIncoming) { result.Buffer = new byte[bytesToReceive]; NetworkIO.EnqueueReceive(c, result.Buffer, 0, result.Buffer.Length, null, null, null, HandshakeReceivedCallback, result); } else { EncryptionTypes usable = CheckRC4(id); bool hasPlainText = Toolbox.HasEncryption(usable, EncryptionTypes.PlainText); bool hasRC4 = Toolbox.HasEncryption(usable, EncryptionTypes.RC4Full) || Toolbox.HasEncryption(usable, EncryptionTypes.RC4Header); if (id.Engine.Settings.PreferEncryption) { if (hasRC4) { result.EncSocket = new PeerAEncryption(id.TorrentManager.InfoHash, usable); result.EncSocket.BeginHandshake(id.Connection, CompletedEncryptedHandshakeCallback, result); } else { result.Complete(); } } else { if (hasPlainText) { result.Complete(); } else { result.EncSocket = new PeerAEncryption(id.TorrentManager.InfoHash, usable); result.EncSocket.BeginHandshake(id.Connection, CompletedEncryptedHandshakeCallback, result); } } } } catch (Exception ex) { result.Complete(ex); } return result; }
public void DebugFormat(string format, IMessage message, MessageId? messageId = null, int messageSize = 0, PeerId peerId = default(PeerId)) { var logInfo = GetLogInfo(message); if (!logInfo.Logger.IsDebugEnabled) return; var messageText = logInfo.GetMessageText(message); _logger.DebugFormat(format, messageText, messageId, messageSize, peerId); }
public ShadowCompletionMessage(Guid messageId, PeerId fromPeer, PeerId toPeer, bool processingSuccessful, IEndpoint endpoint, string messageType) { MessageId = messageId; FromPeer = fromPeer; ToPeer = toPeer; ProcessingSuccessful = processingSuccessful; Endpoint = endpoint; MessageType = messageType; }
public ReceivedTransportMessage(string messageType, PeerId peerId, Guid messageIdentity, IEndpoint endpoint, byte[] data, int? sequenceNumber) { PeerId = peerId; MessageIdentity = messageIdentity; MessageType = messageType; Data = data; SequenceNumber = sequenceNumber; Endpoint = endpoint; }
public void Reinitialize(string messageType, PeerId peerId, Guid messageIdentity, IEndpoint endpoint, byte[] data, int? sequenceNumber) { PeerId = peerId; MessageIdentity = messageIdentity; MessageType = messageType; Data = data; SequenceNumber = sequenceNumber; Endpoint = endpoint; }
public void should_configure_bus() { var peerId = new PeerId("Abc.Foo.0"); var environment = "Dev"; _bus.Configure(peerId, environment); _busMock.Verify(x => x.Configure(peerId, environment)); }
public static StorageSubscription ToStorageSubscription(this SubscriptionsForType subscriptionFortype, PeerId peerId) { return new StorageSubscription { PeerId = peerId.ToString(), MessageTypeId = subscriptionFortype.MessageTypeId.FullName, SubscriptionBindings = SerializeBindingKeys(subscriptionFortype.BindingKeys) }; }
public void AddDynamicSubscriptionsForTypes(PeerId peerId, DateTime timestampUtc, SubscriptionsForType[] subscriptionsForTypes) { var peerEntry = GetEntry(peerId); if (peerEntry == null) return; if (!(timestampUtc >= peerEntry.PeerDescriptor.TimestampUtc)) return; var subscriptions = subscriptionsForTypes.SelectMany(sub => sub.BindingKeys.Select(binding => new Subscription(sub.MessageTypeId, binding))).ToList(); peerEntry.DynamicSubscriptions = peerEntry.DynamicSubscriptions.Concat(subscriptions).ToList(); }
public IEnumerable<ShadowMessageCommand> GetFirstMessages(PeerId peer, IEndpoint endpoint, int maxCount) { PeerMessageQueue queue; if (!_savedMessages.TryGetValue(peer, out queue)) yield break; int numberOfReturnedMessages = 0; while (queue[endpoint].Count != 0 && numberOfReturnedMessages < maxCount) { yield return queue[endpoint].Dequeue(); numberOfReturnedMessages++; } }
public LTChat(PeerId peer, string message) { for (int i = 0; i < peer.ExtensionSupports.Count; i++) { if (peer.ExtensionSupports[i].Name != Support.Name) continue; MessageId = peer.ExtensionSupports[i].MessageId; Message = message; return; } throw new MessageException("The peer does not support chat messages"); }
public static bool SetPeerRespondingState(this IPeerRepository repository, PeerId peerId, bool isResponding, DateTime timestampUtc) { var peer = repository.Get(peerId); if (peer == null || peer.TimestampUtc > timestampUtc) return false; peer.Peer.IsResponding = isResponding; peer.TimestampUtc = timestampUtc; repository.AddOrUpdatePeer(peer); return true; }
public void should_convert_peer_id_to_json_string() { var peerId = new PeerId("Abc.Testing.42"); var text = JsonConvert.SerializeObject(new MessageWithPeerId { PeerId1 = peerId }); text.ShouldContain(peerId.ToString()); Console.WriteLine(text); var message = JsonConvert.DeserializeObject<MessageWithPeerId>(text); message.PeerId1.ShouldEqual(peerId); message.PeerId2.ShouldBeNull(); }
public static MessageContext CreateOverride(PeerId peerId, string peerEndPoint) { var currentContext = Current; var initiatorUserName = GetInitiatorUserName(); var originator = new OriginatorInfo(peerId, peerEndPoint, CurrentMachineName, initiatorUserName); return new MessageContext { MessageId = MessageId.NextId(), Originator = originator, DispatchQueueName = currentContext?.DispatchQueueName, }; }
private static EncryptionTypes CheckRC4(PeerId id) { // If the connection is *not* incoming, then it will be associated with an Engine // so we can check what encryption levels the engine allows. EncryptionTypes t; if (id.Connection.IsIncoming) t = EncryptionTypes.All; else t = id.TorrentManager.Engine.Settings.AllowedEncryption; // We're allowed use encryption if the engine settings allow it and the peer supports it // Binary AND both the engine encryption and peer encryption and check what levels are supported t &= id.Peer.Encryption; return t; }
public static PeerDescriptor UpdatePeerSubscriptions(this IPeerRepository repository, PeerId peerId, Subscription[] subscriptions, DateTime? timestampUtc) { var peerDescriptor = repository.Get(peerId); if (peerDescriptor == null) throw new InvalidOperationException(string.Format("The specified Peer ({0}) does not exist.", peerId)); if (peerDescriptor.TimestampUtc > timestampUtc) return null; peerDescriptor.TimestampUtc = timestampUtc; peerDescriptor.Subscriptions = subscriptions; repository.AddOrUpdatePeer(peerDescriptor); return peerDescriptor; }
public SubscriptionsUpdated(Subscription subscription, PeerId peerId) { Subscriptions = new SubscriptionsForType(subscription.MessageTypeId, subscription.BindingKey); PeerId = peerId; }
protected override void HandleResponse(SetPeerBlacklistResponse setPeerBlackListResponse, IChannelHandlerContext channelHandlerContext, PeerId senderPeerIdentifier, ICorrelationId correlationId) { }
public SubscriptionsUpdated(SubscriptionsForType subscriptions, PeerId peerId) { Subscriptions = subscriptions; PeerId = peerId; }