Jump to content

Yaron

Members
  • Content Count

    275
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Yaron


  1. I believe I figured it out, here's how to show a pop-up dialog with the IP address:

     

    In "Server.Ignition.pas" CreateEngine, I added :

        FEngine.OnBeforeHandleRequest :=
          function (AEngine: TMARSEngine; AURL: TMARSURL; ARequest: TWebRequest; AResponse: TWebResponse; var Handled: Boolean ) : Boolean
          begin
            Result := True;
            ShowMessage(ARequest.RemoteIP);
          end;
    

    And also had to add "MARS.Core.URL, Web.HTTPApp" to the "uses" section.

     


  2. 48 minutes ago, pietrt said:

    I do it in the TMARShttpServerIndy.OnConnect, that is a TIdServerThreadEvent = procedure(AContext: TIdContext) of object;

    Client's Ip address: AContext.Binding.PeerIP

     

    Pieter

    I'm using ISAPI, not Indy for the server-side code, so I can't get the IP the way you suggest.

     

    I'm hoping for a more generic approach that will work in all MARS output modes (stand-alone application EXE, ISAPI, etc)


  3. As part of a service I'm writing using mars, I'm exposing a sign-up page for users to sign up to the service.

    However, I want to prevent attacks on the service by bots and possibly detect multiple accidental clicks on the submit button.

     

    Right now the way I'm considering doing this is by keeping a list of IP addresses and verifying that only one sign-up per time-frame is allowed.

     

    I have two questions:
    1. Using MARS, how do I read the client's IP address?

    2. Are there other recommendations for defending mars?

     

    • Thanks 1

  4. I'm not sure you can really disable hardware acceleration as FMX for Android relies on the GPU canvas which is OpenGL hardware accelerated.

     

    But seriously though, OpenGL hardware acceleration has been built into smartphones for well over 5 years, so even old phones have it.

     

    Not to mention you would have to use Delphi v10.2 or older to even support versions of Android older than v5 and you won't be able to upload these apps into the app store because they don't support the Android SDK google is requiring to upload new apps to the store (not to mention the 64bit issue).


  5. I'm trying to create a smooth UI experience by loading a webpage in the background and only showing it later on when a user clicks a button in the app.

     

    To load the webpage I'm using:

    TWebBrowser.LoadFromStrings('<html><body style="background-color:#2f2f2f"></body></html>','');

     

    However, it seems that the webpage is not rendered if TWebBrowser is not visible, resulting in a white page showing up instead of my HTML.

     

    So I figured if this is a limitation, I'll just have TWebBrowser visible and cover it by a TRectangle, however that didn't work either as it seems (at least under windows) that the TWebBrowser control is always on-top.

    I also tried to placing the TWebBrowser control into a TPanel to see if that would allow it to be overlaid by other components, but it didn't make a difference.

    Finally I tried utilizing the "OnDidFinishLoad" event, but it didn't help either, a white page would still flicker for a split second before the page was rendered.

     

    Is there some other trick I haven't thought of that will allow me to first render the page in the background and only then show it so I don't have a flashing white box appear for a second before the page renders?

     


  6. 17 minutes ago, Dalija Prasnikar said:

    There is ongoing beta open for people on update subscription. You can participate and use it for publishing 64bit app on Play Store.

     

    https://community.idera.com/developer-tools/b/blog/posts/addressing-ios-13-and-android-64-bit-with-rad-studio 

    I'm aware of the beta, but like I wrote above, I would like to avoid wasting an entire work day installing & configuring a beta version of Delphi if the final release is just around the corner.

    And if it's not just around the corner then my subscription might end and I'll be stuck with a beta version.

     

    Like I wrote, no good options for me to plan for when no release information is forthcoming.

    • Sad 1

  7. Just got word from google that my 32bit project that was in beta would not be approved for the extension, not sure if it was because it was in beta or if I requested the extension too late.

     

    It's a shame that Embarcadero couldn't get the extension accepted all the way to the actual release date of v10.3.3.

     

    Now I'm stuck between a choice of two bad options:

    1. Waste hours installing a beta version.

    2. Wait an unknown period of time with the hope that a release will be out soon.

     

    All this while the clock is ticking on my subscription and without the ability to release anything for Android.

     

    • Sad 1

  8. Even though I have a subscription, I did not receive an invitation and now I have a quick Android project that I wanted to beta-test through the play store and... impossible.

     

    While this is a small hurdle now, there are projects that are due in a month or two that I simple can't release, it doesn't seem like google is accepting exemptions on new projects.

     

    • Sad 1

  9. I'm doing something similar and encountered some of the same issues.

     

    1. Since ISAPI is a DLL, did you add "IsMultiThread := True;" to let the memory manager know this DLL is using multiple threads (otherwise you can get random-seeming crashes)?

    2. I'm not sure your logging code is thread safe, it might be useful to add a critical section to your log writes.

    3. There should be no problem using global read-only variables across threads as long as these variables are not classes that do things in the background.

    4. If you're accessing a database, make sure to use connection pooling.

    5. Do you get a ~90sec freeze when trying to stop the application pool? Make sure to terminate the ISAPI dll correctly.

     

    This is my original thread in which the nice people of this forum helped me identify some of these issues:

     


  10. 15 minutes ago, TomDevOps said:

    Now I don't get this - why do you want to login this way? Why you do not want to use REST and login that way? I do not know if WebView allow to execute your own JavaScript - if so, you could pass credentials to the form this way and then call submit, but again, I would not do this way.

     

    I try to understand your architecture and design choices, can you elaborate, please?

     

    I believe I might be able login by using LoadFromStrings() to feed the html form and auto-activating JS to TWebBrowser with the form's action set to my login url, which will bypass the need to actually modify the html content.


  11. 3 minutes ago, TomDevOps said:

    I think I know what you want to achieve, I understand that you want to have HTML/CSS/JS to avoid designing for each platform, so make everything in React, then your web-app and mobile-app can share HTML/CSS/JS stuff 🙂 

     

    If React is not an option, then use REST for communication and WebView for displaying the results only, this is what I did for one of the app.

    I have already written a Delphi ISAPI DLL that hooks into the microsoft IIS server and outputs HTML/JS/CSS.  That part is done and working well in all browsers.

     

    Now, for convenience  I would like to create a separate Android app (using Delphi) that uses the TWebBrowser component to open the web server's URL and automatically log-in by filling in the html form fields (user/pass) and press the "submit" button.

    With this second part I'm struggling since I don't know how to get to the HTML content displayed by the TWebBrowser component and how to trigger the form's "submit" button.


  12. 21 minutes ago, Remy Lebeau said:

    A better solution would be to forgo the TWebBrowser frontend altogether and redesign your web app to accept REST requests on the backend server to do the work you need.  Then use a standard UI on the client side to display the results as needed.

    You would have to check if the underlying platform browsers provide any APIs to automate them in code.  VCL's TWebBrowser is a wrapper for Internet Explorer and exposes access to its DOM API.  FMX's TWebBrowser does not expose similar functionality.

    The Delphi back-end is already rest-based, but the whole point of using HTML/JS for the front-end is to avoid having to design the UI for each platform (web/desktop/android) and rely on CSS to style the UI for every device without having to deal with device resolution/scale within Delphi code.

     


  13. I wrote a web-facing application that uses a combination of javascript/css/html for the front-end and Delphi for the back-end.

    I decided to create a simple Android app that would wrap the web application using a TWebBrowser control that automatically navigates to the web application's URL.

     

    The web application's requires a login and once logged in, a token is generated sever-side and then embedded into the html of subsequent server requests for future authentication.

     

    For security reasons, I do not want to store the code used to create the token within the Android app, so the easiest way for me to perform the login would be to automatically fill in the web form fields and simulate a "submit" action.

     

    Searching the web, I only found examples of how to do this using the WinAPI version of TWebBrowser, but I'm trying to write something that will work on Android and possibly iOS, any ideas?


  14. Looks like I'm encountering an IIS issue when using this scheme.

    In the ISAPI's DLL's finalization code I call "FDManager.Close" and in IIS, when stopping the application pool associated with the DLL it can take ~60 seconds before I can restart the pool, any ideas?

     

    This is the error I get:

    Quote

     

    ---------------------------
    Cannot Start Application Pool
    ---------------------------
    There was an error while performing this operation.

     

    Details:

    The service cannot accept control messages at this time. (Exception from HRESULT: 0x80070425)

     

     

     

    When checking my logs, It doesn't seem to exit cleanly (the debug message that the "DB Closed" does not show up in the log), but there doesn't seem to be an exception, here's the code I use:

      Try FDManager.Close; Except
        on E : Exception do {$IFDEF TRACEDEBUG}AddDebugEntry('Exception disconnecting from DB : '+E.Message){$ENDIF};
      End;
      {$IFDEF TRACEDEBUG}AddDebugEntry('DB Closed');{$ENDIF}

     

    When I run the same code locally as an EXE that handles the HTTP requests, there are no issues, any ideas?

     

×