mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-10-27 10:40:39 +08:00
修订,重构代码, 修复dns的bug; 添加Dns的DoT功能.
修复dns配置中"特殊服务器" 无法被正确配置、使用的bug 将 proxy.Standard结构 移动到 项目根目录的 StandardConf. 将 proxy.AppConf, LoadTomlConfStr, LoadTomlConfFile 函数 移动到根目录 因为 StandardConf和 AppConf里包含很多App级别的配置, 不宜放到proxy子包中 将 proxy.RuleConf 移动到 netLayer 将 proxy.LoadRulesForRoutePolicy 移动到 netLayer 将 proxy.LoadDnsMachine 移动到 netLayer 在dnsquery失败后,会判断错误, 若发现是Read错误,则会试图重新拨号
This commit is contained in:
63
test_test.go
63
test_test.go
@@ -4,6 +4,7 @@ import (
|
||||
"log"
|
||||
"testing"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/hahahrfool/v2ray_simple/proxy"
|
||||
"github.com/hahahrfool/v2ray_simple/utils"
|
||||
"github.com/miekg/dns"
|
||||
@@ -81,12 +82,12 @@ cert = "cert.pem"
|
||||
key = "cert.key"
|
||||
`
|
||||
|
||||
clientConf, err := proxy.LoadTomlConfStr(testClientConfStr)
|
||||
clientConf, err := LoadTomlConfStr(testClientConfStr)
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
t.FailNow()
|
||||
}
|
||||
serverConf, err := proxy.LoadTomlConfStr(testServerConfStr)
|
||||
serverConf, err := LoadTomlConfStr(testServerConfStr)
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
t.FailNow()
|
||||
@@ -142,3 +143,61 @@ key = "cert.key"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadTomlConf(t *testing.T) {
|
||||
|
||||
var conf StandardConf
|
||||
_, err := toml.Decode(testTomlConfStr, &conf)
|
||||
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
t.Log(conf)
|
||||
t.Log("dial0", conf.Dial[0])
|
||||
t.Log("listen0", conf.Listen[0])
|
||||
t.Log("extra", conf.Listen[0].Extra)
|
||||
t.Log(conf.Route[0])
|
||||
t.Log(conf.Route[1])
|
||||
t.Log(conf.Fallbacks)
|
||||
}
|
||||
|
||||
const testTomlConfStr = `# this is a verysimple standard config
|
||||
|
||||
[app]
|
||||
mycountry = "CN"
|
||||
|
||||
[[dial]]
|
||||
tag = "my_vlesss1"
|
||||
protocol = "vlesss"
|
||||
uuid = "a684455c-b14f-11ea-bf0d-42010aaa0003"
|
||||
host = "127.0.0.1"
|
||||
port = 4433
|
||||
version = 0
|
||||
insecure = true
|
||||
utls = true
|
||||
|
||||
[[listen]]
|
||||
protocol = "socks5"
|
||||
host = "127.0.0.1"
|
||||
port = 1080
|
||||
tag = "my_socks51"
|
||||
extra = { ws_earlydata = 4096 }
|
||||
|
||||
|
||||
[[route]]
|
||||
dialTag = "my_ws1"
|
||||
country = ["CN"]
|
||||
ip = ["0.0.0.0/8","10.0.0.0/8","fe80::/10","10.0.0.1"]
|
||||
domain = ["www.google.com","www.twitter.com"]
|
||||
network = ["tcp","udp"]
|
||||
|
||||
[[route]]
|
||||
dialTag = "my_vless1"
|
||||
|
||||
|
||||
[[fallback]]
|
||||
path = "/asf"
|
||||
dest = 6060
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user