mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-31 06:26:53 -05:00
Removed manadory mandatory requirement for Read/Write Timeout
This commit is contained in:
parent
9315bb29fb
commit
d0d63ee5b3
@ -17,6 +17,7 @@ func (this *Config) Apply() error {
|
||||
enableKcp = this.enableKcp
|
||||
if enableKcp {
|
||||
KcpConfig = this.kcpConfig
|
||||
connectionReuse = false
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -82,16 +82,9 @@ func DialKCP3(src v2net.Address, dest v2net.Destination, proxyMeta *proxy.Outbou
|
||||
src = v2net.AnyIP
|
||||
}
|
||||
id := src.String() + "-" + dest.NetAddr()
|
||||
var conn net.Conn
|
||||
if dest.IsTCP() && transport.IsConnectionReusable() {
|
||||
conn = globalCache.Get(id)
|
||||
}
|
||||
if conn == nil {
|
||||
var err error
|
||||
conn, err = DialWithoutCache3(src, dest, proxyMeta)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
conn, err := DialWithoutCache3(src, dest, proxyMeta)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Connection{
|
||||
dest: id,
|
||||
|
@ -13,8 +13,10 @@ import (
|
||||
)
|
||||
|
||||
type KCPVlistener struct {
|
||||
lst *kcp.Listener
|
||||
conf *kcpv.Config
|
||||
lst *kcp.Listener
|
||||
conf *kcpv.Config
|
||||
previousSocketid map[int]uint32
|
||||
previousSocketid_mapid int
|
||||
}
|
||||
|
||||
func (kvl *KCPVlistener) Accept() (net.Conn, error) {
|
||||
@ -23,6 +25,28 @@ func (kvl *KCPVlistener) Accept() (net.Conn, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if kvl.previousSocketid == nil {
|
||||
kvl.previousSocketid = make(map[int]uint32)
|
||||
}
|
||||
|
||||
var badbit bool = false
|
||||
|
||||
for _, key := range kvl.previousSocketid {
|
||||
log.Info("kcp: listener testing,", key, ":", conn.GetConv())
|
||||
if key == conn.GetConv() {
|
||||
badbit = true
|
||||
}
|
||||
}
|
||||
if badbit {
|
||||
return nil, errors.New("KCP:ConnDup, Don't worry~")
|
||||
} else {
|
||||
kvl.previousSocketid_mapid++
|
||||
kvl.previousSocketid[kvl.previousSocketid_mapid] = conn.GetConv()
|
||||
if kvl.previousSocketid_mapid >= 512 {
|
||||
delete(kvl.previousSocketid, kvl.previousSocketid_mapid-512)
|
||||
}
|
||||
}
|
||||
|
||||
kcv := &KCPVconn{hc: conn}
|
||||
kcv.conf = kvl.conf
|
||||
err = kcv.ApplyConf()
|
||||
|
@ -18,5 +18,5 @@ type Config struct {
|
||||
}
|
||||
|
||||
var DefaultAdvancedConfigs = &AdvancedConfig{
|
||||
Mtu: 1350, Sndwnd: 1024, Rcvwnd: 1024, Fec: 4, Dscp: 0, ReadTimeout: 60, WriteTimeout: 40, Acknodelay: false,
|
||||
Mtu: 1350, Sndwnd: 1024, Rcvwnd: 1024, Fec: 4, Dscp: 0, ReadTimeout: 18600, WriteTimeout: 18500, Acknodelay: false,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user