代码拉取完成,页面将自动刷新
package jumpway
import (
"context"
"net"
"sync"
"github.com/wzshiming/anyproxy"
"github.com/wzshiming/bridge"
)
func RunProxy(ctx context.Context, listener net.Listener, dialer bridge.Dialer) error {
address := listener.Addr().String()
proxies := []string{
"http://" + address,
"socks5://" + address,
"socks4://" + address,
"ssh://" + address,
"view://" + address,
}
proxy, err := anyproxy.NewAnyProxy(ctx, proxies, dialer, nil, BytesPool)
if err != nil {
return err
}
host := proxy.Match(address)
for {
conn, err := listener.Accept()
if err != nil {
return err
}
go host.ServeConn(conn)
}
return nil
}
var DefaultSize = 32 * 1024
type bytesPool struct {
sync.Pool
}
func (b *bytesPool) Get() []byte {
buf := b.Pool.Get().([]byte)
buf = buf[:cap(buf)]
return buf
}
func (b *bytesPool) Put(d []byte) {
if d == nil || len(d) < DefaultSize {
return
}
b.Pool.Put(d)
}
var BytesPool = &bytesPool{
Pool: sync.Pool{
New: func() interface{} {
return make([]byte, DefaultSize)
},
},
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。