github.com/yaling888/clash@v1.53.0/context/dns.go (about) 1 package context 2 3 import ( 4 "github.com/miekg/dns" 5 6 "github.com/yaling888/clash/common/uuid" 7 ) 8 9 const ( 10 DNSTypeHost = "host" 11 DNSTypeFakeIP = "fakeip" 12 DNSTypeRaw = "raw" 13 ) 14 15 type DNSContext struct { 16 id uuid.UUID 17 msg *dns.Msg 18 tp string 19 } 20 21 func NewDNSContext(msg *dns.Msg) *DNSContext { 22 id := uuid.RandomB64Hlf() 23 return &DNSContext{ 24 id: id, 25 msg: msg, 26 } 27 } 28 29 // ID implement C.PlainContext ID 30 func (c *DNSContext) ID() uuid.UUID { 31 return c.id 32 } 33 34 // SetType set type of response 35 func (c *DNSContext) SetType(tp string) { 36 c.tp = tp 37 } 38 39 // Type return type of response 40 func (c *DNSContext) Type() string { 41 return c.tp 42 }