Skip to content

Commit 8b9e1d3

Browse files
committed
Revert "[jb] fix #10694: respect GW user settings"
This reverts commit bd5d3ea.
1 parent d7bac05 commit 8b9e1d3

File tree

11 files changed

+62
-121
lines changed

11 files changed

+62
-121
lines changed

components/gitpod-protocol/java/src/main/java/io/gitpod/gitpodprotocol/api/GitpodServerLauncher.java

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,17 @@
44

55
package io.gitpod.gitpodprotocol.api;
66

7-
import org.eclipse.jetty.client.HttpClient;
8-
import org.eclipse.jetty.client.HttpProxy;
9-
import org.eclipse.jetty.client.Socks4Proxy;
10-
import org.eclipse.jetty.util.ssl.SslContextFactory;
11-
import org.eclipse.jetty.websocket.jsr356.ClientContainer;
127
import org.eclipse.lsp4j.jsonrpc.Launcher;
138
import org.eclipse.lsp4j.jsonrpc.MessageConsumer;
149
import org.eclipse.lsp4j.jsonrpc.MessageIssueHandler;
1510
import org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler;
1611
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints;
1712
import org.eclipse.lsp4j.websocket.WebSocketMessageHandler;
1813

19-
import javax.net.ssl.SSLContext;
2014
import javax.websocket.*;
21-
import java.net.InetSocketAddress;
22-
import java.net.Proxy;
23-
import java.net.SocketAddress;
15+
import java.io.IOException;
2416
import java.net.URI;
2517
import java.util.Arrays;
26-
import java.util.Collections;
2718
import java.util.List;
2819
import java.util.Map;
2920
import java.util.logging.Level;
@@ -56,60 +47,10 @@ public GitpodServerConnection listen(
5647
String userAgent,
5748
String clientVersion,
5849
String token
59-
) throws Exception {
60-
return listen(apiUrl, origin, userAgent, clientVersion, token, Collections.emptyList(), null);
61-
}
62-
63-
public GitpodServerConnection listen(
64-
String apiUrl,
65-
String origin,
66-
String userAgent,
67-
String clientVersion,
68-
String token,
69-
List<Proxy> proxies,
70-
SSLContext sslContext
71-
) throws Exception {
50+
) throws DeploymentException, IOException {
7251
String gitpodHost = URI.create(apiUrl).getHost();
73-
HttpClient httpClient;
74-
if (sslContext == null) {
75-
httpClient = new HttpClient();
76-
} else {
77-
SslContextFactory ssl = new SslContextFactory.Client();
78-
ssl.setSslContext(sslContext);
79-
httpClient = new HttpClient(ssl);
80-
}
81-
for (Proxy proxy : proxies) {
82-
if (proxy.type().equals(Proxy.Type.DIRECT)) {
83-
continue;
84-
}
85-
SocketAddress proxyAddress = proxy.address();
86-
if (!(proxyAddress instanceof InetSocketAddress)) {
87-
GitpodServerConnectionImpl.LOG.log(Level.WARNING, gitpodHost + ": unexpected proxy:", proxy);
88-
continue;
89-
}
90-
String hostName = ((InetSocketAddress) proxyAddress).getHostString();
91-
int port = ((InetSocketAddress) proxyAddress).getPort();
92-
if (proxy.type().equals(Proxy.Type.HTTP)) {
93-
httpClient.getProxyConfiguration().getProxies().add(new HttpProxy(hostName, port));
94-
} else if (proxy.type().equals(Proxy.Type.SOCKS)) {
95-
httpClient.getProxyConfiguration().getProxies().add(new Socks4Proxy(hostName, port));
96-
}
97-
}
98-
ClientContainer container = new ClientContainer(httpClient);
99-
// allow clientContainer to own httpClient (for start/stop lifecycle)
100-
container.getClient().addManaged(httpClient);
101-
container.start();
102-
10352
GitpodServerConnectionImpl connection = new GitpodServerConnectionImpl(gitpodHost);
104-
connection.whenComplete((input, exception) -> {
105-
try {
106-
container.stop();
107-
} catch (Throwable t) {
108-
GitpodServerConnectionImpl.LOG.log(Level.WARNING, gitpodHost + ": failed to stop websocket container:", t);
109-
}
110-
});
111-
112-
connection.setSession(container.connectToServer(new Endpoint() {
53+
connection.setSession(ContainerProvider.getWebSocketContainer().connectToServer(new Endpoint() {
11354
@Override
11455
public void onOpen(Session session, EndpointConfig config) {
11556
session.addMessageHandler(new WebSocketMessageHandler(messageReader, jsonHandler, remoteEndpoint));

components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/auth/GitpodAuthService.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import java.util.*
3838
import java.util.concurrent.CompletableFuture
3939
import kotlin.math.absoluteValue
4040

41+
4142
@Service
4243
internal class GitpodAuthService : OAuthServiceBase<Credentials>() {
4344
override val name: String
@@ -65,7 +66,7 @@ internal class GitpodAuthService : OAuthServiceBase<Credentials>() {
6566
constructor(gitpodHost: String) {
6667
val codeVerifier = generateCodeVerifier()
6768
val codeChallenge = generateCodeChallenge(codeVerifier)
68-
val serviceUrl = newFromEncoded("https://$gitpodHost/api/oauth")
69+
val serviceUrl = newFromEncoded("https://${gitpodHost}/api/oauth")
6970
credentialsAcquirer = GitpodAuthCredentialsAcquirer(
7071
serviceUrl.resolve("token"), mapOf(
7172
"grant_type" to "authorization_code",
@@ -93,7 +94,7 @@ internal class GitpodAuthService : OAuthServiceBase<Credentials>() {
9394
val bytes = ByteArray(size)
9495
secureRandom.nextBytes(bytes)
9596

96-
val mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~"
97+
val mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
9798
val scale = 256 / mask.length
9899
val builder = StringBuilder()
99100
for (i in 0 until size) {
@@ -146,6 +147,7 @@ internal class GitpodAuthService : OAuthServiceBase<Credentials>() {
146147

147148
private data class AuthorizationResponseData(val accessToken: String)
148149
private data class JsonWebToken(val jti: String)
150+
149151
}
150152

151153
companion object {
@@ -196,7 +198,7 @@ internal class GitpodAuthService : OAuthServiceBase<Credentials>() {
196198
listener()
197199
}
198200
}
199-
dispatcher.addListener(internalListener)
201+
dispatcher.addListener(internalListener);
200202
return Disposable { dispatcher.removeListener(internalListener) }
201203
}
202204
}

components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GatewayGitpodClient.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ import kotlinx.coroutines.sync.Mutex
2121
import kotlinx.coroutines.sync.withLock
2222

2323
class GatewayGitpodClient(
24-
private val lifetimeDefinition: LifetimeDefinition,
25-
private val gitpodHost: String
24+
private val lifetimeDefinition: LifetimeDefinition, private val gitpodHost: String
2625
) : GitpodClient() {
2726

2827
private val mutex = Mutex()
2928

3029
private val listeners = concurrentMapOf<String, CopyOnWriteArrayList<Channel<WorkspaceInstance>>?>()
3130

3231
private val timeoutDelayInMinutes = 15
33-
private var timeoutJob: Job? = null
32+
private var timeoutJob: Job? = null;
3433

3534
init {
3635
GlobalScope.launch {
@@ -60,7 +59,7 @@ class GatewayGitpodClient(
6059
}
6160
}
6261

63-
private var syncJob: Job? = null
62+
private var syncJob: Job? = null;
6463
override fun notifyConnect() {
6564
syncJob?.cancel()
6665
syncJob = GlobalScope.launch {
@@ -70,17 +69,17 @@ class GatewayGitpodClient(
7069
continue
7170
}
7271
try {
73-
syncWorkspace(id)
72+
syncWorkspace(id);
7473
} catch (t: Throwable) {
75-
thisLogger().error("$gitpodHost: $id: failed to sync", t)
74+
thisLogger().error("${gitpodHost}: ${id}: failed to sync", t)
7675
}
7776
}
7877
}
7978
}
8079

8180
override fun onInstanceUpdate(instance: WorkspaceInstance?) {
8281
if (instance == null) {
83-
return
82+
return;
8483
}
8584
GlobalScope.launch {
8685
val wsListeners = listeners[instance.workspaceId] ?: return@launch
@@ -103,7 +102,7 @@ class GatewayGitpodClient(
103102
val listener = Channel<WorkspaceInstance>()
104103
mutex.withLock {
105104
val listeners = this.listeners.getOrPut(workspaceId) { CopyOnWriteArrayList() }!!
106-
listeners.add(listener)
105+
listeners.add(listener);
107106
cancelTimeout("listening to workspace: $workspaceId")
108107
}
109108
listenerLifetime.onTerminationOrNow {
@@ -121,7 +120,7 @@ class GatewayGitpodClient(
121120
if (listeners.isNullOrEmpty()) {
122121
return
123122
}
124-
listeners.remove(listener)
123+
listeners.remove(listener);
125124
if (listeners.isNotEmpty()) {
126125
return
127126
}
@@ -138,4 +137,5 @@ class GatewayGitpodClient(
138137
onInstanceUpdate(info.latestInstance)
139138
return info
140139
}
140+
141141
}

components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionProvider.kt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import javax.swing.JComponent
4848
import javax.swing.JLabel
4949
import kotlin.coroutines.coroutineContext
5050

51+
5152
class GitpodConnectionProvider : GatewayConnectionProvider {
5253

5354
private val gitpod = service<GitpodConnectionService>()
@@ -64,10 +65,10 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
6465
requestor: ConnectionRequestor
6566
): GatewayConnectionHandle? {
6667
if (parameters["gitpodHost"] == null) {
67-
throw IllegalArgumentException("bad gitpodHost parameter")
68+
throw IllegalArgumentException("bad gitpodHost parameter");
6869
}
6970
if (parameters["workspaceId"] == null) {
70-
throw IllegalArgumentException("bad workspaceId parameter")
71+
throw IllegalArgumentException("bad workspaceId parameter");
7172
}
7273
val connectParams = ConnectParams(
7374
parameters["gitpodHost"]!!,
@@ -92,7 +93,7 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
9293
background = phaseMessage.background
9394
columns = 30
9495
}
95-
var ideUrl = ""
96+
var ideUrl = "";
9697
val connectionPanel = panel {
9798
indent {
9899
row {
@@ -145,18 +146,18 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
145146
}
146147

147148
GlobalScope.launch {
148-
var thinClient: ThinClientHandle? = null
149-
var thinClientJob: Job? = null
149+
var thinClient: ThinClientHandle? = null;
150+
var thinClientJob: Job? = null;
150151

151-
var lastUpdate: WorkspaceInstance? = null
152+
var lastUpdate: WorkspaceInstance? = null;
152153
try {
153154
for (update in updates) {
154155
try {
155156
if (WorkspaceInstance.isUpToDate(lastUpdate, update)) {
156-
continue
157+
continue;
157158
}
158159
ideUrl = update.ideUrl
159-
lastUpdate = update
160+
lastUpdate = update;
160161
if (!update.status.conditions.failed.isNullOrBlank()) {
161162
setErrorMessage(update.status.conditions.failed)
162163
}
@@ -274,7 +275,7 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
274275
}
275276
}
276277

277-
return GitpodConnectionHandle(connectionLifetime, connectionPanel, connectParams)
278+
return GitpodConnectionHandle(connectionLifetime, connectionPanel, connectParams);
278279
}
279280

280281
private suspend fun resolveJoinLink(
@@ -364,6 +365,7 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
364365
break
365366
}
366367
}
368+
367369
}
368370
matchedFingerprint
369371
}
@@ -376,7 +378,7 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
376378
ownerToken: String?,
377379
): String? {
378380
val maxRequestTimeout = 30 * 1000L
379-
val timeoutDelayGrowFactor = 1.5
381+
val timeoutDelayGrowFactor = 1.5;
380382
var requestTimeout = 2 * 1000L
381383
while (true) {
382384
coroutineContext.job.ensureActive()
@@ -395,16 +397,16 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
395397
return response.body()
396398
}
397399
if (response.statusCode() < 500) {
398-
thisLogger().error("${connectParams.gitpodHost}: ${connectParams.workspaceId}: failed to fetch '$endpointUrl': ${response.statusCode()}")
400+
thisLogger().error("${connectParams.gitpodHost}: ${connectParams.workspaceId}: failed to fetch '${endpointUrl}': ${response.statusCode()}")
399401
return null
400402
}
401-
thisLogger().warn("${connectParams.gitpodHost}: ${connectParams.workspaceId}: failed to fetch '$endpointUrl', trying again...: ${response.statusCode()}")
403+
thisLogger().warn("${connectParams.gitpodHost}: ${connectParams.workspaceId}: failed to fetch '${endpointUrl}', trying again...: ${response.statusCode()}")
402404
} catch (t: Throwable) {
403405
if (t is CancellationException) {
404406
throw t
405407
}
406408
thisLogger().warn(
407-
"${connectParams.gitpodHost}: ${connectParams.workspaceId}: failed to fetch '$endpointUrl', trying again...:",
409+
"${connectParams.gitpodHost}: ${connectParams.workspaceId}: failed to fetch '${endpointUrl}', trying again...:",
408410
t
409411
)
410412
}
@@ -444,4 +446,5 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
444446
}
445447

446448
private data class SSHHostKey(val type: String, val hostKey: String)
449+
447450
}

0 commit comments

Comments
 (0)