修订代码; 移除 Makefile 中 build_on信息

This commit is contained in:
e1732a364fed
2000-01-01 00:00:00 +00:00
parent 0bb3e23908
commit ded4d099ee
6 changed files with 20 additions and 11 deletions

View File

@@ -49,7 +49,7 @@ defaultOutFn :=${prefix}${defaultSuffix}
# 注意,因为 macos, linux 和 windows 上 所执行的 md5命令的输出略有不同, 所以完全相同的文件在不同系统上实际得到的 总和md5 值是不同的。所以 md5值 要和 build_on 信息 结合 进行判断。
# BUILD_VERSION :=myversion
BUILD_VERSION :=[ build_on: $(detected_OS), commit: $(shell git rev-parse --short HEAD), all_go_files_md5: $(shell $(md5cmdline)), tags:$(tags) ]
BUILD_VERSION :=[ commit: $(shell git rev-parse --short HEAD), all_go_files_md5: $(shell $(md5cmdline)), tags:$(tags) ]
cmd:=go build -tags "$(tags)" -trimpath -ldflags "-X 'main.Version=${BUILD_VERSION}' -s -w -buildid=" -o

View File

@@ -100,7 +100,7 @@ utls = true #是否使用 utls 来应用 chrome指纹进行伪装, 仅用于
# path = "/ohmygod_verysimple_is_very_simple" # ws的path和 grpc的serviceName 都在这个path里填写, 为了防探测这里越长越随机越好
# 据说下面三行配置可以增强防御
# 据说下面三行配置可以增强防御, 注意因为下面使用了1.2你就没法使用utls, 见issue #205
# extra.tls_minVersion = "1.2"
# extra.tls_maxVersion = "1.2"

View File

@@ -285,6 +285,7 @@ func handleNewIncomeConnection(inServer proxy.Server, defaultClientForThis proxy
if ce := iics.CanLogWarn("tls preread failed"); ce != nil {
ce.Write(zap.Error(e))
}
utils.PutPacket(bs)
wrappedConn.Close()
return
}
@@ -295,16 +296,18 @@ func handleNewIncomeConnection(inServer proxy.Server, defaultClientForThis proxy
if ce := iics.CanLogWarn("tls rejectUnknownSni, client didn't provide sni"); ce != nil {
ce.Write()
}
utils.PutPacket(bs)
wrappedConn.Close()
return
}
//shadowTls自己没有防御功能完全靠我们包外过滤
if tConf.Tls_type == tlsLayer.ShadowTls2_t || tConf.Tls_type == tlsLayer.ShadowTls_t {
if tConf.IsShadowTls() {
if tlsSniff.SniffedServerName != tConf.Host {
if ce := iics.CanLogWarn("tls rejectUnknownSni, client sni not match"); ce != nil {
ce.Write(zap.String("sni", tlsSniff.SniffedServerName), zap.String("shouldBe", tConf.Host))
}
utils.PutPacket(bs)
wrappedConn.Close()
return
}
@@ -347,7 +350,7 @@ func handleNewIncomeConnection(inServer proxy.Server, defaultClientForThis proxy
if header := inServer.HasHeader(); header != nil {
//websocket 可以自行处理header, 不需要额外http包装
//高级层 均可以自行处理header, 不需要额外http包装
if !(advSer != nil && advSer.CanHandleHeaders()) {
var ho *heapObj = iics.heapObj

View File

@@ -65,9 +65,11 @@ func shadowTls1(servername string, clientConn net.Conn) (tlsConn *Conn, err erro
<-finish1
if e1 != nil || e2 != nil {
e := utils.Errs{}
e.Add(utils.ErrsItem{Index: 1, E: e1})
e.Add(utils.ErrsItem{Index: 2, E: e2})
e := utils.Errs{List: []utils.ErrsItem{
{Index: 1, E: e1},
{Index: 2, E: e2},
}}
return nil, e
}
@@ -235,7 +237,7 @@ func shadowCopyHandshakeClientToFake(fakeConn, clientConn net.Conn, hashW *utils
step++
if step > 8 {
return nil, errors.New("shit, shadowTls2 copy loop > 8, maybe under attack")
return nil, errors.New("shadowTls2 copy loop > 8, maybe under attack")
}
}

View File

@@ -55,6 +55,10 @@ type Conf struct {
Extra map[string]any //用于shadowTls
}
func (tConf Conf) IsShadowTls() bool {
return tConf.Tls_type == ShadowTls2_t || tConf.Tls_type == ShadowTls_t
}
func GetTlsConfig(mustHasCert bool, conf Conf) *tls.Config {
var certArray []tls.Certificate
var err error

View File

@@ -53,18 +53,18 @@ func init() {
}
}
//从Pool中获取一个 *bytes.Buffer
// 从Pool中获取一个 *bytes.Buffer
func GetBuf() *bytes.Buffer {
return bufPool.Get().(*bytes.Buffer)
}
//将 buf 放回 Pool
// 将 buf 放回 Pool
func PutBuf(buf *bytes.Buffer) {
buf.Reset()
bufPool.Put(buf)
}
//建议在 Read net.Conn 时, 使用 GetPacket函数 获取到足够大的 []byteMaxBufLen
// 建议在 Read net.Conn 时, 使用 GetPacket函数 获取到足够大的 []byte (MaxPacketLen)
func GetPacket() []byte {
bsPtr := packetPool.Get().(*[]byte)
returnValue := *bsPtr