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