mirror of
				https://github.com/gortc/stun.git
				synced 2025-10-31 11:56:33 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			584 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			584 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package stun
 | |
| 
 | |
| // Software is SOFTWARE attribute.
 | |
| type Software struct {
 | |
| 	Raw []byte
 | |
| }
 | |
| 
 | |
| func (s *Software) String() string {
 | |
| 	return string(s.Raw)
 | |
| }
 | |
| 
 | |
| // NewSoftware returns *Software from string.
 | |
| func NewSoftware(software string) *Software {
 | |
| 	return &Software{Raw: []byte(software)}
 | |
| }
 | |
| 
 | |
| // AddTo adds Software attribute to m.
 | |
| func (s *Software) AddTo(m *Message) error {
 | |
| 	m.Add(AttrSoftware, m.Raw)
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| // GetFrom decodes Software from m.
 | |
| func (s *Software) GetFrom(m *Message) error {
 | |
| 	v, err := m.Get(AttrSoftware)
 | |
| 	if err != nil {
 | |
| 		return err
 | |
| 	}
 | |
| 	s.Raw = v
 | |
| 	return nil
 | |
| }
 | 
