Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af6bc63

Browse files
authored
Merge pull request #4849 from fatedier/dev
bump version
2 parents b41d8f8 + c777891 commit af6bc63

39 files changed

+664
-279
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
go-version: '1.23'
2121
cache: false
2222
- name: golangci-lint
23-
uses: golangci/golangci-lint-action@v4
23+
uses: golangci/golangci-lint-action@v8
2424
with:
2525
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
26-
version: v1.61
26+
version: v2.1
2727

2828
# Optional: golangci-lint command line arguments.
2929
# args: --issues-exit-code=0
@@ -34,9 +34,3 @@ jobs:
3434
# Optional: if set to true then the all caching functionality will be complete disabled,
3535
# takes precedence over all other caching options.
3636
# skip-cache: true
37-
38-
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
39-
# skip-pkg-cache: true
40-
41-
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
42-
# skip-build-cache: true

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Close stale issues"
1+
name: "Close stale issues and PRs"
22
on:
33
schedule:
44
- cron: "20 0 * * *"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ client.key
3939

4040
# Cache
4141
*.swp
42+
43+
# AI
44+
CLAUDE.md

.golangci.yml

Lines changed: 92 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,112 @@
1-
service:
2-
golangci-lint-version: 1.61.x # use the fixed version to not introduce new linters unexpectedly
3-
1+
version: "2"
42
run:
53
concurrency: 4
6-
# timeout for analysis, e.g. 30s, 5m, default is 1m
74
timeout: 20m
85
build-tags:
96
- integ
107
- integfuzz
11-
128
linters:
13-
disable-all: true
9+
default: none
1410
enable:
15-
- unused
16-
- errcheck
11+
- asciicheck
1712
- copyloopvar
13+
- errcheck
1814
- gocritic
19-
- gofumpt
20-
- goimports
21-
- revive
22-
- gosimple
15+
- gosec
2316
- govet
2417
- ineffassign
2518
- lll
19+
- makezero
2620
- misspell
21+
- prealloc
22+
- predeclared
23+
- revive
2724
- staticcheck
28-
- stylecheck
29-
- typecheck
3025
- unconvert
3126
- unparam
27+
- unused
28+
settings:
29+
errcheck:
30+
check-type-assertions: false
31+
check-blank: false
32+
gocritic:
33+
disabled-checks:
34+
- exitAfterDefer
35+
gosec:
36+
excludes:
37+
- G401
38+
- G402
39+
- G404
40+
- G501
41+
- G115
42+
severity: low
43+
confidence: low
44+
govet:
45+
disable:
46+
- shadow
47+
lll:
48+
line-length: 160
49+
tab-width: 1
50+
misspell:
51+
locale: US
52+
ignore-rules:
53+
- cancelled
54+
- marshalled
55+
unparam:
56+
check-exported: false
57+
exclusions:
58+
generated: lax
59+
presets:
60+
- comments
61+
- common-false-positives
62+
- legacy
63+
- std-error-handling
64+
rules:
65+
- linters:
66+
- errcheck
67+
- maligned
68+
path: _test\.go$|^tests/|^samples/
69+
- linters:
70+
- revive
71+
- staticcheck
72+
text: use underscores in Go names
73+
- linters:
74+
- revive
75+
text: unused-parameter
76+
- linters:
77+
- unparam
78+
text: is always false
79+
paths:
80+
- .*\.pb\.go
81+
- .*\.gen\.go
82+
- genfiles$
83+
- vendor$
84+
- bin$
85+
- third_party$
86+
- builtin$
87+
- examples$
88+
formatters:
89+
enable:
3290
- gci
33-
- gosec
34-
- asciicheck
35-
- prealloc
36-
- predeclared
37-
- makezero
38-
fast: false
39-
40-
linters-settings:
41-
errcheck:
42-
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
43-
# default is false: such cases aren't reported by default.
44-
check-type-assertions: false
45-
46-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
47-
# default is false: such cases aren't reported by default.
48-
check-blank: false
49-
govet:
50-
# report about shadowed variables
51-
disable:
52-
- shadow
53-
maligned:
54-
# print struct with more effective memory layout or not, false by default
55-
suggest-new: true
56-
misspell:
57-
# Correct spellings using locale preferences for US or UK.
58-
# Default is to use a neutral variety of English.
59-
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
60-
locale: US
61-
ignore-words:
62-
- cancelled
63-
- marshalled
64-
lll:
65-
# max line length, lines longer will be reported. Default is 120.
66-
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
67-
line-length: 160
68-
# tab width in spaces. Default to 1.
69-
tab-width: 1
70-
gocritic:
71-
disabled-checks:
72-
- exitAfterDefer
73-
unused:
74-
check-exported: false
75-
unparam:
76-
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
77-
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
78-
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
79-
# with golangci-lint call it on a directory with the changed file.
80-
check-exported: false
81-
gci:
82-
sections:
83-
- standard
84-
- default
85-
- prefix(github.com/fatedier/frp/)
86-
gosec:
87-
severity: "low"
88-
confidence: "low"
89-
excludes:
90-
- G401
91-
- G402
92-
- G404
93-
- G501
94-
- G115 # integer overflow conversion
95-
91+
- gofumpt
92+
- goimports
93+
settings:
94+
gci:
95+
sections:
96+
- standard
97+
- default
98+
- prefix(github.com/fatedier/frp/)
99+
exclusions:
100+
generated: lax
101+
paths:
102+
- .*\.pb\.go
103+
- .*\.gen\.go
104+
- genfiles$
105+
- vendor$
106+
- bin$
107+
- third_party$
108+
- builtin$
109+
- examples$
96110
issues:
97-
# List of regexps of issue texts to exclude, empty list by default.
98-
# But independently from this option we use default exclude patterns,
99-
# it can be disabled by `exclude-use-default: false`. To list all
100-
# excluded by default patterns execute `golangci-lint run --help`
101-
# exclude:
102-
# - composite literal uses unkeyed fields
103-
104-
exclude-rules:
105-
# Exclude some linters from running on test files.
106-
- path: _test\.go$|^tests/|^samples/
107-
linters:
108-
- errcheck
109-
- maligned
110-
- linters:
111-
- revive
112-
- stylecheck
113-
text: "use underscores in Go names"
114-
- linters:
115-
- revive
116-
text: "unused-parameter"
117-
- linters:
118-
- unparam
119-
text: "is always false"
120-
121-
exclude-dirs:
122-
- genfiles$
123-
- vendor$
124-
- bin$
125-
exclude-files:
126-
- ".*\\.pb\\.go"
127-
- ".*\\.gen\\.go"
128-
129-
# Independently from option `exclude` we use default exclude patterns,
130-
# it can be disabled by this option. To list all
131-
# excluded by default patterns execute `golangci-lint run --help`.
132-
# Default value for this option is true.
133-
exclude-use-default: true
134-
135-
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
136-
max-per-linter: 0
137-
138-
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
111+
max-issues-per-linter: 0
139112
max-same-issues: 0

Makefile.cross-compiles

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export PATH := $(PATH):`go env GOPATH`/bin
22
export GO111MODULE=on
33
LDFLAGS := -s -w
44

5-
os-archs=darwin:amd64 darwin:arm64 freebsd:amd64 linux:amd64 linux:arm:7 linux:arm:5 linux:arm64 windows:amd64 windows:arm64 linux:mips64 linux:mips64le linux:mips:softfloat linux:mipsle:softfloat linux:riscv64 linux:loong64 android:arm64
5+
os-archs=darwin:amd64 darwin:arm64 freebsd:amd64 openbsd:amd64 linux:amd64 linux:arm:7 linux:arm:5 linux:arm64 windows:amd64 windows:arm64 linux:mips64 linux:mips64le linux:mips:softfloat linux:mipsle:softfloat linux:riscv64 linux:loong64 android:arm64
66

77
all: build
88

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ You can get user's real IP from HTTP request headers `X-Forwarded-For`.
10251025

10261026
#### Proxy Protocol
10271027

1028-
frp supports Proxy Protocol to send user's real IP to local services. It support all types except UDP.
1028+
frp supports Proxy Protocol to send user's real IP to local services.
10291029

10301030
Here is an example for https service:
10311031

Release.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
### Bug Fixes
1+
## Features
22

3-
* **VirtualNet:** Resolved various issues related to connection handling, TUN device management, and stability in the virtual network feature.
3+
* Support for YAML merge functionality (anchors and references with dot-prefixed fields) in strict configuration mode without requiring `--strict-config=false` parameter.
4+
* Support for proxy protocol in UDP proxies to preserve real client IP addresses.

client/proxy/proxy.go

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ import (
2020
"net"
2121
"reflect"
2222
"strconv"
23-
"strings"
2423
"sync"
2524
"time"
2625

2726
libio "github.com/fatedier/golib/io"
2827
libnet "github.com/fatedier/golib/net"
29-
pp "github.com/pires/go-proxyproto"
3028
"golang.org/x/time/rate"
3129

3230
"github.com/fatedier/frp/pkg/config/types"
@@ -35,6 +33,7 @@ import (
3533
plugin "github.com/fatedier/frp/pkg/plugin/client"
3634
"github.com/fatedier/frp/pkg/transport"
3735
"github.com/fatedier/frp/pkg/util/limit"
36+
netpkg "github.com/fatedier/frp/pkg/util/net"
3837
"github.com/fatedier/frp/pkg/util/xlog"
3938
"github.com/fatedier/frp/pkg/vnet"
4039
)
@@ -176,24 +175,9 @@ func (pxy *BaseProxy) HandleTCPWorkConnection(workConn net.Conn, m *msg.StartWor
176175
}
177176

178177
if baseCfg.Transport.ProxyProtocolVersion != "" && m.SrcAddr != "" && m.SrcPort != 0 {
179-
h := &pp.Header{
180-
Command: pp.PROXY,
181-
SourceAddr: connInfo.SrcAddr,
182-
DestinationAddr: connInfo.DstAddr,
183-
}
184-
185-
if strings.Contains(m.SrcAddr, ".") {
186-
h.TransportProtocol = pp.TCPv4
187-
} else {
188-
h.TransportProtocol = pp.TCPv6
189-
}
190-
191-
if baseCfg.Transport.ProxyProtocolVersion == "v1" {
192-
h.Version = 1
193-
} else if baseCfg.Transport.ProxyProtocolVersion == "v2" {
194-
h.Version = 2
195-
}
196-
connInfo.ProxyProtocolHeader = h
178+
// Use the common proxy protocol builder function
179+
header := netpkg.BuildProxyProtocolHeaderStruct(connInfo.SrcAddr, connInfo.DstAddr, baseCfg.Transport.ProxyProtocolVersion)
180+
connInfo.ProxyProtocolHeader = header
197181
}
198182
connInfo.Conn = remote
199183
connInfo.UnderlyingConn = workConn

client/proxy/sudp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,5 +205,5 @@ func (pxy *SUDPProxy) InWorkConn(conn net.Conn, _ *msg.StartWorkConn) {
205205
go workConnReaderFn(workConn, readCh)
206206
go heartbeatFn(sendCh)
207207

208-
udp.Forwarder(pxy.localAddr, readCh, sendCh, int(pxy.clientCfg.UDPPacketSize))
208+
udp.Forwarder(pxy.localAddr, readCh, sendCh, int(pxy.clientCfg.UDPPacketSize), pxy.cfg.Transport.ProxyProtocolVersion)
209209
}

client/proxy/udp.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,7 @@ func (pxy *UDPProxy) InWorkConn(conn net.Conn, _ *msg.StartWorkConn) {
171171
go workConnSenderFn(pxy.workConn, pxy.sendCh)
172172
go workConnReaderFn(pxy.workConn, pxy.readCh)
173173
go heartbeatFn(pxy.sendCh)
174-
udp.Forwarder(pxy.localAddr, pxy.readCh, pxy.sendCh, int(pxy.clientCfg.UDPPacketSize))
174+
175+
// Call Forwarder with proxy protocol version (empty string means no proxy protocol)
176+
udp.Forwarder(pxy.localAddr, pxy.readCh, pxy.sendCh, int(pxy.clientCfg.UDPPacketSize), pxy.cfg.Transport.ProxyProtocolVersion)
175177
}

0 commit comments

Comments
 (0)