Direct connection to Internet without Proxy
Is it possible to make a Direct connection to the Internet without using a Proxy.
Consider a case that my Organization has a Proxy and I use the DIRECT option given in the Java Proxy class.
SocketAddress addr = new
InetSocketAddress("webcache.mydomain.com", 8080);
Proxy proxy = new Proxy(Proxy.Type.DIRECT, addr);
If you go by the documentation it st开发者_运维知识库ates DIRECT which represents a direct connection, or absence of proxy.
Which is exactly the way it behaves. When I use this option, I dont have to give any Proxy details and I can access the content from the Internet.
I have three questions
- As per my understanding if an Organization has a Proxy, all network traffic should get routed through the Proxy. No one should be able to access the Network directly ?
- I also noted that if I remove the Proxy details from IE, I can not access the Web :-( How can Java still do it ?
- If in any Organization you can access both with the Proxy and Directly, how does the firewall block certain sites ? How does the firewall even work ?
Thanks in advance.
Proxy proxy = new Proxy(Proxy.Type.DIRECT, addr);
Is not the proper way to create a direct (no proxy) proxy directive. You should do
Proxy proxy = Proxy.NO_PROXY
The internal implementation of the Socket class and the HttpURLConnection checks if proxy == Proxy.NO_PROXY
(note: "==", not "equals()"!).
It does NOT check if proxy.getType() == Proxy.Type.DIRECT
.
2) You might have set the proxy in any system properties. If you are using any IDE, check the proxy setting of the IDE.
Not all Network traffic goes through a Proxy, if your Organization has a Proxy. You can still go ahead and establish a Direct connection to the Internet. Mostly the Organizations will block Direct connections and force you to use Proxies. Some times they might allow you to have a Restricted Direct connection, which allows certain URL's and denies other ones.
精彩评论