1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00

KCP:func ListenKCP finished

This commit is contained in:
Shelikhoo 2016-06-12 13:14:07 +08:00
parent a9ef8d27bd
commit 70201d8879
No known key found for this signature in database
GPG Key ID: 7791BDB0709ABD21

View File

@ -6,6 +6,7 @@ import (
"time"
"github.com/v2ray/v2ray-core/common/log"
v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/transport"
"github.com/v2ray/v2ray-core/transport/hub/kcpv"
"github.com/xtaci/kcp-go"
@ -126,3 +127,12 @@ func DialKCP(dest v2net.Destination) (*KCPVconn, error) {
}
return kcvn, nil
}
func ListenKCP(address v2net.Address, port v2net.Port) (*KCPVlistener, error) {
kcpconf := transport.KcpConfig
cpip, _ := kcpv.GetChipher(kcpconf.Key)
laddr := address.String() + ":" + port.String()
kcl, err := kcp.ListenWithOptions(kcpconf.AdvancedConfigs.Fec, laddr, cpip)
kcvl := &KCPVlistener{lst: kcl, conf: kcpconf}
return kcvl, err
}