代码拉取完成,页面将自动刷新
package backup
import (
"errors"
"net"
"os"
"reflect"
)
// filer describes an object that has ability to return os.File.
type filer interface {
// File returns a copy of object's file descriptor.
File() (*os.File, error)
}
func handle(x interface{}) (socket_t, error) {
f, ok := x.(filer)
if !ok {
return -1, errors.New("not filter")
}
// Get a copy of fd.
file, err := f.File()
if err != nil {
return -1, err
}
return int(file.Fd()), nil
}
func handle3(conn net.Conn) (socket_t, error) {
tcpConn := conn.(*net.TCPConn)
file, err := tcpConn.File()
if err != nil {
return -1, err
}
return int(file.Fd()), nil
}
func socketFD(conn net.Conn) int {
//tls := reflect.TypeOf(conn.UnderlyingConn()) == reflect.TypeOf(&tls.Conn{})
// Extract the file descriptor associated with the connection
//connVal := reflect.Indirect(reflect.ValueOf(conn)).FieldByName("conn").Elem()
tcpConn := reflect.Indirect(reflect.ValueOf(conn)).FieldByName("conn")
//if tls {
// tcpConn = reflect.Indirect(tcpConn.Elem())
//}
fdVal := tcpConn.FieldByName("fd")
pfdVal := reflect.Indirect(fdVal).FieldByName("pfd")
return int(pfdVal.FieldByName("Sysfd").Int())
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。