Skip to content

Commit 16c152f

Browse files
committed
chore: Bump version to v3.1-beta.4
1 parent b8e10db commit 16c152f

File tree

9 files changed

+62
-42
lines changed

9 files changed

+62
-42
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fmt:
134134

135135
fmt_install:
136136
go install -v mvdan.cc/gofumpt@latest
137-
go install -v github.com/daixiang0/gci@v0.4.0
137+
go install -v github.com/daixiang0/gci@latest
138138

139139
lint:
140140
golangci-lint run ./...

common/proxyprotocol/client_v2_test.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ func TestClientV2(t *testing.T) {
2525
},
2626
destination: netip.MustParseAddrPort("127.0.0.1:1025"),
2727
// VER IP/TCP LENGTH
28-
expect: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x11, 0x00, 0x0C,
28+
expect: []byte{
29+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x11, 0x00, 0x0C,
2930
// IPV4 -------------| IPV4 ----------------| SRC PORT DEST PORT
30-
0x7F, 0x00, 0x00, 0x01, 0x7F, 0x00, 0x00, 0x01, 0xCA, 0x2B, 0x04, 0x01},
31+
0x7F, 0x00, 0x00, 0x01, 0x7F, 0x00, 0x00, 0x01, 0xCA, 0x2B, 0x04, 0x01,
32+
},
3133
},
3234
{
3335
name: "UDP4 127.0.0.1",
@@ -39,8 +41,10 @@ func TestClientV2(t *testing.T) {
3941
},
4042
destination: netip.MustParseAddrPort("127.0.0.1:1025"),
4143
// IP/UDP
42-
expect: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x12, 0x00, 0x0C,
43-
0x7F, 0x00, 0x00, 0x01, 0x7F, 0x00, 0x00, 0x01, 0xCA, 0x2B, 0x04, 0x01},
44+
expect: []byte{
45+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x12, 0x00, 0x0C,
46+
0x7F, 0x00, 0x00, 0x01, 0x7F, 0x00, 0x00, 0x01, 0xCA, 0x2B, 0x04, 0x01,
47+
},
4448
},
4549
{
4650
name: "TCP6 Proxy for TCP4 127.0.0.1",
@@ -52,11 +56,13 @@ func TestClientV2(t *testing.T) {
5256
},
5357
destination: netip.MustParseAddrPort("[::ffff:127.0.0.1]:1025"),
5458
// VER IP/TCP LENGTH
55-
expect: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x21, 0x00, 0x24,
59+
expect: []byte{
60+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x21, 0x00, 0x24,
5661
// IPV6 -------------------------------------------------------------------------------------|
5762
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x01,
5863
// IPV6 -------------------------------------------------------------------------------------| SRC PORT DEST PORT
59-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x01, 0xCC, 0x4C, 0x04, 0x01},
64+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x01, 0xCC, 0x4C, 0x04, 0x01,
65+
},
6066
},
6167
{
6268
name: "TCP6 Maximal",
@@ -68,11 +74,13 @@ func TestClientV2(t *testing.T) {
6874
},
6975
destination: netip.MustParseAddrPort("[FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF]:65535"),
7076
// VER IP/TCP LENGTH
71-
expect: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x21, 0x00, 0x24,
77+
expect: []byte{
78+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x21, 0x00, 0x24,
7279
// IPV6 -------------------------------------------------------------------------------------|
7380
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
7481
// IPV6 -------------------------------------------------------------------------------------| SRC PORT DEST PORT
75-
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
82+
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
83+
},
7684
},
7785
{
7886
name: "TCP6 Proxy for TCP6 ::1",
@@ -84,7 +92,8 @@ func TestClientV2(t *testing.T) {
8492
},
8593
destination: netip.MustParseAddrPort("[::1]:1025"),
8694
// VER IP/TCP LENGTH
87-
expect: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x21, 0x00, 0x24,
95+
expect: []byte{
96+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x21, 0x00, 0x24,
8897
// IPV6 -------------------------------------------------------------------------------------|
8998
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
9099
// IPV6 -------------------------------------------------------------------------------------| SRC PORT DEST PORT
@@ -101,7 +110,8 @@ func TestClientV2(t *testing.T) {
101110
},
102111
destination: netip.MustParseAddrPort("[::1]:1025"),
103112
// VER IP/UDP LENGTH
104-
expect: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x22, 0x00, 0x24,
113+
expect: []byte{
114+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x22, 0x00, 0x24,
105115
// IPV6 -------------------------------------------------------------------------------------|
106116
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
107117
// IPV6 -------------------------------------------------------------------------------------| SRC PORT DEST PORT

common/proxyprotocol/header.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ const (
3232
TransportProtocolDatagram = 0x2
3333
)
3434

35-
var (
36-
ErrNotProxyProtocol = errors.New("not PROXY protocol")
37-
)
35+
var ErrNotProxyProtocol = errors.New("not PROXY protocol")
3836

3937
type Header struct {
4038
Version uint8

common/proxyprotocol/server_v2_test.go

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,65 +19,77 @@ func TestServerV2(t *testing.T) {
1919
{
2020
name: "TCP4 127.0.0.1",
2121
// VER IP/TCP LENGTH
22-
header: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x11, 0x00, 0x0C,
22+
header: []byte{
23+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x11, 0x00, 0x0C,
2324
// IPV4 -------------| IPV4 ----------------| SRC PORT DEST PORT
24-
0x7F, 0x00, 0x00, 0x01, 0x7F, 0x00, 0x00, 0x01, 0xCA, 0x2B, 0x04, 0x01},
25+
0x7F, 0x00, 0x00, 0x01, 0x7F, 0x00, 0x00, 0x01, 0xCA, 0x2B, 0x04, 0x01,
26+
},
2527
source: netip.MustParseAddrPort("127.0.0.1:51755"),
2628
protocol: TransportProtocolStream | TransportProtocolIPv4,
2729
},
2830
{
2931
name: "UDP4 127.0.0.1",
3032
// IP/UDP
31-
header: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x12, 0x00, 0x0C,
32-
0x7F, 0x00, 0x00, 0x01, 0x7F, 0x00, 0x00, 0x01, 0xCA, 0x2B, 0x04, 0x01},
33+
header: []byte{
34+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x12, 0x00, 0x0C,
35+
0x7F, 0x00, 0x00, 0x01, 0x7F, 0x00, 0x00, 0x01, 0xCA, 0x2B, 0x04, 0x01,
36+
},
3337
source: netip.MustParseAddrPort("127.0.0.1:51755"),
3438
protocol: TransportProtocolDatagram | TransportProtocolIPv4,
3539
},
3640
{
3741
name: "TCP6 Proxy for TCP4 127.0.0.1",
3842
// VER IP/TCP LENGTH
39-
header: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x21, 0x00, 0x24,
43+
header: []byte{
44+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x21, 0x00, 0x24,
4045
// IPV6 -------------------------------------------------------------------------------------|
4146
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x01,
4247
// IPV6 -------------------------------------------------------------------------------------| SRC PORT DEST PORT
43-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x01, 0xCC, 0x4C, 0x04, 0x01},
48+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x01, 0xCC, 0x4C, 0x04, 0x01,
49+
},
4450
source: netip.MustParseAddrPort("127.0.0.1:52300"),
4551
protocol: TransportProtocolStream | TransportProtocolIPv6,
4652
},
4753
{
4854
name: "TCP6 Maximal",
4955
// VER IP/TCP LENGTH
50-
header: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x21, 0x00, 0x24,
56+
header: []byte{
57+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x21, 0x00, 0x24,
5158
// IPV6 -------------------------------------------------------------------------------------|
5259
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
5360
// IPV6 -------------------------------------------------------------------------------------| SRC PORT DEST PORT
54-
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
61+
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
62+
},
5563
source: netip.MustParseAddrPort("[FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF]:65535"),
5664
protocol: TransportProtocolStream | TransportProtocolIPv6,
5765
},
5866
{
5967
name: "TCP6 Proxy for TCP6 ::1",
6068
// VER IP/TCP LENGTH
61-
header: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x21, 0x00, 0x2B,
69+
header: []byte{
70+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x21, 0x00, 0x2B,
6271
// IPV6 -------------------------------------------------------------------------------------|
6372
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
6473
// IPV6 -------------------------------------------------------------------------------------| SRC PORT DEST PORT
6574
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xCF, 0x8F, 0x04, 0x01,
66-
//TLVs
67-
0x03, 0x00, 0x04, 0xFD, 0x16, 0xEE, 0x60},
75+
// TLVs
76+
0x03, 0x00, 0x04, 0xFD, 0x16, 0xEE, 0x60,
77+
},
6878
source: netip.MustParseAddrPort("[::1]:53135"),
6979
protocol: TransportProtocolStream | TransportProtocolIPv6,
7080
},
7181
{
7282
name: "UDP6 Proxy for UDP6 ::1",
7383
// VER IP/UDP LENGTH
74-
header: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x22, 0x00, 0x2B,
84+
header: []byte{
85+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x21, 0x22, 0x00, 0x2B,
7586
// IPV6 -------------------------------------------------------------------------------------|
7687
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
7788
// IPV6 -------------------------------------------------------------------------------------| SRC PORT DEST PORT
7889
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xCF, 0x8F, 0x04, 0x01,
79-
//TLVs
80-
0x03, 0x00, 0x04, 0xFD, 0x16, 0xEE, 0x60},
90+
// TLVs
91+
0x03, 0x00, 0x04, 0xFD, 0x16, 0xEE, 0x60,
92+
},
8193
source: netip.MustParseAddrPort("[::1]:53135"),
8294
protocol: TransportProtocolDatagram | TransportProtocolIPv6,
8395
},
@@ -88,8 +100,10 @@ func TestServerV2(t *testing.T) {
88100
},
89101
{
90102
name: "Local with trailing bytes (TLVs)",
91-
header: []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x20, 0xFF, 0x00, 0x07,
92-
0x03, 0x00, 0x04, 0xFD, 0x16, 0xEE, 0x60},
103+
header: []byte{
104+
0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A, 0x20, 0xFF, 0x00, 0x07,
105+
0x03, 0x00, 0x04, 0xFD, 0x16, 0xEE, 0x60,
106+
},
93107
isLocal: true,
94108
},
95109
}

config/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"context"
55
"encoding/json"
66
"errors"
7-
"github.com/layou233/zbproxy/v3/common"
8-
"github.com/layou233/zbproxy/v3/common/jsonx"
97
"os"
108
"time"
119

10+
"github.com/layou233/zbproxy/v3/common"
11+
"github.com/layou233/zbproxy/v3/common/jsonx"
1212
"github.com/layou233/zbproxy/v3/common/set"
1313

1414
"github.com/fsnotify/fsnotify"

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/layou233/zbproxy/v3
33
go 1.20
44

55
require (
6-
github.com/fsnotify/fsnotify v1.8.0
7-
github.com/phuslu/log v1.0.113
6+
github.com/fsnotify/fsnotify v1.9.0
7+
github.com/phuslu/log v1.0.117
88
github.com/zhangyunhao116/fastrand v0.4.0
99
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
1010
golang.org/x/sys v0.30.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
2-
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
3-
github.com/phuslu/log v1.0.113 h1:Koq5A+8ourLX4vhkhW4HCJjo+jEtzMDhqvUUid/5m24=
4-
github.com/phuslu/log v1.0.113/go.mod h1:F8osGJADo5qLK/0F88djWwdyoZZ9xDJQL1HYRHFEkS0=
1+
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
2+
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
3+
github.com/phuslu/log v1.0.117 h1:kyvRlP4ReYWEzmYKsHUNMeYGvmXDTdN3uA0xrNssZ54=
4+
github.com/phuslu/log v1.0.117/go.mod h1:F8osGJADo5qLK/0F88djWwdyoZZ9xDJQL1HYRHFEkS0=
55
github.com/zhangyunhao116/fastrand v0.4.0 h1:86QB6Y+GGgLZRFRDCjMmAS28QULwspK9sgL5d1Bx3H4=
66
github.com/zhangyunhao116/fastrand v0.4.0/go.mod h1:vIyo6EyBhjGKpZv6qVlkPl4JVAklpMM4DSKzbAkMguA=
77
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M=

protocol/minecraft/sniff.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import (
1212
"github.com/layou233/zbproxy/v3/common/mcprotocol"
1313
)
1414

15-
var (
16-
ErrBadPacket = errors.New("bad Minecraft handshake packet")
17-
)
15+
var ErrBadPacket = errors.New("bad Minecraft handshake packet")
1816

1917
func SniffClientHandshake(conn bufio.PeekConn, metadata *adapter.Metadata) error {
2018
if metadata.Minecraft == nil {

version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package version
22

3-
const Version = "3.1-beta.3"
3+
const Version = "3.1-beta.4"

0 commit comments

Comments
 (0)