From 37cb485346608c1e11ca69c1bee2ed54ff3dd311 Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Sat, 14 Jan 2023 22:30:47 +0100 Subject: [PATCH] remove ngrok tunnel implementation due to missing fluent api, needs rewrite or complete removal --- .../eclipse/boot/dash/ngrok/NGROKClient.java | 119 ++++++++---------- 1 file changed, 55 insertions(+), 64 deletions(-) diff --git a/eclipse-extensions/org.springframework.ide.eclipse.boot.dash/src/org/springframework/ide/eclipse/boot/dash/ngrok/NGROKClient.java b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash/src/org/springframework/ide/eclipse/boot/dash/ngrok/NGROKClient.java index db0aafec9..b0cccb6b0 100644 --- a/eclipse-extensions/org.springframework.ide.eclipse.boot.dash/src/org/springframework/ide/eclipse/boot/dash/ngrok/NGROKClient.java +++ b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash/src/org/springframework/ide/eclipse/boot/dash/ngrok/NGROKClient.java @@ -10,15 +10,6 @@ *******************************************************************************/ package org.springframework.ide.eclipse.boot.dash.ngrok; -import java.io.IOException; -import java.net.URLEncoder; - -import org.apache.http.HttpResponse; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.fluent.Request; -import org.json.JSONArray; -import org.json.JSONObject; - /** * @author Martin Lippert */ @@ -53,27 +44,27 @@ public class NGROKClient { } public NGROKTunnel startTunnel(String proto, String addr) throws Exception { - process = NGROKProcess.startNGROK(path, proto, addr); - if (process != null) { - - boolean success = false; - int seconds = 0; - - while (!success && seconds < CREATE_TUNNEL_TIMEOUT_SECONDS) { - NGROKTunnel[] tunnels = retrieveTunnels(); - if (tunnels != null && tunnels.length > 0) { - for (int i = 0; i < tunnels.length; i++) { - if (tunnels[i].getAddr().endsWith(addr) && tunnels[i].getProto().equals(proto)) { - tunnel = tunnels[i]; - return tunnel; - } - } - } - seconds++; - Thread.sleep(1000); - } - } - +// process = NGROKProcess.startNGROK(path, proto, addr); +// if (process != null) { +// +// boolean success = false; +// int seconds = 0; +// +// while (!success && seconds < CREATE_TUNNEL_TIMEOUT_SECONDS) { +// NGROKTunnel[] tunnels = retrieveTunnels(); +// if (tunnels != null && tunnels.length > 0) { +// for (int i = 0; i < tunnels.length; i++) { +// if (tunnels[i].getAddr().endsWith(addr) && tunnels[i].getProto().equals(proto)) { +// tunnel = tunnels[i]; +// return tunnel; +// } +// } +// } +// seconds++; +// Thread.sleep(1000); +// } +// } +// return null; } @@ -91,45 +82,45 @@ public class NGROKClient { private NGROKTunnel[] retrieveTunnels() { NGROKTunnel[] result = null; - try { - String response = Request.Get(process.getApiURL() + "/api/tunnels").execute().returnContent().asString(); - - JSONObject jsonResponse = new JSONObject(response); - - JSONArray tunnels = jsonResponse.getJSONArray("tunnels"); - if (tunnels != null) { - result = new NGROKTunnel[tunnels.length()]; - for (int i = 0; i < result.length; i++) { - JSONObject tunnel = tunnels.getJSONObject(i); - String name = tunnel.getString("name"); - String proto = tunnel.getString("proto"); - String public_url = tunnel.getString("public_url"); - String addr = tunnel.getJSONObject("config").getString("addr"); - - result[i] = new NGROKTunnel(name, proto, public_url, addr); - } - } - } - catch (Exception e) { - System.out.println(e); - // do nothing, might be the case that the ngrok process is not yet up - } +// try { +// String response = Request.Get(process.getApiURL() + "/api/tunnels").execute().returnContent().asString(); +// +// JSONObject jsonResponse = new JSONObject(response); +// +// JSONArray tunnels = jsonResponse.getJSONArray("tunnels"); +// if (tunnels != null) { +// result = new NGROKTunnel[tunnels.length()]; +// for (int i = 0; i < result.length; i++) { +// JSONObject tunnel = tunnels.getJSONObject(i); +// String name = tunnel.getString("name"); +// String proto = tunnel.getString("proto"); +// String public_url = tunnel.getString("public_url"); +// String addr = tunnel.getJSONObject("config").getString("addr"); +// +// result[i] = new NGROKTunnel(name, proto, public_url, addr); +// } +// } +// } +// catch (Exception e) { +// System.out.println(e); +// // do nothing, might be the case that the ngrok process is not yet up +// } return result; } private void shutdownTunnel(NGROKTunnel ngrokTunnel) { - try { - String deleteURL = process.getApiURL() + "/api/tunnels/" + URLEncoder.encode(ngrokTunnel.getName(), "UTF-8"); - HttpResponse response = Request.Delete(deleteURL).execute().returnResponse(); - if (response.getStatusLine().getStatusCode() != 204) { - System.err.println("errro closing tunnel"); - } - } catch (ClientProtocolException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } +// try { +// String deleteURL = process.getApiURL() + "/api/tunnels/" + URLEncoder.encode(ngrokTunnel.getName(), "UTF-8"); +// HttpResponse response = Request.Delete(deleteURL).execute().returnResponse(); +// if (response.getStatusLine().getStatusCode() != 204) { +// System.err.println("errro closing tunnel"); +// } +// } catch (ClientProtocolException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } } }