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

replace lsof to platform dependent method #164

Open
10 of 20 tasks
shirou opened this issue Feb 25, 2016 · 6 comments
Open
10 of 20 tasks

replace lsof to platform dependent method #164

shirou opened this issue Feb 25, 2016 · 6 comments

Comments

@shirou
Copy link
Owner

shirou commented Feb 25, 2016

#142 , #143 are related to using lsof to get Network connection info.

To replace lsof, we needs at least these functions. inet_ntop porting, sysctl decode functions, and so on are little bit heavy to implement. I will update this issue step by step.

  • Linux (see [net]linux: start replacing lsof #169)
    • getting inode list from processes
    • porting socket.inet_ntop to pure golang (linux struct)
    • IPv6
    • Unix Pipe
  • windows
    • needs research
    • rtlIpv4AddressToStringA
    • rtlIpv6AddressToStringA
    • getExtendedTcpTable
  • darwin
    • proc_pidinfo and retrieve proc_fdtype
    • inet_ntop
  • freebsd
    • sysctl net.inet.tcp.pcblist for TCP
    • sysctl net.inet.udp.pcblist for UDP
    • sysctl net.local.stream.pcblist for socket stream
    • sysctl net.local.dgram.pcblist for socket dgram
    • porting inet_ntop to pure golang (freebsd struct)
    • porting kinfo_file
@vrecan
Copy link
Contributor

vrecan commented Feb 25, 2016

👍 great to see that you are taking this on!

@sparrc
Copy link
Contributor

sparrc commented Feb 26, 2016

looking forward to this, thanks for your work @shirou!

@shirou
Copy link
Owner Author

shirou commented Mar 5, 2016

OK. now I have implemented linux version at #169. The output is same as psutil, but more tests are required.

@shirou
Copy link
Owner Author

shirou commented Mar 23, 2016

FreeBSD

sysctl net.inet.tcp.pcblist returnes xtcpcb struct. But since it is complicated to parse to golang struct, time should be required.

Darwin

To get NetConnections, proc_pidinfo() is required and it seems to invoke by only CGO. I am thinking net is also use CGO or not. Or, the net.inet.tcp.pcblist is exists on Darwin also, the FreeBSD code may be used on Darwin, too. I will challenge after FreeBSD.

windows

not yet...

v2 migration

It takes a time to implement, I think prioritize v2.

@NullSoldier
Copy link

Is this dead in the water? I'm seeing flakiness with using lsof where the command never finishes.

@shirou
Copy link
Owner Author

shirou commented Aug 7, 2017

@NullSoldier what platform do you want to replace lsof?

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

No branches or pull requests

5 participants