mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-29 23:34:44 +00:00
Merged latest master
This commit is contained in:
17 files changed
+115
-30
No files matched your search
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user