sing-box/common/process/searcher_linux.go
beryll1um 99840ba0f4 Add high-level boundary management interface
I rewrote the router's boundary management part to implement dynamic management
from a high-level box interface. This also includes a number of changes I made
in the process of rewriting some messy parts, such as the Outbound tree
bottom-top starter.
2024-10-20 15:21:25 +02:00

36 lines
751 B
Go

//go:build linux && !android
package process
import (
"context"
"net/netip"
"github.com/sagernet/sing-box/log"
)
var _ Searcher = (*linuxSearcher)(nil)
type linuxSearcher struct {
logger log.ContextLogger
}
func NewSearcher(config Config) (Searcher, error) {
return &linuxSearcher{config.Logger}, nil
}
func (s *linuxSearcher) FindProcessInfo(ctx context.Context, network string, source netip.AddrPort) (*Info, error) {
inode, uid, err := resolveSocketByNetlink(network, source)
if err != nil {
return nil, err
}
processPath, err := resolveProcessNameByProcSearch(inode, uid)
if err != nil {
s.logger.DebugContext(ctx, "find process path: ", err)
}
return &Info{
UserId: int32(uid),
ProcessPath: processPath,
}, nil
}