Ejemplo n.º 1
0
        private static void EmitLoad(AILEmitterCtx Context, AccessType AccType, bool Pair)
        {
            AOpCodeMemEx Op = (AOpCodeMemEx)Context.CurrOp;

            if (AccType.HasFlag(AccessType.Ordered))
            {
                EmitBarrier(Context);
            }

            if (AccType.HasFlag(AccessType.Exclusive))
            {
                EmitMemoryCall(Context, nameof(AMemory.SetExclusive), Op.Rn);
            }

            Context.EmitLdarg(ATranslatedSub.MemoryArgIdx);
            Context.EmitLdint(Op.Rn);

            EmitReadZxCall(Context, Op.Size);

            Context.EmitStintzr(Op.Rt);

            if (Pair)
            {
                Context.EmitLdarg(ATranslatedSub.MemoryArgIdx);
                Context.EmitLdint(Op.Rn);
                Context.EmitLdc_I(8 << Op.Size);

                Context.Emit(OpCodes.Add);

                EmitReadZxCall(Context, Op.Size);

                Context.EmitStintzr(Op.Rt2);
            }
        }
Ejemplo n.º 2
0
        private static void EmitStore(AILEmitterCtx Context, AccessType AccType, bool Pair)
        {
            AOpCodeMemEx Op = (AOpCodeMemEx)Context.CurrOp;

            if (AccType.HasFlag(AccessType.Ordered))
            {
                EmitBarrier(Context);
            }

            AILLabel LblEx  = new AILLabel();
            AILLabel LblEnd = new AILLabel();

            if (AccType.HasFlag(AccessType.Exclusive))
            {
                EmitMemoryCall(Context, nameof(AMemory.TestExclusive), Op.Rn);

                Context.Emit(OpCodes.Brtrue_S, LblEx);

                Context.EmitLdc_I8(1);
                Context.EmitStintzr(Op.Rs);

                Context.Emit(OpCodes.Br_S, LblEnd);
            }

            Context.MarkLabel(LblEx);

            Context.EmitLdarg(ATranslatedSub.MemoryArgIdx);
            Context.EmitLdint(Op.Rn);
            Context.EmitLdintzr(Op.Rt);

            EmitWriteCall(Context, Op.Size);

            if (Pair)
            {
                Context.EmitLdarg(ATranslatedSub.MemoryArgIdx);
                Context.EmitLdint(Op.Rn);
                Context.EmitLdc_I(8 << Op.Size);

                Context.Emit(OpCodes.Add);

                Context.EmitLdintzr(Op.Rt2);

                EmitWriteCall(Context, Op.Size);
            }

            if (AccType.HasFlag(AccessType.Exclusive))
            {
                Context.EmitLdc_I8(0);
                Context.EmitStintzr(Op.Rs);

                EmitMemoryCall(Context, nameof(AMemory.ClearExclusiveForStore));
            }

            Context.MarkLabel(LblEnd);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Determines if the server is accessible through the selected networks
        /// </summary>
        /// <param name="access">The access scheme</param>
        /// <returns>True if the server was accessible through all the specified access networks</returns>
        public async Task <bool> IsAccessible(AccessType access)
        {
            bool accessFailed = false;

            if (access.HasFlag(AccessType.Internet))
            {
                Logging.OnLogMessage("Checking access from the internet", MessageType.Info);

                if (await ServerIsListening(Settings.Instance.Internet, Settings.Instance.Port))
                {
                    Logging.OnLogMessage("Access is possible through the internet", MessageType.Info);
                }
                else
                {
                    accessFailed = true;
                }
            }

            if (access.HasFlag(AccessType.LAN))
            {
                Logging.OnLogMessage("Checking access from the local network", MessageType.Info);

                if (await ServerIsListening(Settings.Instance.LAN, Settings.Instance.Port))
                {
                    Logging.OnLogMessage("Access is possible through the local network", MessageType.Info);
                }
                else
                {
                    accessFailed = true;
                }
            }

            if (access.HasFlag(AccessType.Loopback))
            {
                Logging.OnLogMessage("Checking access via loopback", MessageType.Info);

                if (await ServerIsListening(Settings.Instance.Loopback, Settings.Instance.Port))
                {
                    Logging.OnLogMessage("Access is possible through loopback", MessageType.Info);
                }
                else
                {
                    accessFailed = true;
                }
            }

            return(!accessFailed);
        }
Ejemplo n.º 4
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (AccessType.HasFlag(ActionAccessType.Public))
            {
                return;
            }

            if (AccessType.HasFlag(ActionAccessType.NotAuthenticatedOnly) && !SessionModel.IsAuthenticated)
            {
                return;
            }

            if (AccessType.HasFlag(ActionAccessType.Authenticated) && SessionModel.IsAuthenticated)
            {
                return;
            }

            if (filterContext.HttpContext.Request.IsAjaxRequest())
            {
                filterContext.HttpContext.Response.ContentType = "application/json";
                var javaScriptSerializer = new JavaScriptSerializer();
                filterContext.HttpContext.Response.Write(
                    javaScriptSerializer.Serialize(
                        new
                {
                    redirect =
                        UrlHelper.GenerateUrl("Default", TargetAction ?? "signin", TargetController ?? "auth", AddReturnUrl ?
                                              new RouteValueDictionary(

                                                  new { returnUrl = filterContext.HttpContext.Request.Url.PathAndQuery }) : new RouteValueDictionary(),
                                              RouteTable.Routes, filterContext.RequestContext, false).ToLower()
                }));
            }
            else
            {
                if (AddReturnUrl)
                {
                    filterContext.HttpContext.Response.RedirectToRoute(new
                    {
                        controller = TargetController ?? "auth",
                        action     = TargetAction ?? "signin",
                        returnUrl  = filterContext.HttpContext.Request.Url.PathAndQuery
                    });
                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new
                    {
                        controller = TargetController ?? "auth",
                        action     = TargetAction ?? "signin",
                        returnUrl  = filterContext.HttpContext.Request.Url.PathAndQuery
                    }));
                }
                else
                {
                    filterContext.HttpContext.Response.RedirectToRoute(new
                    {
                        controller = TargetController ?? "auth",
                        action     = TargetAction ?? "signin"
                    });
                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new
                    {
                        controller = TargetController ?? "auth",
                        action     = TargetAction ?? "signin"
                    }));
                }
            }


            filterContext.HttpContext.Response.End();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Determines if the server is accessible through the selected networks
        /// </summary>
        /// <param name="access">The access scheme</param>
        /// <returns>True if the server was accessible through all the specified access networks</returns>
        public async Task<bool> IsAccessible(AccessType access)
        {
            bool accessFailed = false;

            if (access.HasFlag(AccessType.Internet))
            {
                Logging.OnLogMessage("Checking access from the internet", MessageType.Info);

                if (await ServerIsListening(Settings.Instance.Internet, Settings.Instance.Port))
                    Logging.OnLogMessage("Access is possible through the internet", MessageType.Info);
                else
                    accessFailed = true;
            }

            if (access.HasFlag(AccessType.LAN))
            {
                Logging.OnLogMessage("Checking access from the local network", MessageType.Info);

                if (await ServerIsListening(Settings.Instance.LAN, Settings.Instance.Port))
                    Logging.OnLogMessage("Access is possible through the local network", MessageType.Info);
                else
                    accessFailed = true;
            }

            if (access.HasFlag(AccessType.Loopback))
            {
                Logging.OnLogMessage("Checking access via loopback", MessageType.Info);

                if (await ServerIsListening(Settings.Instance.Loopback, Settings.Instance.Port))
                    Logging.OnLogMessage("Access is possible through loopback", MessageType.Info);
                else
                    accessFailed = true;
            }

            return !accessFailed;
        }