All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.eshore.conf.ProxyURL Maven / Gradle / Ivy

There is a newer version: 1.2.8
Show newest version
package com.eshore.conf;


/**
 * 代理URL 解析
 * @author eshore
 *
 */
public class ProxyURL {
	String clientName;//内网代理节点的名称,唯一
	String dest_host;//内网服务的IP或 域名
	int dest_port;//内网服务器的端口
	int export;//公布到外网的端口
	
	public String getClientName() {
		return clientName;
	}
	public void setClientName(String clientName) {
		this.clientName = clientName;
	}
	public String getDest_host() {
		return dest_host;
	}
	public void setDest_host(String dest_host) {
		this.dest_host = dest_host;
	}
	public int getDest_port() {
		return dest_port;
	}
	public void setDest_port(int dest_port) {
		this.dest_port = dest_port;
	}
	public int getExport() {
		return export;
	}
	public void setExport(int export) {
		this.export = export;
	}
	
	static ProxyURL parse(String url){
		ProxyURL u= new ProxyURL();
		String us[] =url.split("[:]");
		if(us.length==3){
			u.dest_host=us[0];
			u.dest_port=Integer.parseInt(us[1]);
			u.export=Integer.parseInt(us[2]);
		}else if(us.length==4){
			u.clientName=us[0];
			u.dest_host=us[1];
			u.dest_port=Integer.parseInt(us[2]);
			u.export=Integer.parseInt(us[3]);
		}
		return u;
	}
	
	static ProxyURL parse(String url,String name){
		ProxyURL u =parse(url);
		u.setClientName(name);
		return u;
	}
	
	public String toString(){
		return clientName+":"+dest_host+":"+dest_port+":"+export;
	}
	
	public static void main(String[] agrs){
		String str ="default:192.168.199.1:8080:8888";
		System.out.println( ProxyURL.parse(str));
		System.out.println( ProxyURL.parse("192.168.199.1:8080:8888"));
		
		System.out.println(ProxyURL.class.getProtectionDomain().getCodeSource().getLocation().getFile());
		System.out.println(System.getProperty("user.dir"));
		
	}
	
	//public static 
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy