Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: latest
version: v2.13.1
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ linters:
# Too opinionated / noisy for a real codebase
- varnamelen # short var names are idiomatic Go
- exhaustruct # requiring all struct fields is impractical
- exhaustruct_v5 # same, under the name golangci-lint 2.13 gave it
- lll # line length enforcement is too rigid
- mnd # magic number detection is overly aggressive
- wsl_v5 # whitespace style is too opinionated
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ docker:
@docker build -f apps/rotom-ng/Dockerfile -t rotom-ng:latest .

clean:
@rm -rf rotom-ng libs/rotom_ui/static apps/rotom-ng/app/version/version.go libs/protos/rotom.pb.go
@rm -rf rotom-ng libs/rotom_ui/static
@rm -rf .nx node_modules libs/base-ui/node_modules apps/rotom-ng-ui/src/version.ts
1 change: 1 addition & 0 deletions apps/rotom-ng-mock-connector/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func (c *controller) sendLogin(ctx context.Context, conn *ws.Conn, workerID stri
Payload: &protos.MitmRequest_LoginRequest_{
LoginRequest: &protos.MitmRequest_LoginRequest{
Username: c.id + "@mock",
//nolint:staticcheck
Source: protos.MitmRequest_LoginRequest_PTC,
WorkerId: workerID,
},
Expand Down
3 changes: 2 additions & 1 deletion apps/rotom-ng/app/error_handling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ func dialRawController(t *testing.T, addr string) *websocket.Conn {
LoginRequest: &protos.MitmRequest_LoginRequest{
WorkerId: controllerID,
Username: "test-user",
Source: protos.MitmRequest_LoginRequest_PTC,
//nolint:staticcheck
Source: protos.MitmRequest_LoginRequest_PTC,
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ require (
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0 // indirect
)

tool google.golang.org/protobuf/cmd/protoc-gen-go
6 changes: 3 additions & 3 deletions libs/connections/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ func (mgr *ConnectionManager[C, W]) registerController(controller C) {
})
}

func (mgr *ConnectionManager[C, W]) pruneSelectorWorkerIDs() {
func (mgr *ConnectionManager[C, W]) pruneSelectorWorkerIDs(ctx context.Context) {
// ensure periodic task runner doesn't die
defer func() {
r := recover()
if r != nil {
mgr.logger.LogAttrs(context.Background(), slog.LevelError, "PruneWorkerIDsSeen panicked", slog.Any("panic", r))
mgr.logger.LogAttrs(ctx, slog.LevelError, "PruneWorkerIDsSeen panicked", slog.Any("panic", r))
return
}
}()
Expand Down Expand Up @@ -871,7 +871,7 @@ func (mgr *ConnectionManager[C, W]) RunPeriodicTasks(ctx context.Context) {
case <-ctx.Done():
return
case <-ticker.C:
mgr.pruneSelectorWorkerIDs()
mgr.pruneSelectorWorkerIDs(ctx)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions libs/connections/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1242,12 +1242,12 @@ func TestPruneSelectorWorkerIDs_PanicRecovery(_ *testing.T) {
o.selector.prunePanic = true

// Should not panic
mgr.pruneSelectorWorkerIDs()
mgr.pruneSelectorWorkerIDs(context.Background())
}

func TestPruneSelectorWorkerIDs_Success(t *testing.T) {
mgr, o := newTestManager()
mgr.pruneSelectorWorkerIDs()
mgr.pruneSelectorWorkerIDs(context.Background())

o.selector.mu.Lock()
if !o.selector.pruneCalled {
Expand Down
2 changes: 1 addition & 1 deletion libs/protos/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// for the MITM communication protocol.
package protos

//go:generate protoc --go_opt=paths=source_relative --experimental_allow_proto3_optional --go_opt=Mrotom.proto=github.com/UnownHash/RotomNG/libs/protos --go_out=. rotom.proto
//go:generate ./generate.sh
20 changes: 20 additions & 0 deletions libs/protos/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
set -e

if ! command -v protoc >/dev/null 2>&1; then
echo "protoc not found. Install it: apt install protobuf-compiler, or brew install protobuf." >&2
exit 1
fi

# protoc-gen-go comes from the tool directive in go.mod, so it is built on
# demand at the same google.golang.org/protobuf version the generated code
# links against. Nothing to install by hand, and the two cannot drift apart.
plugin="$(go tool -n protoc-gen-go)"

exec protoc \
--plugin=protoc-gen-go="$plugin" \
--go_opt=paths=source_relative \
--experimental_allow_proto3_optional \
--go_opt=Mrotom.proto=github.com/UnownHash/RotomNG/libs/protos \
--go_out=. \
rotom.proto
Loading
Loading