Skip to content

Commit 5b1a127

Browse files
committed
chore: optimize codes (golint) and github actions
1 parent 40f75ef commit 5b1a127

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

.github/workflows/stale.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ jobs:
1313
days-before-stale: 90
1414
days-before-close: 5
1515
exempt-issue-labels: "bug,enhancement"
16+
exempt-pr-labels: "bug,enhancement"
17+

proxy/tproxy/tproxy.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import (
1010
"golang.org/x/sys/unix"
1111
)
1212

13-
const IPV6_RECVORIGDSTADDR = 0x4a
14-
1513
// ref: https://github.com/LiamHaworth/go-tproxy/blob/master/tproxy_udp.go
1614
// MIT License by @LiamHaworth
1715

@@ -65,7 +63,7 @@ func ReadFromUDP(conn *net.UDPConn, b []byte) (int, *net.UDPAddr, *net.UDPAddr,
6563
port := binary.BigEndian.Uint16(msg.Data[2:4])
6664
return n, addr, &net.UDPAddr{IP: ip, Port: int(port)}, nil
6765
}
68-
if msg.Header.Level == syscall.SOL_IPV6 && msg.Header.Type == IPV6_RECVORIGDSTADDR {
66+
if msg.Header.Level == syscall.SOL_IPV6 && msg.Header.Type == unix.IPV6_RECVORIGDSTADDR {
6967
ip := net.IP(msg.Data[8:24])
7068
port := binary.BigEndian.Uint16(msg.Data[2:4])
7169
return n, addr, &net.UDPAddr{IP: ip, Port: int(port)}, nil

proxy/vmess/chunk_size_parser.go renamed to proxy/vmess/size.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ type ChunkSizeDecoder interface {
1818
Decode([]byte) (uint16, error)
1919
}
2020

21+
// ShakeSizeParser implements ChunkSizeEncoder & ChunkSizeDecoder.
2122
type ShakeSizeParser struct {
2223
shake sha3.ShakeHash
2324
buffer [2]byte
2425
}
2526

27+
// NewShakeSizeParser returns a new ShakeSizeParser.
2628
func NewShakeSizeParser(nonce []byte) *ShakeSizeParser {
2729
shake := sha3.NewShake128()
2830
shake.Write(nonce)
@@ -31,6 +33,7 @@ func NewShakeSizeParser(nonce []byte) *ShakeSizeParser {
3133
}
3234
}
3335

36+
// SizeBytes implements ChunkSizeEncoder method.
3437
func (*ShakeSizeParser) SizeBytes() int32 {
3538
return 2
3639
}
@@ -40,12 +43,14 @@ func (s *ShakeSizeParser) next() uint16 {
4043
return binary.BigEndian.Uint16(s.buffer[:])
4144
}
4245

46+
// Decode implements ChunkSizeDecoder method.
4347
func (s *ShakeSizeParser) Decode(b []byte) (uint16, error) {
4448
mask := s.next()
4549
size := binary.BigEndian.Uint16(b)
4650
return mask ^ size, nil
4751
}
4852

53+
// Encode implements ChunkSizeEncoder method.
4954
func (s *ShakeSizeParser) Encode(size uint16, b []byte) []byte {
5055
mask := s.next()
5156
binary.BigEndian.PutUint16(b, mask^size)

0 commit comments

Comments
 (0)