comparison src/net/sourceforge/jsocks/CProxy.java @ 354:3c16508419fe

update jsocks to 2011-03-19
author Carl Byington <carl@five-ten-sg.com>
date Fri, 01 Aug 2014 11:39:46 -0700
parents 205ee2873330
children
comparison
equal deleted inserted replaced
353:20412de44c06 354:3c16508419fe
32 protected static CProxy defaultProxy = null; 32 protected static CProxy defaultProxy = null;
33 33
34 //Constructors 34 //Constructors
35 //==================== 35 //====================
36 CProxy(CProxy chainProxy, 36 CProxy(CProxy chainProxy,
37 String proxyHost,int proxyPort)throws UnknownHostException{ 37 String proxyHost,int proxyPort)throws UnknownHostException{
38 this.chainProxy = chainProxy; 38 this.chainProxy = chainProxy;
39 this.proxyHost = proxyHost; 39 this.proxyHost = proxyHost;
40 40
41 if(chainProxy == null) 41 if(chainProxy == null)
42 this.proxyIP = InetAddress.getByName(proxyHost); 42 this.proxyIP = InetAddress.getByName(proxyHost);
43 43
44 this.proxyPort = proxyPort; 44 this.proxyPort = proxyPort;
45 } 45 }
46 46
47 47
48 CProxy(String proxyHost,int proxyPort)throws UnknownHostException{ 48 CProxy(String proxyHost,int proxyPort)throws UnknownHostException{
49 this(null,proxyHost,proxyPort); 49 this(null,proxyHost,proxyPort);
50 } 50 }
51 51
52 CProxy(CProxy chainProxy,InetAddress proxyIP,int proxyPort){ 52 CProxy(CProxy chainProxy,InetAddress proxyIP,int proxyPort){
145 @param chainProxy CProxy to use to connect to this proxy. 145 @param chainProxy CProxy to use to connect to this proxy.
146 */ 146 */
147 public void setChainProxy(CProxy chainProxy){ 147 public void setChainProxy(CProxy chainProxy){
148 this.chainProxy = chainProxy; 148 this.chainProxy = chainProxy;
149 } 149 }
150 150
151 /** 151 /**
152 Get proxy which is used to connect to this proxy. 152 Get proxy which is used to connect to this proxy.
153 @return CProxy which is used to connect to this proxy, or null 153 @return CProxy which is used to connect to this proxy, or null
154 if proxy is to be contacted directly. 154 if proxy is to be contacted directly.
155 */ 155 */
307 protected abstract ProxyMessage formMessage(int cmd,String host,int port) 307 protected abstract ProxyMessage formMessage(int cmd,String host,int port)
308 throws UnknownHostException; 308 throws UnknownHostException;
309 protected abstract ProxyMessage formMessage(InputStream in) 309 protected abstract ProxyMessage formMessage(InputStream in)
310 throws SocksException, 310 throws SocksException,
311 IOException; 311 IOException;
312 312
313 313
314 protected ProxyMessage connect(InetAddress ip,int port) 314 protected ProxyMessage connect(InetAddress ip,int port)
315 throws SocksException{ 315 throws SocksException{
316 try{ 316 try{
317 startSession(); 317 startSession();
425 protected void sendMsg(ProxyMessage msg)throws SocksException, 425 protected void sendMsg(ProxyMessage msg)throws SocksException,
426 IOException{ 426 IOException{
427 msg.write(out); 427 msg.write(out);
428 } 428 }
429 429
430 /** 430 /**
431 * Reads the reply from the SOCKS server 431 * Reads the reply from the SOCKS server
432 */ 432 */
433 protected ProxyMessage readMsg()throws SocksException, 433 protected ProxyMessage readMsg()throws SocksException,
434 IOException{ 434 IOException{
435 return formMessage(in); 435 return formMessage(in);
479 479
480 public static final int SOCKS_DIRECT_FAILED =7<<16; 480 public static final int SOCKS_DIRECT_FAILED =7<<16;
481 public static final int SOCKS_METHOD_NOTSUPPORTED =8<<16; 481 public static final int SOCKS_METHOD_NOTSUPPORTED =8<<16;
482 482
483 483
484 static final int SOCKS_CMD_CONNECT =0x1; 484 public static final int SOCKS_CMD_CONNECT =0x1;
485 static final int SOCKS_CMD_BIND =0x2; 485 static final int SOCKS_CMD_BIND =0x2;
486 static final int SOCKS_CMD_UDP_ASSOCIATE =0x3; 486 static final int SOCKS_CMD_UDP_ASSOCIATE =0x3;
487 487
488 } 488 }