Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix snail007#80

Signed-off-by: arraykeys@gmail.com <arraykeys@gmail.com>
  • Loading branch information
snail007 committed May 22, 2018
1 parent 8649bbc commit f559fb1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ goproxy
*.exe
*.exe~
.*
*.prof
!.gitignore
release-*
proxy.crt
Expand Down
9 changes: 6 additions & 3 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ proxy更新日志
v4.8
1.优化了SPS连接HTTP上级的指令,避免了某些代理不响应的问题.
2.SPS功能增加了参数:
--disable-http:禁用http(s)代理
--disable-socks:禁用socks代理
默认都是false(开启).
--disable-http:禁用http(s)代理
--disable-socks:禁用socks代理
默认都是false(开启).
3.重构了部分代码的日志部分,保证了日志按着预期输出.
4.修复了sps\http代理初始化服务的时机不正确,导致nil异常的bug.
5.优化了sps日志输出.
6.--debug参数增加了Profiling功能,可以保存cpu,内存等多种调试数据到文件.
7.优化了服务注册,避免了不必要的内存开销.
8.增加了Dockerfile和docker安装手册.
9.优化了ioCopy避免了内存泄漏,大大提升了内存占用的稳定性.



v4.7
Expand Down
3 changes: 2 additions & 1 deletion utils/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ func IoBind(dst io.ReadWriteCloser, src io.ReadWriteCloser, fn func(err interfac
}()
}
func ioCopy(dst io.ReadWriter, src io.ReadWriter) (err error) {
buf := make([]byte, 32*1024)
buf := LeakyBuffer.Get()
defer LeakyBuffer.Put(buf)
n := 0
for {
n, err = src.Read(buf)
Expand Down
6 changes: 3 additions & 3 deletions utils/ss/leakybuf.go → utils/leakybuf.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Provides leaky buffer, based on the example in Effective Go.
package ss
package utils

type LeakyBuf struct {
bufSize int // size of each buffer
freeList chan []byte
}

const leakyBufSize = 4108 // data.len(2) + hmacsha1(10) + data(4096)
const LeakyBufSize = 2048 // data.len(2) + hmacsha1(10) + data(4096)
const maxNBuf = 2048

var leakyBuf = NewLeakyBuf(maxNBuf, leakyBufSize)
var LeakyBuffer = NewLeakyBuf(maxNBuf, LeakyBufSize)

// NewLeakyBuf creates a leaky buffer which can hold at most n buffer, each
// with bufSize bytes.
Expand Down
7 changes: 7 additions & 0 deletions utils/ss/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ import (
"net"
"os"
"strconv"

"github.com/snail007/goproxy/utils"
)

const leakyBufSize = 4108 // data.len(2) + hmacsha1(10) + data(4096)
const maxNBuf = 2048

var leakyBuf = utils.NewLeakyBuf(maxNBuf, leakyBufSize)

func IsFileExists(path string) (bool, error) {
stat, err := os.Stat(path)
if err == nil {
Expand Down

0 comments on commit f559fb1

Please sign in to comment.