コード例 #1
0
ファイル: AjaxWebsocket.cs プロジェクト: hungdluit/sipserver
			public void RestoreAddresses(ServerAsyncEventArgs e)
			{
				e.ConnectionId = connectionId;
				e.LocalEndPoint = localEndPoint;
				e.RemoteEndPoint = remoteEndPoint;

				localEndPoint = null;
				remoteEndPoint = null;
			}
コード例 #2
0
        public static ConnectionId Generate(ServerEndPoint reflexive, IPEndPoint local)
        {
            if (sha1 == null)
                sha1 = new HMACSHA1(sha1Key);

            string hashData = reflexive.ToString() + local.ToString() + Interlocked.Increment(ref count).ToString();

            var bytes = sha1.ComputeHash(Encoding.UTF8.GetBytes(hashData));

            return new ConnectionId()
            {
                Value1 = BitConverter.ToInt64(bytes, 0),
                Value2 = BitConverter.ToInt64(bytes, 8),
                Value3 = BitConverter.ToInt32(bytes, 16),
            };
        }
コード例 #3
0
 public AppTermServerTransport(SyncBinding binding,
                               ServerEndPoint serverEndpoint,
                               IPAddress localAddr, int port) : base(binding, serverEndpoint, localAddr, port)
 {
 }
コード例 #4
0
ファイル: JokeInspectors.cs プロジェクト: itadapter/nfx
 public RequestMsg ServerDispatchRequest(ServerEndPoint endpoint, RequestMsg request)
 {
     NFX.ApplicationModel.ExecutionContext.Application.Log.Write( new NFX.Log.Message{  Type=NFX.Log.MessageType.TraceA, From ="ServeInspector", Text="Received " + request.ServerTransport.StatBytesReceived.ToString() + " bytes"});
       return request;
 }
コード例 #5
0
ファイル: SyncServerTransport.cs プロジェクト: lulzzz/nfx-1
 /// <summary>
 /// Allocates a listener transport
 /// </summary>
 public SyncServerTransport(SyncBinding binding, ServerEndPoint serverEndpoint, IPAddress localAddr, int port) : base(binding, serverEndpoint)
 {
     Node        = serverEndpoint.Node;
     m_IPAddress = localAddr;
     m_Port      = port;
 }
コード例 #6
0
ファイル: InProcBinding.cs プロジェクト: sergey-msu/nfx
 protected internal override ServerTransport OpenServerEndpoint(ServerEndPoint epoint)
 {
     return new InProcServerTransport(this, epoint);
 }
コード例 #7
0
ファイル: TurnServer.cs プロジェクト: vf1/turnserver
        private void SendTurn(TurnMessage message, ServerEndPoint local, IPEndPoint remote)
        {
            ServerAsyncEventArgs p;
            int offset;

            message.ComputeMessageLength();

            GetBuffer(local, remote, message.TotalMessageLength, out p, out offset);

            message.GetBytes(p.Buffer, offset, Authentificater.Key2);

            turnServer.SendAsync(p);
        }
コード例 #8
0
 private string GetKey(ServerEndPoint local, IPEndPoint remote)
 {
     return(local.ToString() + @"|" + remote.ToString());
 }
コード例 #9
0
 internal ServerInfoEventArgs(ServerEndPoint serverEndPoint, SocketException error)
     : base(serverEndPoint)
 {
     SocketError = error.SocketErrorCode;
     Exception = error;
 }
コード例 #10
0
 public PhotonServerPeer(InitRequest initRequest) : base(initRequest)
 {
     ServerEndPoint = new ServerEndPoint(new PhotonServerCommunicationInterface(this));
     ServerEndPoint.LastConnectedIPAddress = RemoteIPAddress;
     EndPointFactory.Instance.EndPointConnect(ServerEndPoint);
 }
コード例 #11
0
 public PipeClient(ServerEndPoint endpoint, ILoggerFactory loggerFactory)
 {
     _endpoint      = (NamedPipeEndPoint)endpoint.EndPoint;
     ServerEndPoint = endpoint;
     _loggerFactory = loggerFactory;
 }
コード例 #12
0
ファイル: IpEndPointExt.cs プロジェクト: KhaledSMQ/SipServer
 public static bool IsTransportUnreliable(this ServerEndPoint endPoint)
 {
     return(endPoint.Protocol == ServerProtocol.Udp);
 }
コード例 #13
0
ファイル: AjaxWebsocket.cs プロジェクト: hungdluit/sipserver
			public void StoreAddresses(Connection connection)
			{
				connectionId = connection.Id;
				localEndPoint = connection.LocalEndPoint;
				remoteEndPoint = connection.RemoteEndPoint;
			}
コード例 #14
0
 public ServerChangeEventArgs(ServerEndPoint serverEndPoint)
 {
     ServerEndPoint = serverEndPoint;
 }
コード例 #15
0
ファイル: NOPGlue.cs プロジェクト: vlapchenko/nfx
        public void UnregisterServerEndpoint(ServerEndPoint ep)
        {

        }
コード例 #16
0
ファイル: MpxBinding.cs プロジェクト: sergey-msu/nfx
 protected internal override void CloseServerEndpoint(ServerEndPoint epoint)
 {
   var t = epoint.Transport;
   if (t!=null) t.Dispose();
 }
コード例 #17
0
ファイル: TurnServer.cs プロジェクト: vf1/turnserver
        private TurnMessage ProcessAllocateRequest(ref Allocation allocation, TurnMessage request, ServerEndPoint local, IPEndPoint remote)
        {
            uint sequenceNumber = (request.MsSequenceNumber != null) ? request.MsSequenceNumber.SequenceNumber : 0;

            {
                uint lifetime = (request.Lifetime != null) ? ((request.Lifetime.Value > MaxLifetime.Seconds) ? MaxLifetime.Seconds : request.Lifetime.Value) : DefaultLifetime.Seconds;

                if (allocation != null)
                {
                    allocation.Lifetime = lifetime;

                    if (lifetime == 0)
                    {
                        logger.WriteInformation(string.Format("Update Allocation: {2} seconds {0} <--> {1}", allocation.Alocated.ToString(), allocation.Reflexive.ToString(), lifetime));
                    }
                }
                else
                {
                    if (lifetime <= 0)
                    {
                        throw new TurnServerException(ErrorCode.NoBinding);
                    }

                    ProtocolPort pp = new ProtocolPort()
                    {
                        Protocol = local.Protocol,
                    };
                    if (peerServer.Bind(ref pp) != SocketError.Success)
                    {
                        throw new TurnServerException(ErrorCode.ServerError);
                    }

                    allocation = new Allocation()
                    {
                        TransactionId = request.TransactionId,
                        ConnectionId  = ConnectionIdGenerator.Generate(local, remote),

                        Local     = local,
                        Alocated  = new ServerEndPoint(pp, PublicIp),
                        Real      = new ServerEndPoint(pp, RealIp),
                        Reflexive = new IPEndPoint(remote.Address, remote.Port),

                        Lifetime = lifetime,
                    };

                    allocations.Replace(allocation);

                    logger.WriteInformation(string.Format("Allocated: {0} <--> {1} for {2} seconds", allocation.Alocated.ToString(), allocation.Reflexive.ToString(), allocation.Lifetime));
                }
            }

            return(new TurnMessage()
            {
                IsAttributePaddingDisabled = true,
                MessageType = MessageType.AllocateResponse,
                TransactionId = request.TransactionId,

                MagicCookie = new MagicCookie(),

                MappedAddress = new MappedAddress()
                {
                    IpAddress = allocation.Alocated.Address,
                    Port = (UInt16)allocation.Alocated.Port,
                },

                Lifetime = new Lifetime()
                {
                    Value = allocation.Lifetime,
                },
                Bandwidth = new Bandwidth()
                {
                    Value = 750,
                },

                XorMappedAddress = new XorMappedAddress(TurnMessageRfc.MsTurn)
                {
                    IpAddress = remote.Address,
                    Port = (UInt16)remote.Port,
                },

                Realm = new Realm(TurnMessageRfc.MsTurn)
                {
                    Ignore = true,
                    Value = Authentificater.Realm,
                },
                MsUsername = new MsUsername()
                {
                    Ignore = true,
                    Value = request.MsUsername.Value,
                },
                //MsUsername = allocation.Username,
                MessageIntegrity = new MessageIntegrity(),

                MsSequenceNumber = new MsSequenceNumber()
                {
                    ConnectionId = allocation.ConnectionId,
                    SequenceNumber = sequenceNumber,//allocation.SequenceNumber,
                },
            });
        }
コード例 #18
0
 internal ServerInfoEventArgs(ServerEndPoint serverEndPoint, string api, string function, uint error)
     : base(serverEndPoint)
 {
     Error = Format(api, function, error);
 }
コード例 #19
0
ファイル: AllocationsPool.cs プロジェクト: vf1/turnserver
        public Allocation Get(ServerEndPoint allocated)
        {
            Allocation allocation = null;

            lock (syncRoot)
            {
                if (byAllocated.TryGetValue(allocated, out allocation) == false)
                    byReal.TryGetValue(allocated, out allocation);
            }

            return allocation != null && allocation.IsValid() ? allocation : null;
        }
コード例 #20
0
ファイル: TurnServer.cs プロジェクト: vf1/turnserver
        private TurnMessage ProcessAllocateRequest(ref Allocation allocation, TurnMessage request, ServerEndPoint local, IPEndPoint remote)
        {
            uint sequenceNumber = (request.MsSequenceNumber != null) ? request.MsSequenceNumber.SequenceNumber : 0;

            {
                uint lifetime = (request.Lifetime != null) ? ((request.Lifetime.Value > MaxLifetime.Seconds) ? MaxLifetime.Seconds : request.Lifetime.Value) : DefaultLifetime.Seconds;

                if (allocation != null)
                {
                    allocation.Lifetime = lifetime;

                    if (lifetime == 0)
                        logger.WriteInformation(string.Format("Update Allocation: {2} seconds {0} <--> {1}", allocation.Alocated.ToString(), allocation.Reflexive.ToString(), lifetime));
                }
                else
                {
                    if (lifetime <= 0)
                        throw new TurnServerException(ErrorCode.NoBinding);

                    ProtocolPort pp = new ProtocolPort() { Protocol = local.Protocol, };
                    if (peerServer.Bind(ref pp) != SocketError.Success)
                        throw new TurnServerException(ErrorCode.ServerError);

                    allocation = new Allocation()
                    {
                        TransactionId = request.TransactionId,
                        ConnectionId = ConnectionIdGenerator.Generate(local, remote),

                        Local = local,
                        Alocated = new ServerEndPoint(pp, PublicIp),
                        Real = new ServerEndPoint(pp, RealIp),
                        Reflexive = new IPEndPoint(remote.Address, remote.Port),

                        Lifetime = lifetime,
                    };

                    allocations.Replace(allocation);

                    logger.WriteInformation(string.Format("Allocated: {0} <--> {1} for {2} seconds", allocation.Alocated.ToString(), allocation.Reflexive.ToString(), allocation.Lifetime));
                }
            }

            return new TurnMessage()
            {
                IsAttributePaddingDisabled = true,
                MessageType = MessageType.AllocateResponse,
                TransactionId = request.TransactionId,

                MagicCookie = new MagicCookie(),

                MappedAddress = new MappedAddress()
                {
                    IpAddress = allocation.Alocated.Address,
                    Port = (UInt16)allocation.Alocated.Port,
                },

                Lifetime = new Lifetime() { Value = allocation.Lifetime, },
                Bandwidth = new Bandwidth() { Value = 750, },

                XorMappedAddress = new XorMappedAddress(TurnMessageRfc.MsTurn)
                {
                    IpAddress = remote.Address,
                    Port = (UInt16)remote.Port,
                },

                Realm = new Realm(TurnMessageRfc.MsTurn)
                {
                    Ignore = true,
                    Value = Authentificater.Realm,
                },
                MsUsername = new MsUsername()
                {
                    Ignore = true,
                    Value = request.MsUsername.Value,
                },
                //MsUsername = allocation.Username,
                MessageIntegrity = new MessageIntegrity(),

                MsSequenceNumber = new MsSequenceNumber()
                {
                    ConnectionId = allocation.ConnectionId,
                    SequenceNumber = sequenceNumber,//allocation.SequenceNumber,
                },
            };
        }
コード例 #21
0
ファイル: AllocationsPool.cs プロジェクト: vf1/turnserver
        public Allocation GetByPeer(ServerEndPoint local, IPEndPoint remote)
        {
            Allocation allocation = null;

            lock (syncRoot)
                byKey.TryGetValue(GetKey(local, remote), out allocation);

            return allocation != null && allocation.IsValid() ? allocation : null;
        }
コード例 #22
0
            public ServerCallStub(ServerEndPoint endPoint)
            {
                Assert(endPoint != null);

                _endPoint = endPoint;
            }
コード例 #23
0
ファイル: AllocationsPool.cs プロジェクト: vf1/turnserver
 private string GetKey(ServerEndPoint local, IPEndPoint remote)
 {
     return local.ToString() + @"|" + remote.ToString();
 }
コード例 #24
0
 public InProcServerTransport(InProcBinding binding, ServerEndPoint serverEndpoint) : base(binding, serverEndpoint)
 {
     Node = serverEndpoint.Node;
 }
コード例 #25
0
ファイル: ServerHandler.cs プロジェクト: sergey-msu/nfx
            public serverImplementer(ServerHandler handler, ServerEndPoint sep, Type contract)
            {
                Handler = handler;
                ServerEndPoint = sep;
                Contract = contract;
                   
                var implementers = sep.ContractServers.Where(ts => contract.IsAssignableFrom(ts)).ToArray();

                if (implementers.Length==0)
                throw new ServerContractException(string.Format(StringConsts.GLUE_ENDPOINT_CONTRACT_NOT_IMPLEMENTED_ERROR, sep.Name, contract.FullName));

                if (implementers.Length>1)
                {
                      handler.WriteLog(LogSrc.Server, 
                                       MessageType.Warning,  
                                       string.Format(StringConsts.GLUE_ENDPOINT_CONTRACT_MANY_SERVERS_WARNING, contract.FullName, sep.Name),
                                       from: "serverImplementer"); 
                }

                Implementation = implementers[0];

                //pre-alloc Contract/Implementation method infos
                var intfMapping = Implementation.GetInterfaceMap(Contract);
                foreach(var miContract in Contract.GetMethods())
                {
                  var mspec = new MethodSpec(miContract);
                  var miImpl = intfMapping.TargetMethods.FirstOrDefault( tmi => new MethodSpec(tmi).Equals( mspec ));
                  if (miImpl==null)
                    throw new ServerContractException(StringConsts.GLUE_ENDPOINT_CONTRACT_INTF_MAPPING_ERROR.Args( sep.Name, 
                                                                                                                   contract.FullName,
                                                                                                                   miContract.Name,
                                                                                                                   Implementation.FullName));
                  var fBody = getFBody(miContract);
                  methodMap.Add(mspec, new mapping(miContract, miImpl, fBody));//todo DODELAT Functor!
                }

                var lifeCycle = Contract.GetCustomAttributes(typeof(LifeCycleAttribute), false).FirstOrDefault() as LifeCycleAttribute;
                if (lifeCycle!=null)
                {
                    InstanceMode = lifeCycle.Mode;
                    InstanceTimeoutMs = lifeCycle.TimeoutMs;
                }

                if (InstanceTimeoutMs==0) InstanceTimeoutMs = DEFAULT_INSTANCE_TIMEOUT_MS;

                ThreadSafe = Attribute.IsDefined(Implementation, typeof(ThreadSafeAttribute), false);

                AuthenticationSupport =  Attribute.IsDefined(Contract, typeof(AuthenticationSupportAttribute), false);

                SupportsGlueCtor = Implementation.GetConstructor(ServerHandler.GLUE_CTOR_SIGNATURE) != null;


            }
コード例 #26
0
 public void UnregisterServerEndpoint(ServerEndPoint ep)
 {
     m_Servers.Unregister(ep);
 }
コード例 #27
0
ファイル: ServerHandler.cs プロジェクト: sergey-msu/nfx
 private serverImplementer getServerImplementer(ServerEndPoint sep, Type contract)
 {
   serverImplementer server;
   if (sep.m_ContractImplementers.TryGetValue(contract, out server)) return server;
  
   server = new serverImplementer(this, sep, contract); //throws
   sep.m_ContractImplementers.TryAdd(contract, server); 
   return server;
 }
コード例 #28
0
ファイル: JokeInspectors.cs プロジェクト: itadapter/nfx
 public ResponseMsg ServerReturnResponse(ServerEndPoint endpoint, RequestMsg request, ResponseMsg response)
 {
     response.Headers.Add( new TextInfoHeader{ Text="Response generated at " + App.LocalizedTime.ToString(), Info = "Serve Node: " + endpoint.Node } );
       return response;
 }
コード例 #29
0
ファイル: GlueService.cs プロジェクト: sergey-msu/nfx
 public void RegisterServerEndpoint(ServerEndPoint ep)
 {
     if (!m_Servers.Register(ep))
         throw new GlueException(StringConsts.GLUE_DUPLICATE_NAMED_INSTANCE_ERROR +
             "ServerEndPoint = " + ep.Name);
 }
コード例 #30
0
 public SingleBlockEnumerable(RedisBase redis, ServerEndPoint server,
                              Task <T[]> pending, int pageOffset) : base(redis, server, 0, int.MaxValue, 0, pageOffset, default)
 {
     _pending = pending;
 }
コード例 #31
0
ファイル: GlueService.cs プロジェクト: sergey-msu/nfx
 public void UnregisterServerEndpoint(ServerEndPoint ep)
 {
     m_Servers.Unregister(ep);
 }
コード例 #32
0
ファイル: MpxBinding.cs プロジェクト: sergey-msu/nfx
          protected internal override ServerTransport OpenServerEndpoint(ServerEndPoint epoint)
          {
              var cfg = ConfigNode.NavigateSection(CONFIG_SERVER_TRANSPORT_SECTION);
              if (!cfg.Exists) cfg = ConfigNode;

              var ipep = MpxBinding.ToIPEndPoint(epoint.Node);
              var transport = new MpxServerTransport(this, epoint, ipep.Address, ipep.Port);
              transport.Configure(cfg);
              transport.Start();

              return transport;
          }
コード例 #33
0
 public SocketClient(ServerEndPoint specifiedEndPoint, ILoggerFactory loggerFactory)
 {
     ServerEndPoint = specifiedEndPoint;
     _loggerFactory = loggerFactory;
 }
コード例 #34
0
 internal ServerInfoEventArgs(ServerEndPoint serverEndPoint, Exception error)
     : base(serverEndPoint)
 {
     Exception = error;
 }
コード例 #35
0
ファイル: InProcBinding.cs プロジェクト: mjaric/nfx
 protected internal override ServerTransport OpenServerEndpoint(ServerEndPoint epoint)
 {
     return(new InProcServerTransport(this, epoint));
 }
コード例 #36
0
 internal ServerInfoEventArgs(ServerEndPoint serverEndPoint, string error)
     : base(serverEndPoint)
 {
     Error = error;
 }
コード例 #37
0
ファイル: TurnServer.cs プロジェクト: vf1/turnserver
        private void GetBuffer(ServerEndPoint local, IPEndPoint remote, int length, out ServerAsyncEventArgs e, out int offset)
        {
            int headerLength = (local.Protocol == ServerProtocol.Tcp) ? TcpFramingHeader.TcpFramingHeaderLength : 0;

            e = EventArgsManager.Get();

            e.ConnectionId = ServerAsyncEventArgs.AnyConnectionId;
            e.LocalEndPoint = local;
            e.RemoteEndPoint = remote;
            e.Count = headerLength + length;
            e.AllocateBuffer();

            if (headerLength > 0)
                TcpFramingHeader.GetBytes(e.Buffer, e.Offset, TcpFrameType.ControlMessage, length);

            offset = e.Offset + headerLength;
        }
コード例 #38
0
 internal ServerInfoEventArgs(ServerEndPoint serverEndPoint, SocketError error)
     : base(serverEndPoint)
 {
     SocketError = error;
 }
コード例 #39
0
ファイル: AjaxWebsocket.cs プロジェクト: KhaledSMQ/SipServer
 public void StoreAddresses(Connection connection)
 {
     connectionId   = connection.Id;
     localEndPoint  = connection.LocalEndPoint;
     remoteEndPoint = connection.RemoteEndPoint;
 }