mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-12-24 13:27:56 +08:00
修订代码; 移除 Makefile 中 build_on信息
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
7
main.go
7
main.go
@@ -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
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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函数 获取到足够大的 []byte(MaxBufLen)
|
||||
// 建议在 Read net.Conn 时, 使用 GetPacket函数 获取到足够大的 []byte (MaxPacketLen)
|
||||
func GetPacket() []byte {
|
||||
bsPtr := packetPool.Get().(*[]byte)
|
||||
returnValue := *bsPtr
|
||||
|
||||
Reference in New Issue
Block a user