mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-10-31 03:56:20 +08:00
解决trojan无法兼容trojan-go客户端的问题.
This commit is contained in:
6
main.go
6
main.go
@@ -641,7 +641,7 @@ func handshakeInserver(iics *incomingInserverConnState) (wlc io.ReadWriteCloser,
|
||||
return
|
||||
}
|
||||
|
||||
session := inServer.GetServerInnerMuxSession(mh.ReadWriteCloser)
|
||||
session := inServer.GetServerInnerMuxSession(mh)
|
||||
|
||||
if session == nil {
|
||||
err = utils.ErrFailed
|
||||
@@ -660,7 +660,9 @@ func handshakeInserver(iics *incomingInserverConnState) (wlc io.ReadWriteCloser,
|
||||
|
||||
stream, err := session.AcceptStream()
|
||||
if err != nil {
|
||||
utils.Debug("inServer try accept stream err")
|
||||
if ce := utils.CanLogDebug("mux inServer try accept stream failed"); ce != nil {
|
||||
ce.Write(zap.Error(err))
|
||||
}
|
||||
|
||||
session.Close()
|
||||
return
|
||||
|
||||
@@ -37,9 +37,18 @@ func PrintAllClientNames() {
|
||||
//用于Server返回一个可被识别为innerMux的结构
|
||||
type MuxConnHaser struct {
|
||||
io.ReadWriteCloser
|
||||
OptionalReader io.Reader
|
||||
IsMux bool
|
||||
}
|
||||
|
||||
func (mc MuxConnHaser) Read(p []byte) (n int, err error) {
|
||||
if r := mc.OptionalReader; r != nil {
|
||||
return r.Read(p)
|
||||
} else {
|
||||
return mc.ReadWriteCloser.Read(p)
|
||||
}
|
||||
}
|
||||
|
||||
// Client 用于向 服务端 拨号.
|
||||
//服务端是一种 “泛目标”代理,所以我们客户端的 Handshake 要传入目标地址, 来告诉它 我们 想要到达的 目标地址.
|
||||
// 一个Client 掌握从最底层的tcp等到最上层的 代理协议间的所有数据;
|
||||
@@ -282,7 +291,7 @@ func (pcs *ProxyCommonStruct) HasInnerMux() (int, string) {
|
||||
return 0, ""
|
||||
}
|
||||
|
||||
func (pcs *ProxyCommonStruct) GetServerInnerMuxSession(wlc io.ReadWriteCloser) *smux.Session {
|
||||
func (*ProxyCommonStruct) GetServerInnerMuxSession(wlc io.ReadWriteCloser) *smux.Session {
|
||||
smuxConfig := smux.DefaultConfig()
|
||||
smuxSession, err := smux.Server(wlc, smuxConfig)
|
||||
if err != nil {
|
||||
|
||||
@@ -159,10 +159,14 @@ realPart:
|
||||
}
|
||||
|
||||
if ismux {
|
||||
return proxy.MuxConnHaser{
|
||||
mh := proxy.MuxConnHaser{
|
||||
ReadWriteCloser: underlay,
|
||||
IsMux: true,
|
||||
}, nil, targetAddr, nil
|
||||
}
|
||||
if readbuf.Len() > 0 {
|
||||
mh.OptionalReader = io.MultiReader(readbuf, underlay)
|
||||
}
|
||||
return mh, nil, targetAddr, nil
|
||||
}
|
||||
|
||||
if isudp {
|
||||
|
||||
Reference in New Issue
Block a user