mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-21 16:56:27 -05:00
KCP: Added Dial func
This commit is contained in:
parent
e84d52263d
commit
2fd963801c
@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
"github.com/v2ray/v2ray-core/transport"
|
||||
"github.com/v2ray/v2ray-core/transport/hub/kcpv"
|
||||
"github.com/xtaci/kcp-go"
|
||||
)
|
||||
@ -109,3 +110,19 @@ func (kcpvc *KCPVconn) SetReadDeadline(t time.Time) error {
|
||||
func (kcpvc *KCPVconn) SetWriteDeadline(t time.Time) error {
|
||||
return kcpvc.hc.SetWriteDeadline(t)
|
||||
}
|
||||
|
||||
func DialKCP(dest v2net.Destination) (*KCPVconn, error) {
|
||||
kcpconf := transport.KcpConfig
|
||||
cpip, _ := kcpv.GetChipher(kcpconf.Key)
|
||||
kcv, err := kcp.DialWithOptions(kcpconf.AdvancedConfigs.Fec, dest.NetAddr(), cpip)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
kcvn := &KCPVconn{hc: kcv}
|
||||
kcvn.conf = kcpconf
|
||||
err = kcvn.ApplyConf()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return kcvn, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user