-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zed lake service launched by Zui is accepting remote connections #3056
Comments
Between my research and discussions with the team thus far, there's a few ways I see to potentially address this.
|
@philrz: It's easy enough for the UI to change |
Thanks @nwt. That seems like a reasonable suggestion. Unfortunately, upon closer inspection it seems the side effects of the connect-directly-to- Consider the attached video which I took with the zed-lake-only-localhost branch and a Zui Insiders dev build based on the same. As a user, let's say I want to connect from my Zui Insiders to the lake running behind regular Zui. This may not come often, but given how we position the two apps as something that can be run side-by-side it could indeed happen. I add a remote lake config to Repro.mp4This doesn't happen with the zed-lake-localhost-dns-order approach. |
Zui is currently using Electron 28, with Node v18 in the main process. Upgrading to Electron 29 or 30 will give us Node v20. That seems like the best way to get the DNS-related behavior we want (i.e., if a name resolves to both A and AAAA records, then try both). If upgrading Electron isn't practical right now, another way to get the behavior we want is to use Electron's net.fetch() API in the main process instead of node-fetch by doing something like this: diff --git a/apps/zui/src/core/main/main-object.ts b/apps/zui/src/core/main/main-object.ts
index 1392194e2..02d7ba843 100644
--- a/apps/zui/src/core/main/main-object.ts
+++ b/apps/zui/src/core/main/main-object.ts
@@ -2,7 +2,7 @@ import {app} from "electron"
import keytar from "keytar"
import {EventEmitter} from "events"
import os from "os"
-import {Client, Lake} from "@brimdata/zed-node"
+import {Lake} from "@brimdata/zed-node"
import {Store as ReduxStore} from "redux"
import url from "url"
import {
@@ -22,6 +22,7 @@ import * as zdeps from "../../electron/zdeps"
import {MainArgs, mainDefaults} from "../../electron/run-main/args"
import createSession, {Session} from "../../electron/session"
import {getAppMeta, AppMeta} from "../../electron/meta"
+import {ZedClient} from "../../electron/zed-client"
import {createMainStore} from "../../js/state/stores/create-main-store"
import {AppDispatch, State} from "../../js/state/types"
import {PathName, getPath} from "../../js/api/core/get-path"
@@ -135,7 +136,7 @@ export class MainObject {
const lakeData = Lakes.id(lakeId)(this.store.getState())
const lake = createLake(lakeData)
const auth = await this.dispatch(getAuthToken(lake))
- return new Client(lake.getAddress(), {auth})
+ return new ZedClient(lake.getAddress(), {auth})
}
async createDefaultClient() {
diff --git a/apps/zui/src/electron/zed-client.ts b/apps/zui/src/electron/zed-client.ts
new file mode 100644
index 000000000..b8d2d6408
--- /dev/null
+++ b/apps/zui/src/electron/zed-client.ts
@@ -0,0 +1,9 @@
+import {Client} from "@brimdata/zed-node"
+import {net} from "electron"
+
+export class ZedClient extends Client {
+ // eslint-disable-next-line
+ // @ts-ignore
+ // eslint-disable-next-line
+ public fetch = (...args: any[]) => net.fetch(...args);
+} |
Verified in Zui commit 9c37575. The changes in #3069 effectively got us to the "happy eyeballs" solution described as item 4 in the list above, then #3091 changed how the Zed lake service is launched by Zui such that now it's only listening for connections from
I've confirmed from my Windows laptop on the same network that I can no longer connect to that Zed service behind my Zui like I could before. This all unblocks #1105, so soon I'll put up a PR to add that option in Settings so a user can open the launched service up to remote connections again if that's their preference. |
tl;dr
In GA Zui
v1.5.0
and older, the Zed lake service was launched by Zui withzed serve -l localhost:9867
such that client connections would only be permitted fromlocalhost
. The changes in #2934 resulted in this becomingzed serve -l :9867
such that in GA Zuiv1.6.0
and newer Zui's local lake service has been open to connections from remote addresses as well. Hopefully default desktop configs are such that firewalls would prevent such incoming connections regardless, but we should likely revert this change in the interest of good security hygiene. Unfortunately, other tool changes (probably the same ones that resulted in the change in #2934) require us to do a bit more than just put back the original code.Details
The change from #2934 in question is commit e0e3a7d where this line that formerly said
this.addr(),
changed to:zui/packages/zed-node/src/lake.ts
Line 41 in 9c98969
If we revert just that change back to
this.addr()
and then try to do something with the lake such as load data, we now get an error:Web searches regarding this error brings up Node.js issue nodejs/node#40702 wherein this comment seems like the best summary I've seen. In brief, it appears that the move to Node v18 in #2972 has made it such that now when the
zed-node
client seeks to connect tolocalhost
, new Node behavior has made it such that the connection is now attempted to the IPv6 address::1
and since the Zed service is listening only on the IPv4 address the connection is refused.I've been experimenting with some of the fixes/workarounds described in nodejs/node#40702 and am weighing the trade-offs. I'll add a comment next with findings thus far.
The text was updated successfully, but these errors were encountered: