String svc_passwd = info.get("password");
String svc_dbname = info.get("db") != null ? info.get("db") : info.get("name");
String txt_dbname = info.get("db") != null ? "db" : "name";
String svc_vhost = info.get("vhost");
TunnelServer server = new TunnelServer(local, new HttpTunnelFactory(url, host, port, auth));
server.start();
System.out.println("Tunnel is running on " + LOCAL_HOST +" port " + LOCAL_PORT + " with auth=" + auth);
if (svc_vhost != null) {
System.out.println("Connect client with username=" + svc_username +" password=" + svc_passwd + " " + "vhost=" + svc_vhost);
}
else {
System.out.println("Connect client with username=" + svc_username +" password=" + svc_passwd + " " + txt_dbname + "=" + svc_dbname);
}
while (true) {
if (console != null) {
String command = console.readLine("Enter exit to stop: ");
if (command.toLowerCase().equals("exit")) {
break;
}
}
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {}
}
server.stop();
finalize(client);
System.out.println("DONE!");
}