Skip to content

Commit

Permalink
Refactor(pool): move to internal
Browse files Browse the repository at this point in the history
lint

rr
  • Loading branch information
xjasonlyu committed Aug 31, 2024
1 parent 978803c commit 1f81529
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 27 deletions.
17 changes: 0 additions & 17 deletions common/pool/buffer.go

This file was deleted.

3 changes: 1 addition & 2 deletions common/pool/alloc.go → internal/pool/alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ func (alloc *Allocator) Put(buf []byte) error {
return errors.New("allocator Put() incorrect buffer size")
}

//lint:ignore SA6002 ignore temporarily
//nolint
//nolint:staticcheck
alloc.buffers[b].Put(buf)
return nil
}
Expand Down
File renamed without changes.
17 changes: 17 additions & 0 deletions internal/pool/buffer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package pool

import (
"bytes"
"sync"
)

var _bufferPool = sync.Pool{New: func() any { return &bytes.Buffer{} }}

func GetBuffer() *bytes.Buffer {
return _bufferPool.Get().(*bytes.Buffer)
}

func PutBuffer(buf *bytes.Buffer) {
buf.Reset()
_bufferPool.Put(buf)
}
File renamed without changes.
2 changes: 1 addition & 1 deletion proxy/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

"github.com/go-gost/relay"

"github.com/xjasonlyu/tun2socks/v2/common/pool"
"github.com/xjasonlyu/tun2socks/v2/dialer"
"github.com/xjasonlyu/tun2socks/v2/internal/pool"
M "github.com/xjasonlyu/tun2socks/v2/metadata"
"github.com/xjasonlyu/tun2socks/v2/proxy/proto"
)
Expand Down
2 changes: 1 addition & 1 deletion transport/shadowsocks/shadowaead/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io"
"net"

"github.com/xjasonlyu/tun2socks/v2/common/pool"
"github.com/xjasonlyu/tun2socks/v2/internal/pool"
)

// ErrShortPacket means that the packet is too short for a valid encrypted packet.
Expand Down
2 changes: 1 addition & 1 deletion transport/shadowsocks/shadowaead/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"io"
"net"

"github.com/xjasonlyu/tun2socks/v2/common/pool"
"github.com/xjasonlyu/tun2socks/v2/internal/pool"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion transport/shadowsocks/shadowstream/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io"
"net"

"github.com/xjasonlyu/tun2socks/v2/common/pool"
"github.com/xjasonlyu/tun2socks/v2/internal/pool"
)

// ErrShortPacket means the packet is too short to be a valid encrypted packet.
Expand Down
2 changes: 1 addition & 1 deletion transport/simple-obfs/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"net"
"net/http"

"github.com/xjasonlyu/tun2socks/v2/common/pool"
"github.com/xjasonlyu/tun2socks/v2/internal/pool"
)

// HTTPObfs is shadowsocks http simple-obfs implementation
Expand Down
2 changes: 1 addition & 1 deletion transport/simple-obfs/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net"
"time"

"github.com/xjasonlyu/tun2socks/v2/common/pool"
"github.com/xjasonlyu/tun2socks/v2/internal/pool"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion tunnel/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"sync"
"time"

"github.com/xjasonlyu/tun2socks/v2/common/pool"
"github.com/xjasonlyu/tun2socks/v2/core/adapter"
"github.com/xjasonlyu/tun2socks/v2/internal/pool"
"github.com/xjasonlyu/tun2socks/v2/log"
M "github.com/xjasonlyu/tun2socks/v2/metadata"
"github.com/xjasonlyu/tun2socks/v2/tunnel/statistic"
Expand Down
2 changes: 1 addition & 1 deletion tunnel/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"sync"
"time"

"github.com/xjasonlyu/tun2socks/v2/common/pool"
"github.com/xjasonlyu/tun2socks/v2/core/adapter"
"github.com/xjasonlyu/tun2socks/v2/internal/pool"
"github.com/xjasonlyu/tun2socks/v2/log"
M "github.com/xjasonlyu/tun2socks/v2/metadata"
"github.com/xjasonlyu/tun2socks/v2/tunnel/statistic"
Expand Down

0 comments on commit 1f81529

Please sign in to comment.