diff --git a/cmd/conf/conf.go b/cmd/conf/conf.go index 3c818ef..d97f0e2 100644 --- a/cmd/conf/conf.go +++ b/cmd/conf/conf.go @@ -47,6 +47,7 @@ func (f *queryFormatter) Format(entry *log.Entry) ([]byte, error) { // Group 配置文件中每个groups section对应的结构 type Group struct { ECS string + NoCookie bool `toml:"no_cookie"` Socks5 string IPSet string IPSetTTL int `toml:"ipset_ttl"` @@ -222,6 +223,7 @@ func (conf *Conf) GenGroups() (groups map[string]*inbound.Group, err error) { inboundGroup := &inbound.Group{ Callers: group.GenCallers(), Concurrent: group.Concurrent, FastestV4: group.FastestV4, TCPPingPort: group.TCPPingPort, + NoCookie: group.NoCookie, } if inboundGroup.Concurrent { log.Warnln("enable concurrent dns in group " + name) diff --git a/inbound/server.go b/inbound/server.go index 6490360..d4d2bf6 100644 --- a/inbound/server.go +++ b/inbound/server.go @@ -22,6 +22,7 @@ type Group struct { FastestV4 bool TCPPingPort int ECS *dns.EDNS0_SUBNET + NoCookie bool } // CallDNS 向组内的dns服务器转发请求,可能返回nil @@ -31,6 +32,9 @@ func (group *Group) CallDNS(request *dns.Msg) *dns.Msg { } request = request.Copy() common.SetDefaultECS(request, group.ECS) + if group.NoCookie { + common.RemoveEDNSCookie(request) + } // 并发用的channel ch := make(chan *dns.Msg, len(group.Callers)) // 包裹Caller.Call,方便实现并发 diff --git a/inbound/server_test.go b/inbound/server_test.go index 0944a30..025f89e 100644 --- a/inbound/server_test.go +++ b/inbound/server_test.go @@ -152,7 +152,8 @@ func TestHandler(t *testing.T) { func TestGroup(t *testing.T) { callers := []outbound.Caller{&outbound.DNSCaller{}} - group := &Group{Callers: callers, Matcher: matcher.NewABPByText(""), IPSet: &ipset.IPSet{}} + group := &Group{Callers: callers, Matcher: matcher.NewABPByText(""), + IPSet: &ipset.IPSet{}, NoCookie: true} mocker := mock.Mocker{} defer mocker.Reset()