예제 #1
0
// Package buffers provides shared byte buffers based on bpool
package buffers

import (
	"github.com/oxtoacart/bpool"
)

const (
	maxBuffers = 2500
	bufferSize = 32768
)

var (
	pool = bpool.NewBytePool(maxBuffers, bufferSize)
)

// Pool gets the byte pool
func Pool() *bpool.BytePool {
	return pool
}

// Get gets a byte buffer from the pool
func Get() []byte {
	return pool.Get()
}

// Put returns a byte buffer to the pool
func Put(b []byte) {
	pool.Put(b)
}
예제 #2
0
파일: client.go 프로젝트: udo-tech-team/mus
	idType  = 0 // address type index
	idIP0   = 1 // ip addres start index
	idDmLen = 1 // domain address length index
	idDm0   = 2 // domain address start index

	typeIPv4 = 1 // type is ipv4 address
	typeDm   = 3 // type is domain address
	typeIPv6 = 4 // type is ipv6 address

	lenIPv4   = 1 + net.IPv4len + 2 // 1addrType + ipv4 + 2port
	lenIPv6   = 1 + net.IPv6len + 2 // 1addrType + ipv6 + 2port
	lenDmBase = 1 + 1 + 2           // 1addrType + 1addrLen + 2port, plus addrLen
)

var (
	bytePool = bpool.NewBytePool(4096, 2048)
)

type SSClienter interface {
	net.Conn
	Remote() net.Conn
}

type client struct {
	mu sync.Mutex
	*ss.Conn
	server *ProxyServer
	remote *remote
	closed bool
}