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

+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
}