mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-04 03:03:14 -05:00 
			
		
		
		
	
		
			
	
	
		
			26 lines
		
	
	
		
			397 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			26 lines
		
	
	
		
			397 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								package msg
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import (
							 | 
						||
| 
								 | 
							
									"fmt"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									lib "github.com/dnstap/golang-dnstap"
							 | 
						||
| 
								 | 
							
									"github.com/golang/protobuf/proto"
							 | 
						||
| 
								 | 
							
								)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func wrap(m *lib.Message) *lib.Dnstap {
							 | 
						||
| 
								 | 
							
									t := lib.Dnstap_MESSAGE
							 | 
						||
| 
								 | 
							
									return &lib.Dnstap{
							 | 
						||
| 
								 | 
							
										Type:    &t,
							 | 
						||
| 
								 | 
							
										Message: m,
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func Marshal(m *lib.Message) (data []byte, err error) {
							 | 
						||
| 
								 | 
							
									data, err = proto.Marshal(wrap(m))
							 | 
						||
| 
								 | 
							
									if err != nil {
							 | 
						||
| 
								 | 
							
										err = fmt.Errorf("proto: %s", err)
							 | 
						||
| 
								 | 
							
										return
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
									return
							 | 
						||
| 
								 | 
							
								}
							 |