Tech Off Thread

8 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

request.getRemoteAddr() and IPv6

Back to Forum: Tech Off
  • User profile image
    cheong

    Hello,

        I need to get some website using ancient Java applet (targets JRE 1.2) and accepts address via request.getRemoteAddr() working.

        But when I'm accessing the page in localhost for debugging, it always returns "::1" for the request.getRemoteAddr() and breaks the Java applet.

        Is there any replacement function I can use that can return IPv4 address with only?

    Regards,
    Lau Lei Cheong

    Recent Achievement unlocked: Code Avenger Tier 4/6: You see dead program. A lot!
    Last modified
  • User profile image
    W3bbo

    Ultimately, no, because what would happen if you were running on a system that didn't use IPv4? It would have to return an IPv6 address.

    You'll have to modify the program to accept both IPv4 and IPv6 addresses.

  • User profile image
    Sven Groot

    What happens if you access the page specifically via http://127.0.0.1, rather than http://localhost? That should prevent the browser from using IPv6 to connect.

  • User profile image
    cheong

    @W3bbo:It's an old applet that we don't have source to modify, a blackbox that we don't know what it does inside, and the client specifically require us to keep it.

    The applet contains code that breaks if it accepts IPv6 address, As the client confirms they'll accept the applet to break when it see IPv6 address (pass empty string to it appears to be fine), our responsibility is to feed it with just IPv4.

    @Sven: Tried and it does not help. The said function still returns "::1" on this case.

    I know that there's a JVM optional to set preference on IPv4, but we want something that can be deployed with a WAR file...

    Recent Achievement unlocked: Code Avenger Tier 4/6: You see dead program. A lot!
    Last modified
  • User profile image
    W3bbo

    , cheong wrote

    @W3bbo:It's an old applet that we don't have source to modify, a blackbox that we don't know what it does inside, and the client specifically require us to keep it.

    The applet contains code that breaks if it accepts IPv6 address, As the client confirms they'll accept the applet to break when it see IPv6 address (pass empty string to it appears to be fine), our responsibility is to feed it with just IPv4.

    Like CIL assemblies, Java classes can be disassembled back into readable Java code. Have you tried going that route?

  • User profile image
    cheong

    @W3bbo: It's not in my position to determine that. Moreover, the applet is neither owned by my company nor the owner of said web application. So we have no right to alter it in any way.

    Note that it's not uncommon for websites of government or other bureaucratic entities to host applets from other departments/organizations.

    Recent Achievement unlocked: Code Avenger Tier 4/6: You see dead program. A lot!
    Last modified
  • User profile image
    joechung

    Edit your HOSTS file not to use the ::1 IPv6 alias for localhost.

    Edit: Ah never mind, sorry. I saw your request about needing the solution to be deployable after posting.

  • User profile image
    Matthew van Eerde

    You could disable IPv6 on the server.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.