Skip to content

Commit 2b24362

Browse files
authored
very large refactor of wshrouter (#2732)
the PR spiraled and ended up being much larger than anticipated. it is a refactor of wshrouter to have it track "links" as opposed to just routes. this lets us simplify a lot of things when it comes to multi-level routing. * now the router can handle unauthenticated links directly, instead of a weird limbo in wshproxy * no more wshmultiproxy * no more "authtoken" weirdness * more straightforward handling in connserver (when using router option) also adds more debugging, more logging, some windows fixes, other wsl fixes
1 parent 90011a7 commit 2b24362

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1597
-1275
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ out/
1616
make/
1717
artifacts/
1818
mikework/
19+
manifests/
1920
.env
2021
out
2122

Taskfile.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ vars:
88
BIN_DIR: "bin"
99
VERSION:
1010
sh: node version.cjs
11-
RM: '{{if eq OS "windows"}}powershell Remove-Item -Force -ErrorAction SilentlyContinue{{else}}rm -f{{end}}'
1211
RMRF: '{{if eq OS "windows"}}powershell Remove-Item -Force -Recurse -ErrorAction SilentlyContinue{{else}}rm -rf{{end}}'
1312
DATE: '{{if eq OS "windows"}}powershell Get-Date -UFormat{{else}}date{{end}}'
1413
ARTIFACTS_BUCKET: waveterm-github-artifacts/staging-w2
@@ -177,7 +176,7 @@ tasks:
177176
desc: Build the wavesrv component for macOS (Darwin) platforms (generates artifacts for both arm64 and amd64).
178177
platforms: [darwin]
179178
cmds:
180-
- cmd: "{{.RM}} dist/bin/wavesrv*"
179+
- cmd: rm -f dist/bin/wavesrv*
181180
ignore_error: true
182181
- task: build:server:internal
183182
vars:
@@ -224,7 +223,7 @@ tasks:
224223
desc: Build the wavesrv component for Windows platforms (only generates artifacts for the current architecture).
225224
platforms: [windows]
226225
cmds:
227-
- cmd: "{{.RM}} dist/bin/wavesrv*"
226+
- cmd: powershell -Command "Remove-Item -Force -ErrorAction SilentlyContinue -Path dist/bin/wavesrv*"
228227
ignore_error: true
229228
- task: build:server:internal
230229
vars:
@@ -237,7 +236,7 @@ tasks:
237236
desc: Build the wavesrv component for Linux platforms (only generates artifacts for the current architecture).
238237
platforms: [linux]
239238
cmds:
240-
- cmd: "{{.RM}} dist/bin/wavesrv*"
239+
- cmd: rm -f dist/bin/wavesrv*
241240
ignore_error: true
242241
- task: build:server:internal
243242
vars:
@@ -261,7 +260,11 @@ tasks:
261260
build:wsh:
262261
desc: Build the wsh component for all possible targets.
263262
cmds:
264-
- cmd: "{{.RM}} dist/bin/wsh*"
263+
- cmd: rm -f dist/bin/wsh*
264+
platforms: [darwin, linux]
265+
ignore_error: true
266+
- cmd: powershell -Command "Remove-Item -Force -ErrorAction SilentlyContinue -Path dist/bin/wsh*"
267+
platforms: [windows]
265268
ignore_error: true
266269
- task: build:wsh:internal
267270
vars:
@@ -527,7 +530,11 @@ tasks:
527530
desc: Create package.json for tsunami scaffold using npm commands
528531
dir: tsunami/frontend/scaffold
529532
cmds:
530-
- cmd: "{{.RM}} package.json"
533+
- cmd: rm -f package.json
534+
platforms: [darwin, linux]
535+
ignore_error: true
536+
- cmd: powershell -Command "Remove-Item -Force -ErrorAction SilentlyContinue -Path package.json"
537+
platforms: [windows]
531538
ignore_error: true
532539
- npm --no-workspaces init -y --init-license Apache-2.0
533540
- npm pkg set name=tsunami-scaffold
@@ -588,7 +595,11 @@ tasks:
588595
tsunami:build:
589596
desc: Build the tsunami binary.
590597
cmds:
591-
- cmd: "{{.RM}} bin/tsunami*"
598+
- cmd: rm -f bin/tsunami*
599+
platforms: [darwin, linux]
600+
ignore_error: true
601+
- cmd: powershell -Command "Remove-Item -Force -ErrorAction SilentlyContinue -Path bin/tsunami*"
602+
platforms: [windows]
592603
ignore_error: true
593604
- mkdir -p bin
594605
- cd tsunami && go build -ldflags "-X main.BuildTime=$({{.DATE}} +'%Y%m%d%H%M') -X main.TsunamiVersion={{.VERSION}}" -o ../bin/tsunami{{exeExt}} cmd/main-tsunami.go

cmd/server/main-server.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,11 @@ func shutdownActivityUpdate() {
389389
func createMainWshClient() {
390390
rpc := wshserver.GetMainRpcClient()
391391
wshfs.RpcClient = rpc
392-
wshutil.DefaultRouter.RegisterRoute(wshutil.DefaultRoute, rpc, true)
392+
wshutil.DefaultRouter.RegisterTrustedLeaf(rpc, wshutil.DefaultRoute)
393393
wps.Broker.SetClient(wshutil.DefaultRouter)
394-
localConnWsh := wshutil.MakeWshRpc(nil, nil, wshrpc.RpcContext{Conn: wshrpc.LocalConnName}, &wshremote.ServerImpl{}, "conn:local")
394+
localConnWsh := wshutil.MakeWshRpc(wshrpc.RpcContext{Conn: wshrpc.LocalConnName}, &wshremote.ServerImpl{}, "conn:local")
395395
go wshremote.RunSysInfoLoop(localConnWsh, wshrpc.LocalConnName)
396-
wshutil.DefaultRouter.RegisterRoute(wshutil.MakeConnectionRouteId(wshrpc.LocalConnName), localConnWsh, true)
396+
wshutil.DefaultRouter.RegisterTrustedLeaf(localConnWsh, wshutil.MakeConnectionRouteId(wshrpc.LocalConnName))
397397
}
398398

399399
func grabAndRemoveEnvVars() error {
@@ -457,10 +457,12 @@ func maybeStartPprofServer() {
457457
}
458458

459459
func main() {
460-
log.SetFlags(log.LstdFlags | log.Lmicroseconds)
460+
log.SetFlags(0) // disable timestamp since electron's winston logger already wraps with timestamp
461461
log.SetPrefix("[wavesrv] ")
462462
wavebase.WaveVersion = WaveVersion
463463
wavebase.BuildTime = BuildTime
464+
wshutil.DefaultRouter = wshutil.NewWshRouter()
465+
wshutil.DefaultRouter.SetAsRootRouter()
464466

465467
err := grabAndRemoveEnvVars()
466468
if err != nil {
@@ -546,6 +548,11 @@ func main() {
546548
log.Printf("error clearing temp files: %v\n", err)
547549
return
548550
}
551+
err = wcore.InitMainServer()
552+
if err != nil {
553+
log.Printf("error initializing mainserver: %v\n", err)
554+
return
555+
}
549556

550557
err = shellutil.FixupWaveZshHistory()
551558
if err != nil {

0 commit comments

Comments
 (0)