1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-20 14:35:23 +00:00
v2fly/app/router/rules/chinaip_json_test.go

27 lines
699 B
Go
Raw Normal View History

2016-02-01 21:30:00 +00:00
// +build json
package rules_test
import (
"testing"
2016-08-20 18:55:45 +00:00
. "v2ray.com/core/app/router/rules"
"v2ray.com/core/testing/assert"
2016-02-01 21:30:00 +00:00
)
func TestChinaIPJson(t *testing.T) {
2016-05-24 19:55:46 +00:00
assert := assert.On(t)
2016-02-01 21:30:00 +00:00
rule := ParseRule([]byte(`{
"type": "chinaip",
"outboundTag": "x"
}`))
2016-05-24 19:55:46 +00:00
assert.String(rule.Tag).Equals("x")
2016-02-01 21:30:00 +00:00
assert.Bool(rule.Apply(makeDestination("121.14.1.189"))).IsTrue() // sina.com.cn
assert.Bool(rule.Apply(makeDestination("101.226.103.106"))).IsTrue() // qq.com
assert.Bool(rule.Apply(makeDestination("115.239.210.36"))).IsTrue() // image.baidu.com
assert.Bool(rule.Apply(makeDestination("120.135.126.1"))).IsTrue()
assert.Bool(rule.Apply(makeDestination("8.8.8.8"))).IsFalse()
}