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