mirror of https://github.com/v2ray/v2ray-core
add scripting support for attributes matching
parent
8fb4f3bb20
commit
02d8845093
|
@ -5,6 +5,9 @@ package router
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"go.starlark.net/starlark"
|
||||||
|
"go.starlark.net/syntax"
|
||||||
|
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/common/strmatcher"
|
"v2ray.com/core/common/strmatcher"
|
||||||
)
|
)
|
||||||
|
@ -280,3 +283,60 @@ func (m *ProtocolMatcher) Apply(ctx *Context) bool {
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AttributeMatcher struct {
|
||||||
|
program *starlark.Program
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAttributeMatcher(code string) (*AttributeMatcher, error) {
|
||||||
|
starFile, err := syntax.Parse("attr.star", "satisfied=("+code+")", 0)
|
||||||
|
if err != nil {
|
||||||
|
return nil, newError("attr rule").Base(err)
|
||||||
|
}
|
||||||
|
p, err := starlark.FileProgram(starFile, func(name string) bool {
|
||||||
|
if name == "attrs" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &AttributeMatcher{
|
||||||
|
program: p,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *AttributeMatcher) Match(attrs map[string]interface{}) bool {
|
||||||
|
attrsDict := new(starlark.Dict)
|
||||||
|
for key, value := range attrs {
|
||||||
|
var starValue starlark.Value
|
||||||
|
switch value := value.(type) {
|
||||||
|
case string:
|
||||||
|
starValue = starlark.String(value)
|
||||||
|
}
|
||||||
|
if starValue != nil {
|
||||||
|
attrsDict.SetKey(starlark.String(key), starValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
predefined := make(starlark.StringDict)
|
||||||
|
predefined["attrs"] = attrsDict
|
||||||
|
|
||||||
|
thread := &starlark.Thread{
|
||||||
|
Name: "matcher",
|
||||||
|
}
|
||||||
|
results, err := m.program.Init(thread, predefined)
|
||||||
|
if err != nil {
|
||||||
|
newError("attr matcher").Base(err).WriteToLog()
|
||||||
|
}
|
||||||
|
satisfied := results["satisfied"]
|
||||||
|
return satisfied != nil && bool(satisfied.Truth())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *AttributeMatcher) Apply(ctx *Context) bool {
|
||||||
|
if ctx.Content == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return m.Match(ctx.Content.Attributes)
|
||||||
|
}
|
||||||
|
|
|
@ -264,6 +264,18 @@ func TestRoutingRule(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
rule: &RoutingRule{
|
||||||
|
Protocol: []string{"http"},
|
||||||
|
Attributes: "attrs[':path'].startswith('/test')",
|
||||||
|
},
|
||||||
|
test: []ruleTest{
|
||||||
|
{
|
||||||
|
input: &Context{Content: &session.Content{Protocol: "http/1.1", Attributes: map[string]interface{}{":path": "/test/1"}}},
|
||||||
|
output: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range cases {
|
for _, test := range cases {
|
||||||
|
|
|
@ -126,6 +126,14 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
|
||||||
conds.Add(NewProtocolMatcher(rr.Protocol))
|
conds.Add(NewProtocolMatcher(rr.Protocol))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(rr.Attributes) > 0 {
|
||||||
|
cond, err := NewAttributeMatcher(rr.Attributes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
conds.Add(cond)
|
||||||
|
}
|
||||||
|
|
||||||
if conds.Len() == 0 {
|
if conds.Len() == 0 {
|
||||||
return nil, newError("this rule has no effective fields").AtWarning()
|
return nil, newError("this rule has no effective fields").AtWarning()
|
||||||
}
|
}
|
||||||
|
|
|
@ -488,6 +488,7 @@ type RoutingRule struct {
|
||||||
UserEmail []string `protobuf:"bytes,7,rep,name=user_email,json=userEmail,proto3" json:"user_email,omitempty"`
|
UserEmail []string `protobuf:"bytes,7,rep,name=user_email,json=userEmail,proto3" json:"user_email,omitempty"`
|
||||||
InboundTag []string `protobuf:"bytes,8,rep,name=inbound_tag,json=inboundTag,proto3" json:"inbound_tag,omitempty"`
|
InboundTag []string `protobuf:"bytes,8,rep,name=inbound_tag,json=inboundTag,proto3" json:"inbound_tag,omitempty"`
|
||||||
Protocol []string `protobuf:"bytes,9,rep,name=protocol,proto3" json:"protocol,omitempty"`
|
Protocol []string `protobuf:"bytes,9,rep,name=protocol,proto3" json:"protocol,omitempty"`
|
||||||
|
Attributes string `protobuf:"bytes,15,opt,name=attributes,proto3" json:"attributes,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
XXX_sizecache int32 `json:"-"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
@ -643,6 +644,13 @@ func (m *RoutingRule) GetProtocol() []string {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *RoutingRule) GetAttributes() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Attributes
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// XXX_OneofWrappers is for the internal use of the proto package.
|
// XXX_OneofWrappers is for the internal use of the proto package.
|
||||||
func (*RoutingRule) XXX_OneofWrappers() []interface{} {
|
func (*RoutingRule) XXX_OneofWrappers() []interface{} {
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
|
@ -773,62 +781,62 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptor_6b1608360690c5fc = []byte{
|
var fileDescriptor_6b1608360690c5fc = []byte{
|
||||||
// 897 bytes of a gzipped FileDescriptorProto
|
// 910 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xdd, 0x6e, 0xe3, 0x44,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x5f, 0x8f, 0xdb, 0x44,
|
||||||
0x14, 0xae, 0xed, 0x24, 0x1b, 0x1f, 0x27, 0xc1, 0x8c, 0x58, 0x64, 0x0a, 0xa5, 0xc1, 0x5a, 0xd8,
|
0x10, 0x3f, 0xdb, 0x49, 0x1a, 0x8f, 0x93, 0xd4, 0xac, 0x28, 0x32, 0x07, 0xd7, 0x0b, 0x56, 0xa1,
|
||||||
0x48, 0x20, 0x47, 0xca, 0x02, 0x17, 0x08, 0xb4, 0x34, 0xe9, 0xd2, 0x46, 0x40, 0xa9, 0xa6, 0xbb,
|
0x91, 0x40, 0x8e, 0x94, 0x02, 0x0f, 0x08, 0x54, 0x2e, 0xb9, 0x72, 0x17, 0x01, 0xc7, 0x69, 0xaf,
|
||||||
0x7b, 0x01, 0x17, 0x91, 0xe3, 0x4c, 0x8d, 0xb5, 0xce, 0xcc, 0x68, 0x3c, 0x5e, 0x36, 0xaf, 0x84,
|
0xed, 0x03, 0x3c, 0x44, 0x8e, 0xb3, 0x67, 0xac, 0x3a, 0xbb, 0xab, 0xf5, 0xba, 0x34, 0x5f, 0x09,
|
||||||
0xc4, 0x33, 0xf0, 0x28, 0xbc, 0x0a, 0x9a, 0x9f, 0x34, 0x0d, 0x34, 0x25, 0xe2, 0x6e, 0xce, 0x39,
|
0x89, 0xcf, 0xc0, 0x47, 0x03, 0xed, 0x9f, 0x24, 0x17, 0x68, 0x8e, 0x13, 0x6f, 0x3b, 0xb3, 0xbf,
|
||||||
0xdf, 0x39, 0xf3, 0xcd, 0xf9, 0x1b, 0xf8, 0xe4, 0xf5, 0x48, 0xa4, 0xab, 0x24, 0x63, 0xcb, 0x61,
|
0xf9, 0xed, 0x6f, 0x67, 0x76, 0x66, 0xe1, 0x93, 0xd7, 0x23, 0x91, 0xae, 0x92, 0x8c, 0x2d, 0x87,
|
||||||
0xc6, 0x04, 0x19, 0xa6, 0x9c, 0x0f, 0x05, 0xab, 0x25, 0x11, 0xc3, 0x8c, 0xd1, 0xeb, 0x22, 0x4f,
|
0x19, 0x13, 0x64, 0x98, 0x72, 0x3e, 0x14, 0xac, 0x96, 0x44, 0x0c, 0x33, 0x46, 0xaf, 0x8b, 0x3c,
|
||||||
0xb8, 0x60, 0x92, 0xa1, 0x87, 0x6b, 0x9c, 0x20, 0x49, 0xca, 0x79, 0x62, 0x30, 0x87, 0x8f, 0xfe,
|
0xe1, 0x82, 0x49, 0x86, 0x1e, 0xac, 0x71, 0x82, 0x24, 0x29, 0xe7, 0x89, 0xc1, 0x1c, 0x3e, 0xfa,
|
||||||
0xe1, 0x9e, 0xb1, 0xe5, 0x92, 0xd1, 0x21, 0x25, 0x72, 0xc8, 0x99, 0x90, 0xc6, 0xf9, 0xf0, 0xf1,
|
0x47, 0x78, 0xc6, 0x96, 0x4b, 0x46, 0x87, 0x94, 0xc8, 0x21, 0x67, 0x42, 0x9a, 0xe0, 0xc3, 0xc7,
|
||||||
0x6e, 0x14, 0x25, 0xf2, 0x37, 0x26, 0x5e, 0x19, 0x60, 0xfc, 0xa7, 0x0b, 0xad, 0x53, 0xb6, 0x4c,
|
0xfb, 0x51, 0x94, 0xc8, 0xdf, 0x98, 0x78, 0x65, 0x80, 0xf1, 0x9f, 0x2e, 0xb4, 0x4e, 0xd9, 0x32,
|
||||||
0x0b, 0x8a, 0xbe, 0x84, 0x86, 0x5c, 0x71, 0x12, 0x39, 0x7d, 0x67, 0xd0, 0x1b, 0xc5, 0xc9, 0x9d,
|
0x2d, 0x28, 0xfa, 0x12, 0x1a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74, 0x7e, 0x6e, 0x99, 0xd5, 0xef, 0xee, 0x83, 0x97, 0x23,
|
||||||
0xe9, 0xb2, 0x3e, 0xf9, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xb2, 0x28, 0x0d, 0x41, 0xf1, 0x07, 0x00,
|
0x9c, 0xae, 0x92, 0x89, 0x42, 0x9c, 0x70, 0xae, 0xef, 0x47, 0xc4, 0xbc, 0xa5, 0xcb, 0xfe, 0xe4,
|
||||||
0x00,
|
0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x3e, 0x38, 0x1b, 0x11, 0x08, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,8 @@ message RoutingRule {
|
||||||
repeated string user_email = 7;
|
repeated string user_email = 7;
|
||||||
repeated string inbound_tag = 8;
|
repeated string inbound_tag = 8;
|
||||||
repeated string protocol = 9;
|
repeated string protocol = 9;
|
||||||
|
|
||||||
|
string attributes = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
message BalancingRule {
|
message BalancingRule {
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -5,6 +5,7 @@ require (
|
||||||
github.com/golang/protobuf v1.2.1-0.20190205222052-c823c79ea157
|
github.com/golang/protobuf v1.2.1-0.20190205222052-c823c79ea157
|
||||||
github.com/google/go-cmp v0.2.0
|
github.com/google/go-cmp v0.2.0
|
||||||
github.com/miekg/dns v1.1.4
|
github.com/miekg/dns v1.1.4
|
||||||
|
go.starlark.net v0.0.0-20190225160109-1174b2613e82
|
||||||
golang.org/x/crypto v0.0.0-20190208162236-193df9c0f06f
|
golang.org/x/crypto v0.0.0-20190208162236-193df9c0f06f
|
||||||
golang.org/x/net v0.0.0-20190206173232-65e2d4e15006
|
golang.org/x/net v0.0.0-20190206173232-65e2d4e15006
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
|
||||||
|
|
5
go.sum
5
go.sum
|
@ -1,5 +1,6 @@
|
||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk=
|
github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk=
|
||||||
|
@ -9,8 +10,11 @@ github.com/golang/protobuf v1.2.1-0.20190205222052-c823c79ea157 h1:SdQMHsZ18/XZC
|
||||||
github.com/golang/protobuf v1.2.1-0.20190205222052-c823c79ea157/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
|
github.com/golang/protobuf v1.2.1-0.20190205222052-c823c79ea157/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
|
||||||
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/miekg/dns v1.1.4 h1:rCMZsU2ScVSYcAsOXgmC6+AKOK+6pmQTOcw03nfwYV0=
|
github.com/miekg/dns v1.1.4 h1:rCMZsU2ScVSYcAsOXgmC6+AKOK+6pmQTOcw03nfwYV0=
|
||||||
github.com/miekg/dns v1.1.4/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
github.com/miekg/dns v1.1.4/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||||
|
go.starlark.net v0.0.0-20190225160109-1174b2613e82 h1:vAHCTDREx7LqPeWqNeTvCKWcURJztP3wBKnF2Q0sW7Q=
|
||||||
|
go.starlark.net v0.0.0-20190225160109-1174b2613e82/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg=
|
||||||
golang.org/x/crypto v0.0.0-20190208162236-193df9c0f06f h1:ETU2VEl7TnT5bl7IvuKEzTDpplg5wzGYsOCAPhdoEIg=
|
golang.org/x/crypto v0.0.0-20190208162236-193df9c0f06f h1:ETU2VEl7TnT5bl7IvuKEzTDpplg5wzGYsOCAPhdoEIg=
|
||||||
golang.org/x/crypto v0.0.0-20190208162236-193df9c0f06f/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20190208162236-193df9c0f06f/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
@ -25,7 +29,6 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522 h1:Ve1ORMCxvRmSXBwJK+t3Oy+V2
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
|
||||||
|
|
|
@ -363,6 +363,7 @@ func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) {
|
||||||
User *StringList `json:"user"`
|
User *StringList `json:"user"`
|
||||||
InboundTag *StringList `json:"inboundTag"`
|
InboundTag *StringList `json:"inboundTag"`
|
||||||
Protocols *StringList `json:"protocol"`
|
Protocols *StringList `json:"protocol"`
|
||||||
|
Attributes string `json:"attrs"`
|
||||||
}
|
}
|
||||||
rawFieldRule := new(RawFieldRule)
|
rawFieldRule := new(RawFieldRule)
|
||||||
err := json.Unmarshal(msg, rawFieldRule)
|
err := json.Unmarshal(msg, rawFieldRule)
|
||||||
|
@ -435,6 +436,10 @@ func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(rawFieldRule.Attributes) > 0 {
|
||||||
|
rule.Attributes = rawFieldRule.Attributes
|
||||||
|
}
|
||||||
|
|
||||||
return rule, nil
|
return rule, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue