Ejemplo n.º 1
0
        public bool Open(object arg)
        {
            try
            {
                _headerLogRecord = Ashley.CreateHeader(AshleyVersion.V1_1, NetDebugLogTransmissionManager.ID_N1,
                                                       (ulong)BiuNetDebugAction.LogRecord, AshleyFlag.Security);
                _headerLogRecord.Security.Alg = AshleySecurityAlg.P4S;


                _server.CC = new ConnectionCreation()
                {
                    Trait            = SocketTrait.Normal,
                    Type             = SocketType.IPv4TCP,
                    Protocol         = _ashley,
                    Handler          = BiuIoManager.Instance.Handlers[NetDebugLogTransmissionManager.Handler_DebugN1].Handler,
                    EndPoint         = this.DebugN1EndPoint,
                    SecurityProvider = _securityProvider
                };

                TransmissionRouter.Instance.AddHop(this);

                return(_server.Create(true));
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public bool Initialize()
        {
            try
            {
                TransmissionManager.StartUpWSA();

                _securityProvider = new SecurityProvider();
                _securityProvider.NewItem();

                _ashley = Ashley.CreateEntityProtocol();
                _server = new AppServer();

                BiuIoManager.Instance.NewHandler(NetDebugLogTransmissionManager.Handler_DebugN1, NetDebugLogTransmissionManager.ID_N1, 0, 0);
                //BiuIoManager.Instance.NewHandler(NetDebugLogTransmissionManager.Handler_DebugN1_Data, NetDebugLogTransmissionManager.ID_N1, 0, 0);

                _actionTable.Add(NetDebugLogTransmissionManager.Handler_DebugN1)
                .AddRow((ulong)BiuAction.Accept, IOOperation.Read)
                .AddRow((ulong)BiuAction.PublicKey, DebugN1_PublicKey);

                return(true);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public IOOperation DispatchIo(string name, ulong action, Peer peer, ref bool handled)
        {
            IOOperation operation = IOOperation.Read;
            Ashley      ashley    = peer.Protocol;

            try
            {
                bool bHandled = false;
                if (null != this.MainHop)
                {
                    operation = this.MainHop.HopIo(name, action, peer, ref handled);
                    if (handled)
                    {
                        bHandled = true;
                    }
                }

                foreach (var item in _dictHop.Values)
                {
                    ITransmissionHop hop;
                    if (!item.TryGetTarget(out hop))
                    {
                        continue;
                    }

                    operation = hop.HopIo(name, action, peer, ref handled);
                    if (handled)
                    {
                        bHandled = true;
                    }
                }

                handled = bHandled;

                return(operation);
            }
            catch
            {
                throw;
            }
            finally
            {
                ashley.KillObject();
            }
        }
Ejemplo n.º 4
0
        public void Uninitialize()
        {
            try
            {
                BiuIoManager.Instance.RemoveHandler(NetDebugLogTransmissionManager.Handler_DebugN1);

                _server = null;

                _ashley.Dispose();
                _ashley = null;

                _securityProvider.Dispose();
                _securityProvider = null;

                TransmissionManager.CleanUpWSA();
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        private IOOperation DebugN1_PublicKey(BiuIoHopArgs arg)
        {
            var peer = arg.Peer;

            try
            {
                RawData raw = new RawData();
                if (!peer.Protocol.GetObjKept <RawData>(ref raw))
                {
                    return(IOOperation.None);
                }

                AshleyHeader header = Ashley.CreateHeader(AshleyVersion.V1_1, NetDebugLogTransmissionManager.ID_N1,
                                                          (ulong)BiuAction.Ack, AshleyFlag.None);

                Ack ack = new Ack()
                {
                    AckAction = (ulong)BiuAction.PublicKey,
                    AckResult = (uint)BiuAckResult.OK
                };

                if (null == peer.SecurityContext)
                {
                    ack.AckResult = (uint)BiuAckResult.Unsupported;
                }
                else if (!peer.SecurityContext.ChangeRemoateKey(raw.Raw.ToArray()))
                {
                    ack.AckResult = (uint)BiuAckResult.Failed;
                }

                peer.Return(ack, header);

                return(IOOperation.Continue);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 6
0
        void DebugN1_Accepted(Peer peer, BoolArg arg)
        {
            arg.RetuenValue = true;

            if (null != peer.SecurityContext)
            {
                RawData raw = new RawData()
                {
                    Raw = peer.SecurityContext.ExportKey().ToList()
                };

                AshleyHeader header = Ashley.CreateHeader(AshleyVersion.V1_1, NetDebugLogTransmissionManager.ID_N1,
                                                          (ulong)BiuAction.PublicKey, AshleyFlag.None);
                peer.Send(raw, header);
            }

            try
            {
                UserLogin(peer);
            }
            catch
            {
            }
        }