rule_network.go 417 B

1234567891011121314151617181920212223
  1. package route
  2. import (
  3. "github.com/sagernet/sing-box/adapter"
  4. )
  5. var _ RuleItem = (*NetworkItem)(nil)
  6. type NetworkItem struct {
  7. network string
  8. }
  9. func NewNetworkItem(network string) *NetworkItem {
  10. return &NetworkItem{network}
  11. }
  12. func (r *NetworkItem) Match(metadata *adapter.InboundContext) bool {
  13. return r.network == metadata.Network
  14. }
  15. func (r *NetworkItem) String() string {
  16. return "network=" + r.network
  17. }