public override ServerPeer CreateServerPeer(INetworkMessageSender sender, IConnectionDetails details, INetworkMessageSubscriptionService subService, IDisconnectionServiceHandler disconnectHandler)
        {
            //This shouldn't be called by the ProxyLoadBalancing server
            AppLogger.ErrorFormat("Outgoing connection attempt on Proxy to IP {0} Port {1}. Proxy should not be connecting to other peers", details.RemoteIP, details.RemotePort);

            return(null);
        }
예제 #2
0
 public void ReplicateFrom(
    IConnectionDetails source,
    string filter,
    object filterquery)
 {
     Replicate(source, _connection, filter, filterquery);
 }
 protected TransferServiceFactory(
     TransferProtocol transferProtocol,
     IConnectionDetails connectionDetails)
 {
     _transferProtocol  = transferProtocol;
     _connectionDetails = connectionDetails;
 }
        public AuthServicePeerSession(ILog logger, INetworkMessageSender sender, IConnectionDetails details, INetworkMessageSubscriptionService netMessageSubService,
                                      IDisconnectionServiceHandler disconnectHandler, IRequestPayloadHandlerService <AuthServicePeerSession> requestHandlerService)
            : base(logger, sender, details, netMessageSubService, disconnectHandler)
        {
            logger.Debug("Created new authservice.");

            requestHandler = requestHandlerService;
        }
예제 #5
0
		protected ClientPeer(ILog logger, INetworkMessageRouterService messageSender, IConnectionDetails details, INetworkMessageSubscriptionService subService,
			IDisconnectionServiceHandler disconnectHandler
#if !ENDUSER
			, INetworkMessageRouteBackService routebackService)
#else
			)
#endif
				: base(logger, messageSender, details, subService, disconnectHandler)
예제 #6
0
        public Peer(IConnectionDetails details, EncryptionRegister encryptRegister)
        {
            if (details != null)
            {
                MemberwiseConnectionDetailsCopyToClass(details);
            }

            EncryptionRegister = encryptRegister;
        }
예제 #7
0
        /// <summary>
        /// Determines if the session can pass through the gate.
        /// </summary>
        /// <param name="sessionType">Type of the session.</param>
        /// <param name="details">Details about the connection.</param>
        /// <returns>True if the session can pass through the gate.</returns>
        public bool RequestPassage(ProxySessionType sessionType, IConnectionDetails details)
        {
            //For now we just let everything pass through.
            //Eventually we will block incoming connections for certain session types that don't match
            //the subset of valid IPs for the service or if it doesn't match the correct port

            //Don't let default sessions pass in.
            if (sessionType == ProxySessionType.Default)
            {
                return(false);
            }

            return(isValidPort(details.LocalPort));
        }
예제 #8
0
        /// <inheritdoc />
        public ClientPeerSession Create(IConnectionDetails connectionDetails, NetConnection connection)
        {
            if (connectionDetails == null)
            {
                throw new ArgumentNullException(nameof(connectionDetails));
            }
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }

            //Build the message router service
            LidgrenNetworkMessageRouterService    routerService         = new LidgrenServerNetworkMessageRouterService(new LidgrenNetworkMessageFactory(), connection, Serializer);
            NetworkMessagePublisher               basicMessagePublisher = new NetworkMessagePublisher();
            DefaultNetworkMessageRouteBackService routebackService      = new DefaultNetworkMessageRouteBackService(NetPeerAUIDService, PeerLogger);
            DefaultDisconnectionServiceHandler    disconnectionHandler  = new DefaultDisconnectionServiceHandler();

            //TODO: Clean this up
            disconnectionHandler.DisconnectionEventHandler += () => PeerServiceCollection.Remove(connectionDetails.ConnectionID);

            //Try to create the incoming peer; consumers of the library may reject the connection.
            ClientPeerSession session = ManagedSessionFactory.CreateIncomingPeerSession(routerService, connectionDetails, basicMessagePublisher, disconnectionHandler, routebackService);

            if (session == null)
            {
                return(null);
            }

            if (session.PeerDetails.ConnectionID == 0)
            {
                throw new InvalidOperationException("Generated peer has an unset connection ID.");
            }

            //Create a service context for the server.
            ClientSessionServiceContext serviceContext = new ClientSessionServiceContext(routerService, basicMessagePublisher, session);

            //Enter AUID lock
            PeerServiceCollection.syncObj.EnterWriteLock();
            try
            {
                PeerServiceCollection.Add(session.PeerDetails.ConnectionID, serviceContext);
            }
            finally
            {
                PeerServiceCollection.syncObj.ExitWriteLock();
            }

            return(session);
        }
예제 #9
0
파일: Peer.cs 프로젝트: HelloKitty/GladNet2
        protected Peer(ILog logger, INetworkMessageRouterService messageSender, IConnectionDetails details, INetworkMessageSubscriptionService subService,
			IDisconnectionServiceHandler disconnectHandler)
        {
            Throw<ArgumentNullException>.If.IsNull(logger)?.Now(nameof(logger));
            Throw<ArgumentNullException>.If.IsNull(messageSender)?.Now(nameof(messageSender));
            Throw<ArgumentNullException>.If.IsNull(details)?.Now(nameof(details));
            Throw<ArgumentNullException>.If.IsNull(subService)?.Now(nameof(subService));
            Throw<ArgumentNullException>.If.IsNull(disconnectHandler)?.Now(nameof(disconnectHandler));

            PeerDetails = details;
            NetworkSendService = messageSender;
            Logger = logger;
            disconnectionHandler = disconnectHandler;

            //All peers should care about status changes so we subscribe
            subService.SubscribeTo<StatusMessage>()
                .With(OnReceiveStatus);
        }
예제 #10
0
 public void Replicate(
    IConnectionDetails from,
    IConnectionDetails to,
    string filter,
    object filterquery)
 {
     if (string.IsNullOrEmpty(filter))
         _client.DoRequest("_replicate", "POST", _serializer.Serialize(new
         {
             source = string.Concat(from.ToUriString(true), "/", from["database"]),
             target = string.Concat(to.ToUriString(true), "/", to["database"])
         }), "application/json");
     else
         _client.DoRequest("_replicate", "POST", _serializer.Serialize(new
         {
             source = string.Concat(from.ToUriString(true), "/", from["database"]),
             target = string.Concat(to.ToUriString(true), "/", to["database"]),
             filter = filter,
             query_params = filterquery
         }), "application/json");
 }
		/// <summary>
		/// Creates a client session for the incoming connection request.
		/// </summary>
		/// <param name="sender">Message sending service.</param>
		/// <param name="details">Connection details.</param>
		/// <param name="subService">Subscription service for networked messages.</param>
		/// <param name="disconnectHandler">Disconnection handling service.</param>
		/// <returns>A new client session.</returns>
		protected abstract ClientPeerSession CreateClientSession(INetworkMessageRouterService sender, IConnectionDetails details, INetworkMessageSubscriptionService subService,
			IDisconnectionServiceHandler disconnectHandler, INetworkMessageRouteBackService routebackService);
 //Resolves a TSessionType from the context provided
 private TSessionType SessionResolve <TSessionType>(IComponentContext context, INetworkMessageSender sender, IConnectionDetails details,
                                                    INetworkMessageSubscriptionService subService, IDisconnectionServiceHandler disconnectHandler)
     where TSessionType : ClientPeerSession
 {
     return(context.Resolve <TSessionType>(GenerateTypedParameter(sender), GenerateTypedParameter(details), GenerateTypedParameter(subService), GenerateTypedParameter(disconnectHandler)));
 }
예제 #13
0
 public void ReplicateFrom(
    IConnectionDetails source)
 {
     Replicate(source, _connection, null, null);
 }
예제 #14
0
 public ElasticServer(IRestClient client, ISerializer serializer, IConnectionDetails connection)
 {
     _serializer = serializer;
     _client = client;
     _connection = connection;
 }
예제 #15
0
 public ServerPeer(IConnectionDetails details, ILogger logger)
     : base(details)
 {
     this.ClassLogger = logger;
 }
예제 #16
0
 public void Replicate(
    IConnectionDetails from,
    IConnectionDetails to)
 {
     Replicate(from, to, null, null);
 }
        /// <summary>
        /// Creates a new object that represents an auth service connection.
        /// </summary>
        /// <param name="logger">Logging service for this session.</param>
        /// <param name="sender">Network message sending service.</param>
        /// <param name="details">Connection details for this specific incoming game server session.</param>
        /// <param name="netMessageSubService">Subscription service for incoming messages.</param>
        /// <param name="disconnectHandler">Disconnection handler for the session.</param>
        /// <param name="responseHandler">Request payload handler for the session.</param>
        public AuthServiceClientPeer(ILog logger, INetworkMessageRouterService messageSender, IConnectionDetails details,
                                     INetworkMessageSubscriptionService subService, IDisconnectionServiceHandler disconnectHandler, INetworkMessageRouteBackService routebackService, IResponseMessageHandlerService <AuthServiceClientPeer> responseHandler)
            : base(logger, messageSender, details, subService, disconnectHandler, routebackService)
        {
            //We check logger null because we want to log now
            Throw <ArgumentNullException> .If.IsNull(logger)?.Now(nameof(logger), $"Logging service provided must be non-null.");

            Throw <ArgumentNullException> .If.IsNull(responseHandler)?.Now(nameof(responseHandler), $"Response handling service provided must be non-null.");


            //the authservice doesn't really 'connect'
            logger.Debug($"An {nameof(AuthServiceClientPeer)} was created but not connected yet.");

            //We only have a response handler; we won't be provided with an event handler (maybe in the future) because we don't want to handle any events.
            responseHandlerService = responseHandler;
        }
		/// <summary>
		/// Creates a server client session (outbound) for the incoming connection request.
		/// </summary>
		/// <param name="sender">Message sending service.</param>
		/// <param name="details">Connection details.</param>
		/// <param name="subService">Subscription service for networked messages.</param>
		/// <param name="disconnectHandler">Disconnection handling service.</param>
		/// <returns>A new client session.</returns>
		public abstract GladNet.Engine.Common.ClientPeer CreateServerPeer(INetworkMessageRouterService sender, IConnectionDetails details, INetworkMessageSubscriptionService subService,
			IDisconnectionServiceHandler disconnectHandler, INetworkMessageRouteBackService routebackService);
예제 #19
0
        //Right now there isn't anything extra in a Lidgren peer. It needs to be used so that it
        //can be a future vector for delivering features to lidgren peers.

        public LidgrenClientPeer(ILog logger, INetworkMessageRouterService messageSender, IConnectionDetails details, INetworkMessageSubscriptionService subService, IDisconnectionServiceHandler disconnectHandler, INetworkMessageRouteBackService routebackService)
            : base(logger, messageSender, details, subService, disconnectHandler, routebackService)
        {
        }
예제 #20
0
        /// <summary>
        /// A helper method to create <see cref="KustoConnectionStringBuilder"/>.
        /// </summary>
        /// <param name="connectionDetails">Connection deatails.</param>
        /// <returns>A new instance of <see cref="KustoConnectionStringBuilder"/>.</returns>
        public static KustoConnectionStringBuilder CreateKustoConnectionStringBuilder(IConnectionDetails connectionDetails)
        {
            var conn = new KustoConnectionStringBuilder(
                connectionDetails.ClusterUrl,
                connectionDetails.DefaultDatabaseName)
                       .WithAadApplicationKeyAuthentication(
                connectionDetails.AadClientId,
                connectionDetails.AadClientSecret,
                connectionDetails.AadTenantId);

            // Sending both name and version this way for better visibility in Kusto audit logs.
            conn.ApplicationNameForTracing = $"{KustoApplicationNameForTracing}:{AssemblyVersion}";

            return(conn);
        }
예제 #21
0
 public ClientPeer(IConnectionDetails details)
     : base(details)
 {
 }
예제 #22
0
 protected override ClientPeerSession CreateClientSession(INetworkMessageRouterService sender, IConnectionDetails details, INetworkMessageSubscriptionService subService, IDisconnectionServiceHandler disconnectHandler, INetworkMessageRouteBackService routeBack)
 {
     return(peerFactory.Create(sender, details, subService, disconnectHandler, routeBack));
 }
예제 #23
0
 protected override bool ShouldServiceIncomingPeerConnect(IConnectionDetails details)
 {
     return(peerFactory.CanCreate(details));
 }
예제 #24
0
 public ConnectionManager(IConnectionDetails connectionDetails, ITokenRepository tokenRepository)
 {
     _connectionDetails = connectionDetails;
     _tokenRepository   = tokenRepository;
 }
예제 #25
0
 public RestClient(IConnectionDetails connectionDetails)
     : this(connectionDetails.ToUri(), connectionDetails.GetCredentials())
 {
 }
 public override ServerPeerSession CreateServerPeerSession(INetworkMessageSender sender, IConnectionDetails details, INetworkMessageSubscriptionService subService, IDisconnectionServiceHandler disconnectHandler)
 {
     throw new NotImplementedException("This is deprecated and will be removed. Somehow a someone tried to create a peer session.");
 }
예제 #27
0
 public void ReplicateTo(
    IConnectionDetails destination)
 {
     Replicate(_connection, destination, null, null);
 }
 public UserClientPeerSession(ILog logger, INetworkMessageSender sender, IConnectionDetails details, INetworkMessageSubscriptionService subService, IDisconnectionServiceHandler disconnectHandler)
     : base(logger, sender, details, subService, disconnectHandler)
 {
     logger.Debug("Created new client session.");
 }
		//Right now there isn't anything extra in a Lidgren peer. It needs to be used so that it
		//can be a future vector for delivering features to lidgren peers.

		public LidgrenClientPeer(ILog logger, INetworkMessageRouterService messageSender, IConnectionDetails details, INetworkMessageSubscriptionService subService, IDisconnectionServiceHandler disconnectHandler, INetworkMessageRouteBackService routebackService) 
			: base(logger, messageSender, details, subService, disconnectHandler, routebackService)
		{

		}
예제 #30
0
        /// <inheritdoc />
        public override ClientPeerSession CreateIncomingPeerSession(INetworkMessagePayloadSenderService sender, IConnectionDetails details, INetworkMessageSubscriptionService subService, IDisconnectionServiceHandler disconnectHandler)
        {
            //For now we assume that any connection is valid.
            //In the future we might filter out some IPs but most validation will be post-connection from a signed message.
            ClientPeerSession session = new InstanceClientSession(Logger, sender, details, subService, disconnectHandler, instanceSessionRequestMessageHandlerService);

            //Register the OnDisconnect UnityEvent for when the session disconnects
            disconnectHandler.DisconnectionEventHandler += () => OnSessionDisconnected?.Invoke(session);

            //This isn't great; invoking this before returning it to the server base is not great design but it's the only way right now
            OnNewSessionCreated?.Invoke(session);

            return(session);
        }
예제 #31
0
 protected void MemberwiseConnectionDetailsCopyToClass(IConnectionDetails details)
 {
     this.RemoteConnectionEndpoint = details.RemoteConnectionEndpoint;
     this.UniqueConnectionId       = details.UniqueConnectionId;
     this.InternalNetConnection    = details.InternalNetConnection;
 }
예제 #32
0
 /// <summary>
 /// Processes incoming connection details and decides if a connection should be established.
 /// </summary>
 /// <param name="details">Details of the connection.</param>
 /// <returns>Indicates if, based on the details, a connection should be serviced.</returns>
 protected abstract bool ShouldServiceIncomingPeerConnect(IConnectionDetails details);
예제 #33
0
 /// <summary>
 /// Creates a client session for the incoming connection request.
 /// </summary>
 /// <param name="sender">Message sending service.</param>
 /// <param name="details">Connection details.</param>
 /// <param name="subService">Subscription service for networked messages.</param>
 /// <param name="disconnectHandler">Disconnection handling service.</param>
 /// <returns>A new client session.</returns>
 protected abstract ClientPeerSession CreateClientSession(INetworkMessageRouterService sender, IConnectionDetails details, INetworkMessageSubscriptionService subService,
                                                          IDisconnectionServiceHandler disconnectHandler, INetworkMessageRouteBackService routebackService);
예제 #34
0
        public ServerPeerSession(ILog logger, INetworkMessageRouterService sender, IConnectionDetails details, INetworkMessageSubscriptionService netMessageSubService,
			IDisconnectionServiceHandler disconnectHandler, INetworkMessageRouteBackService routebackService)
            : base(logger, sender, details, netMessageSubService, disconnectHandler, routebackService)
        {
        }
예제 #35
0
 /// <summary>
 /// Creates a server client session (outbound) for the incoming connection request.
 /// </summary>
 /// <param name="sender">Message sending service.</param>
 /// <param name="details">Connection details.</param>
 /// <param name="subService">Subscription service for networked messages.</param>
 /// <param name="disconnectHandler">Disconnection handling service.</param>
 /// <returns>A new client session.</returns>
 public abstract GladNet.Engine.Common.ClientPeer CreateServerPeer(INetworkMessageRouterService sender, IConnectionDetails details, INetworkMessageSubscriptionService subService,
                                                                   IDisconnectionServiceHandler disconnectHandler, INetworkMessageRouteBackService routebackService);
예제 #36
0
 public void ReplicateTo(
    IConnectionDetails destination,
    string filter,
    object filterquery)
 {
     Replicate(_connection, destination, filter, filterquery);
 }
 public ConcreteTransferServiceFactory(
     TransferProtocol transferProtocol,
     IConnectionDetails connectionDetails)
     : base(transferProtocol, connectionDetails)
 {
 }
        public InstanceClientSession(ILog logger, INetworkMessagePayloadSenderService sender, IConnectionDetails details,
                                     INetworkMessageSubscriptionService subService, IDisconnectionServiceHandler disconnectHandler, IRequestMessageHandlerService <InstanceClientSession> requestMessageHandlers)
            : base(logger, sender, details, subService, disconnectHandler)
        {
            if (requestMessageHandlers == null)
            {
                throw new ArgumentNullException(nameof(requestMessageHandlers), $"Cannot provide a null {nameof(IRequestMessageHandlerService<InstanceClientSession>)}.");
            }

            requestMessageHandlerService = requestMessageHandlers;
        }
		/// <summary>
		/// Processes incoming connection details and decides if a connection should be established.
		/// </summary>
		/// <param name="details">Details of the connection.</param>
		/// <returns>Indicates if, based on the details, a connection should be serviced.</returns>
		protected abstract bool ShouldServiceIncomingPeerConnect(IConnectionDetails details);