Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (542)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (604)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Need a way to discover if i'm behind a proxy  (Read 2447 times)
0 Members and 1 Guest are viewing this topic.
Offline i30817

Junior Devvie





« Posted 2009-08-11 20:18:40 »

To popup a dialog so users can configure it. I already have a popup and it works, but the method i use, (querying by http if google is reachable) besides being lame and slow, also can't distinguish between no connection and a proxy firewall, so the dialog appears when it shouldn't.

Any way to test this?
Offline JAW

Senior Devvie


Medals: 2



« Reply #1 - Posted 2009-08-25 21:31:15 »

Did you google it? Sounds like a typical problem. Maybe a HTTP response contains some info in the header from a proxy, when one is active. I cannot look for more details myself right now, I have no more time. But this is what I would try, to find out if a proxy somehow gives a sign in its HTTP response.

-JAW
Offline i30817

Junior Devvie





« Reply #2 - Posted 2009-08-27 18:11:49 »

I googled and googled, but this request is too close to "autodetect proxy setting" that is not the same thing - i'm just detecting if i need to query the user for the proxy setting.

I fixed most of it, by finding a way to detect networks in java, now it will not ask for proxy setting in a offline computer. It will still request them uselessly if google is down though, and that is sad... I don't want to test more sites, that just seems a waste of time. Do you know how to test for the principal DNS servers? Those should be fast.
Your idea of the http response seems very fine, but i didn't find a way to analyze the packets at such a level in pure java i think-

Relevant part of the code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
    /**
     * Probe for a working network, and show a input dialog
     * for proxy config if needed
     */

    private void probeForProxy() {
        try{
        Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
        boolean upAndNotLocal = false;
        while (e.hasMoreElements()){
             NetworkInterface n = e.nextElement();
             if(!n.isLoopback() && n.isUp()){
                 upAndNotLocal = true;
                 break;
             }
        }
       
        if (upAndNotLocal && tryDirectFailBecauseOfProxy("http://www.google.com")) {
            showRequestDialog();
        }
        }catch(IOException e){
            //if getNetworkInterfaces() threw a exception there is
            //NO network, and thus, no need to show the dialog.
            //if there are, proxy for acess to http. If can't connnect
            //then, show dialog.
        }
    }


BTW really strange that a coding site hasn't the code tag as a button.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DzzD
« Reply #3 - Posted 2009-09-14 23:38:53 »

you can try to open an URLConnection (HTTPConnection) to your website and check usingProxy() method

Online cylab

JGO Ninja


Medals: 56



« Reply #4 - Posted 2009-09-15 08:11:19 »

you can try to open an URLConnection (HTTPConnection) to your website and check usingProxy() method
Actually this would only work, if the proxy is already configured, which is the problem the OP is facing.

@OP
I think your solution is as good as it gets. You could also try to search for ways how to get the proxy settings from the OS or from different browsers, but I think if the proxy ist correctly configured in the OS, java should also have the proxy set right straigt away.

Mathias - I Know What [you] Did Last Summer!
Offline DzzD
« Reply #5 - Posted 2009-09-15 08:17:16 »

Actually this would only work, if the proxy is already configured, which is the problem the OP is facing.

@OP
I think your solution is as good as it gets. You could also try to search for ways how to get the proxy settings from the OS or from different browsers, but I think if the proxy ist correctly configured in the OS, java should also have the proxy set right straigt away.

hum.. I guess that if the user reach its website, proxy setting maybe already set properly, no ?

Offline pjt33
« Reply #6 - Posted 2009-09-15 08:38:45 »

I fixed most of it, by finding a way to detect networks in java, now it will not ask for proxy setting in a offline computer. It will still request them uselessly if google is down though, and that is sad... I don't want to test more sites, that just seems a waste of time. Do you know how to test for the principal DNS servers? Those should be fast.
I imagine the principal DNS servers will reject packets on port 80, so they don't help detect a proxy.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Elsealabs (9 views)
2014-12-28 10:39:27

CopyableCougar4 (16 views)
2014-12-28 02:10:29

BurntPizza (20 views)
2014-12-27 22:38:51

Mr.CodeIt (13 views)
2014-12-27 04:03:04

TheDudeFromCI (18 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (93 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!