Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/net.go: There is no way to get the Unix/Linux socket file descriptor which is necessary for other encrypted communication library #39235

Closed
Kira818 opened this issue May 24, 2020 · 1 comment

Comments

@Kira818
Copy link

@Kira818 Kira818 commented May 24, 2020

What version of Go are you using (go version)?

$ go version
go version go1.14.3 linux/amd64

Does this issue reproduce with the latest release?

Yes. The latest release has no methed to get the Unix/Linux socket file descriptor either.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build780506382=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Used cgo and C language library to realize encrypted communication with sm2, sm3 and sm4 algorithm. At first, I can not fetch the tcp socket file descriptor which will be the input argument of the C language library. Then, I add a methed in net.go to fetch the Unix/Linux file descriptor to solve this problem.

What did you expect to see?

There is a specific method to get Unix/Linux socket file descriptor, so I can operate the fd freely under certain circumstances.

Thank you for reading.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented May 24, 2020

You can use https://golang.org/pkg/net/#TCPConn.SyscallConn to get a syscall.RawConn and then you can call the Control method.

We don't generally use the issue tracker for questions. You will get better and faster answers using a forum. See https://golang.org/wiki/Questions. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.