Merged latest master

This commit is contained in:
Shelikhoo committed 2016-06-12 12:58:20 +08:00
commit a9ef8d27bd
17 files changed
+115 -30

No files matched your search

+2
View File
@@ -2,12 +2,14 @@ package transport
import "github.com/v2ray/v2ray-core/transport/hub/kcpv"
// Config for V2Ray transport layer.
type Config struct {
ConnectionReuse bool
enableKcp bool
kcpConfig *kcpv.Config
}
// Apply applies this Config.
func (this *Config) Apply() error {
if this.ConnectionReuse {
connectionReuse = true
+20
View File
@@ -1,12 +1,18 @@
package hub
import (
"errors"
"net"
"reflect"
"time"
"github.com/v2ray/v2ray-core/transport"
)
var (
ErrInvalidConn = errors.New("Invalid Connection.")
)
type ConnectionHandler func(*Connection)
type ConnectionManager interface {
@@ -73,3 +79,17 @@ func (this *Connection) SetReusable(reusable bool) {
func (this *Connection) Reusable() bool {
return this.reusable
}
func (this *Connection) SysFd() (int, error) {
cv := reflect.ValueOf(this.conn)
switch ce := cv.Elem(); ce.Kind() {
case reflect.Struct:
netfd := ce.FieldByName("conn").FieldByName("fd")
switch fe := netfd.Elem(); fe.Kind() {
case reflect.Struct:
fd := fe.FieldByName("sysfd")
return int(fd.Int()), nil
}
}
return 0, ErrInvalidConn
}
+1
View File
@@ -8,6 +8,7 @@ var (
KcpConfig *kcpv.Config
)
// IsConnectionReusable returns true if V2Ray is trying to reuse TCP connections.
func IsConnectionReusable() bool {
return connectionReuse
}