mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-04 00:25:04 +00:00
Merged latest master
This commit is contained in:
17 files changed
+115
-30
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -8,6 +8,7 @@ var (
|
||||
KcpConfig *kcpv.Config
|
||||
)
|
||||
|
||||
// IsConnectionReusable returns true if V2Ray is trying to reuse TCP connections.
|
||||
func IsConnectionReusable() bool {
|
||||
return connectionReuse
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user