github.com/sagernet/sing-box@v1.2.7/route/rule_network.go (about)

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