Skip to content

Commit 0607590

Browse files
chore: apply customizations on 2026.5.1
1 parent f6f60e1 commit 0607590

11 files changed

Lines changed: 328 additions & 109 deletions

File tree

.github/workflows/check.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/semgrep.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

Makefile

Lines changed: 31 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,13 @@ else
2424
DEB_PACKAGE_NAME := $(BINARY_NAME)
2525
endif
2626

27-
# Use git in windows since we don't have access to the `date` tool
28-
ifeq ($(TARGET_OS), windows)
29-
DATE := $(shell git log -1 --format="%ad" --date=format-local:'%Y-%m-%dT%H:%M UTC' -- RELEASE_NOTES)
30-
else
31-
DATE := $(shell date -u -r RELEASE_NOTES '+%Y-%m-%d-%H:%M UTC')
32-
endif
33-
27+
DATE := $(shell date -u -r RELEASE_NOTES '+%Y-%m-%d-%H%M UTC')
3428
VERSION_FLAGS := -X "main.Version=$(VERSION)" -X "main.BuildTime=$(DATE)"
3529
ifdef PACKAGE_MANAGER
3630
VERSION_FLAGS := $(VERSION_FLAGS) -X "github.com/cloudflare/cloudflared/cmd/cloudflared/updater.BuiltForPackageManager=$(PACKAGE_MANAGER)"
3731
endif
3832

39-
ifdef CONTAINER_BUILD
33+
ifdef CONTAINER_BUILD
4034
VERSION_FLAGS := $(VERSION_FLAGS) -X "github.com/cloudflare/cloudflared/metrics.Runtime=virtual"
4135
endif
4236

@@ -62,6 +56,8 @@ PACKAGE_DIR := $(CURDIR)/packaging
6256
PREFIX := /usr
6357
INSTALL_BINDIR := $(PREFIX)/bin/
6458
INSTALL_MANDIR := $(PREFIX)/share/man/man1/
59+
CF_GO_PATH := /tmp/go
60+
PATH := $(CF_GO_PATH)/bin:$(PATH)
6561

6662
LOCAL_ARCH ?= $(shell uname -m)
6763
ifneq ($(GOARCH),)
@@ -70,8 +66,6 @@ else ifeq ($(LOCAL_ARCH),x86_64)
7066
TARGET_ARCH ?= amd64
7167
else ifeq ($(LOCAL_ARCH),amd64)
7268
TARGET_ARCH ?= amd64
73-
else ifeq ($(LOCAL_ARCH),386)
74-
TARGET_ARCH ?= 386
7569
else ifeq ($(LOCAL_ARCH),i686)
7670
TARGET_ARCH ?= amd64
7771
else ifeq ($(shell echo $(LOCAL_ARCH) | head -c 5),armv8)
@@ -97,6 +91,8 @@ else ifeq ($(LOCAL_OS),windows)
9791
TARGET_OS ?= windows
9892
else ifeq ($(LOCAL_OS),freebsd)
9993
TARGET_OS ?= freebsd
94+
else ifeq ($(LOCAL_OS),netbsd)
95+
TARGET_OS ?= netbsd
10096
else ifeq ($(LOCAL_OS),openbsd)
10197
TARGET_OS ?= openbsd
10298
else
@@ -119,7 +115,7 @@ ifneq ($(TARGET_ARM), )
119115
ARM_COMMAND := GOARM=$(TARGET_ARM)
120116
endif
121117

122-
ifeq ($(TARGET_ARM), 7)
118+
ifeq ($(TARGET_ARM), 7)
123119
PACKAGE_ARCH := armhf
124120
else
125121
PACKAGE_ARCH := $(TARGET_ARCH)
@@ -128,19 +124,13 @@ endif
128124
#for FIPS compliance, FPM defaults to MD5.
129125
RPM_DIGEST := --rpm-digest sha256
130126

131-
GO_TEST_LOG_OUTPUT = /tmp/gotest.log
132-
133127
.PHONY: all
134128
all: cloudflared test
135129

136130
.PHONY: clean
137131
clean:
138132
go clean
139133

140-
.PHONY: vulncheck
141-
vulncheck:
142-
@./.ci/scripts/vuln-check.sh
143-
144134
.PHONY: cloudflared
145135
cloudflared:
146136
ifeq ($(FIPS), true)
@@ -162,9 +152,11 @@ generate-docker-version:
162152

163153
.PHONY: test
164154
test: vet
165-
$Q go test -json -v -mod=vendor -race $(LDFLAGS) ./... 2>&1 | tee $(GO_TEST_LOG_OUTPUT)
166-
ifneq ($(FIPS), true)
167-
@go run -mod=readonly github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest -input $(GO_TEST_LOG_OUTPUT)
155+
ifndef CI
156+
go test -v -mod=vendor -race $(LDFLAGS) ./...
157+
else
158+
@mkdir -p .cover
159+
go test -v -mod=vendor -race $(LDFLAGS) -coverprofile=".cover/c.out" ./...
168160
endif
169161

170162
.PHONY: cover
@@ -182,17 +174,26 @@ fuzz:
182174
@go test -fuzz=FuzzIPDecoder -fuzztime=600s ./packet
183175
@go test -fuzz=FuzzICMPDecoder -fuzztime=600s ./packet
184176
@go test -fuzz=FuzzSessionWrite -fuzztime=600s ./quic/v3
185-
@go test -fuzz=FuzzSessionRead -fuzztime=600s ./quic/v3
177+
@go test -fuzz=FuzzSessionServe -fuzztime=600s ./quic/v3
186178
@go test -fuzz=FuzzRegistrationDatagram -fuzztime=600s ./quic/v3
187179
@go test -fuzz=FuzzPayloadDatagram -fuzztime=600s ./quic/v3
188180
@go test -fuzz=FuzzRegistrationResponseDatagram -fuzztime=600s ./quic/v3
189181
@go test -fuzz=FuzzNewIdentity -fuzztime=600s ./tracing
190182
@go test -fuzz=FuzzNewAccessValidator -fuzztime=600s ./validation
191183

184+
.PHONY: install-go
185+
install-go:
186+
rm -rf ${CF_GO_PATH}
187+
./.teamcity/install-cloudflare-go.sh
188+
189+
.PHONY: cleanup-go
190+
cleanup-go:
191+
rm -rf ${CF_GO_PATH}
192+
192193
cloudflared.1: cloudflared_man_template
193194
sed -e 's/\$${VERSION}/$(VERSION)/; s/\$${DATE}/$(DATE)/' cloudflared_man_template > cloudflared.1
194195

195-
install: cloudflared cloudflared.1
196+
install: install-go cloudflared cloudflared.1 cleanup-go
196197
mkdir -p $(DESTDIR)$(INSTALL_BINDIR) $(DESTDIR)$(INSTALL_MANDIR)
197198
install -m755 cloudflared $(DESTDIR)$(INSTALL_BINDIR)/cloudflared
198199
install -m644 cloudflared.1 $(DESTDIR)$(INSTALL_MANDIR)/cloudflared.1
@@ -221,6 +222,10 @@ cloudflared-deb: cloudflared cloudflared.1
221222
cloudflared-rpm: cloudflared cloudflared.1
222223
$(call build_package,rpm)
223224

225+
.PHONY: cloudflared-pkg
226+
cloudflared-pkg: cloudflared cloudflared.1
227+
$(call build_package,osxpkg)
228+
224229
.PHONY: cloudflared-msi
225230
cloudflared-msi:
226231
wixl --define Version=$(VERSION) --define Path=$(EXECUTABLE_PATH) --output cloudflared-$(VERSION)-$(TARGET_ARCH).msi cloudflared.wxs
@@ -231,18 +236,13 @@ github-release-dryrun:
231236

232237
.PHONY: github-release
233238
github-release:
234-
python3 github_release.py --path $(PWD)/artifacts/ --release-version $(VERSION)
239+
python3 github_release.py --path $(PWD)/built_artifacts --release-version $(VERSION)
235240
python3 github_message.py --release-version $(VERSION)
236241

237242
.PHONY: r2-linux-release
238243
r2-linux-release:
239244
python3 ./release_pkgs.py
240245

241-
.PHONY: r2-next-linux-release
242-
# Publishes to a separate R2 repository during GPG key rollover, using dual-key signing.
243-
r2-next-linux-release:
244-
python3 ./release_pkgs.py --upload-repo-file
245-
246246
.PHONY: capnp
247247
capnp:
248248
which capnp # https://capnproto.org/install.html
@@ -251,7 +251,7 @@ capnp:
251251

252252
.PHONY: vet
253253
vet:
254-
$Q go vet -mod=vendor github.com/cloudflare/cloudflared/...
254+
go vet -mod=vendor github.com/cloudflare/cloudflared/...
255255

256256
.PHONY: fmt
257257
fmt:
@@ -260,38 +260,12 @@ fmt:
260260

261261
.PHONY: fmt-check
262262
fmt-check:
263-
@./.ci/scripts/fmt-check.sh
263+
@./fmt-check.sh
264264

265265
.PHONY: lint
266266
lint:
267267
@golangci-lint run
268268

269269
.PHONY: mocks
270270
mocks:
271-
go generate mocks/mockgen.go
272-
273-
.PHONY: ci-build
274-
ci-build:
275-
@GOOS=linux GOARCH=amd64 $(MAKE) cloudflared
276-
@mkdir -p artifacts
277-
@mv cloudflared artifacts/cloudflared
278-
279-
.PHONY: ci-fips-build
280-
ci-fips-build:
281-
@FIPS=true GOOS=linux GOARCH=amd64 $(MAKE) cloudflared
282-
@mkdir -p artifacts
283-
@mv cloudflared artifacts/cloudflared
284-
285-
.PHONY: ci-test
286-
ci-test: fmt-check lint test
287-
@go run -mod=readonly github.com/jstemmer/go-junit-report/v2@latest -in $(GO_TEST_LOG_OUTPUT) -parser gojson -out report.xml -set-exit-code
288-
289-
.PHONY: ci-fips-test
290-
ci-fips-test:
291-
@FIPS=true $(MAKE) ci-test
292-
293-
.PHONY: install-hooks
294-
install-hooks:
295-
git config core.hooksPath .githooks
296-
@echo "Git hooks installed from .githooks/"
297-
@echo "Pre-push hook will run: make fmt-check lint test"
271+
go generate mocks/mockgen.go

connection/errors.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,44 @@ func serverRegistrationErrorFromRPC(err error) ServerRegisterTunnelError {
5252
}
5353
}
5454

55-
type ControlStreamError struct{}
55+
type ControlStreamError struct {
56+
Cause error
57+
}
5658

5759
var _ error = &ControlStreamError{}
5860

5961
func (e *ControlStreamError) Error() string {
6062
return "control stream encountered a failure while serving"
6163
}
6264

63-
type StreamListenerError struct{}
65+
func (e *ControlStreamError) Unwrap() error {
66+
return e.Cause
67+
}
68+
69+
type StreamListenerError struct {
70+
Cause error
71+
}
6472

6573
var _ error = &StreamListenerError{}
6674

6775
func (e *StreamListenerError) Error() string {
6876
return "accept stream listener encountered a failure while serving"
6977
}
7078

71-
type DatagramManagerError struct{}
79+
func (e *StreamListenerError) Unwrap() error {
80+
return e.Cause
81+
}
82+
83+
type DatagramManagerError struct {
84+
Cause error
85+
}
7286

7387
var _ error = &DatagramManagerError{}
7488

7589
func (e *DatagramManagerError) Error() string {
7690
return "datagram manager encountered a failure while serving"
7791
}
92+
93+
func (e *DatagramManagerError) Unwrap() error {
94+
return e.Cause
95+
}

connection/quic_connection.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,23 @@ func (q *quicConnection) Serve(ctx context.Context) error {
120120
if err != nil {
121121
q.logger.Error().Err(err).Msg("failed to serve the control stream")
122122
}
123-
return &ControlStreamError{}
123+
return &ControlStreamError{Cause: err}
124124
})
125125
// Start the accept stream loop routine
126126
errGroup.Go(func() error {
127127
err := q.acceptStream(ctx)
128128
if err != nil {
129129
q.logger.Error().Err(err).Msg("failed to accept incoming stream requests")
130130
}
131-
return &StreamListenerError{}
131+
return &StreamListenerError{Cause: err}
132132
})
133133
// Start the datagram handler routine
134134
errGroup.Go(func() error {
135135
err := q.datagramHandler.Serve(ctx)
136136
if err != nil {
137137
q.logger.Error().Err(err).Msg("failed to run the datagram handler")
138138
}
139-
return &DatagramManagerError{}
139+
return &DatagramManagerError{Cause: err}
140140
})
141141

142142
return errGroup.Wait()

diagnostic/network/collector_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build darwin || linux
1+
//go:build darwin || linux || freebsd || openbsd || netbsd
22

33
package diagnostic
44

diagnostic/network/collector_unix_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build darwin || linux
1+
//go:build darwin || linux || freebsd || openbsd || netbsd
22

33
package diagnostic_test
44

0 commit comments

Comments
 (0)