mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
39 lines
939 B
Go
39 lines
939 B
Go
package process
|
|
|
|
import (
|
|
"errors"
|
|
"net/netip"
|
|
|
|
C "github.com/metacubex/mihomo/constant"
|
|
)
|
|
|
|
var (
|
|
ErrInvalidNetwork = errors.New("invalid network")
|
|
ErrPlatformNotSupport = errors.New("not support on this platform")
|
|
ErrNotFound = errors.New("process not found")
|
|
)
|
|
|
|
const (
|
|
TCP = "tcp"
|
|
UDP = "udp"
|
|
)
|
|
|
|
func FindProcessName(network string, srcIP netip.Addr, srcPort int) (uint32, string, error) {
|
|
return findProcessName(network, srcIP, srcPort)
|
|
}
|
|
|
|
// PackageNameResolver
|
|
// never change type traits because it's used in CMFA
|
|
type PackageNameResolver func(metadata *C.Metadata) (string, error)
|
|
|
|
// DefaultPackageNameResolver
|
|
// never change type traits because it's used in CMFA
|
|
var DefaultPackageNameResolver PackageNameResolver
|
|
|
|
func FindPackageName(metadata *C.Metadata) (string, error) {
|
|
if resolver := DefaultPackageNameResolver; resolver != nil {
|
|
return resolver(metadata)
|
|
}
|
|
return "", ErrPlatformNotSupport
|
|
}
|