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
windows net: replacement for /etc/protocols #2215
Labels
Comments
You are correct. readProtocols will not work on windows. I think, getprotobyname is a good alternative. Send a fix, if you like. Labels changed: added packagebug, os-windows. Owner changed to @alexbrainman. Status changed to Accepted. |
Thanks. I will be submitting a patch for issues 2215 and 2216. This will also present a new public net.LookupProtocol() function, which will invoke getprotobyname. I prefer to use the reentrant version on Unix - getprotobyname_r, however this is technically not POSIX. It works on Linux and I suspect it will work on the other Unixes supported by go, since it was in the original BSD, however I don't have easy access to those platforms to test on. Please let me know if you think that using getprotobyname_r would get the patch rejected. I will also add the relevant tests. I fear the patchset may look a little large but I want to do it right. |
I appreciate your advice. Does this seem like too much to you? $ hg diff --stat -b src/pkg/net/Makefile | 3 +++ src/pkg/net/cgo_stub.go | 4 ++++ src/pkg/net/cgo_unix.go | 16 ++++++++++++++++ src/pkg/net/ipraw_test.go | 20 +++++++++++++++----- src/pkg/net/iprawsock.go | 34 +--------------------------------- src/pkg/net/lookup_unix.go | 9 +++++++++ src/pkg/net/lookup_windows.go | 11 +++++++++++ src/pkg/net/proto.go | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/pkg/net/proto_test.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/pkg/syscall/syscall_windows.go | 1 + src/pkg/syscall/zsyscall_windows_386.go | 16 ++++++++++++++++ src/pkg/syscall/zsyscall_windows_amd64.go | 16 ++++++++++++++++ src/pkg/syscall/ztypes_windows.go | 7 +++++++ 13 files changed, 204 insertions(+), 38 deletions(-) Bear in mind that I need to implement the protocol lookup three times: the C based version in cgo_unix.go, the fallback to a direct read of /etc/protocols in proto.go (modeled after port.go), and the Windows version. All the new code is very similar to the existing port (service) lookup code. I also implemented a test for LookupProtocol, modeled after the existing one in port_test.go and updated ipraw_test.go so that it works on Windows when run by an administrator. It continues to be skipped if the user doesn't have permission to open a raw socket. Also zsyscall_windows_*.go are auto generated because of the one line added to syscall_windows.go. If it is too much, can you suggest ways I could break it up into smaller chunks? |
This issue was closed by revision 059c68b. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: