package stun
func NewUsername (username string ) Username {
return Username (username )
}
type Username []byte
func (u Username ) String () string {
return string (u )
}
const maxUsernameB = 513
func (u Username ) AddTo (m *Message ) error {
return TextAttribute (u ).AddToAs (m , AttrUsername , maxUsernameB )
}
func (u *Username ) GetFrom (m *Message ) error {
return (*TextAttribute )(u ).GetFromAs (m , AttrUsername )
}
func NewRealm (realm string ) Realm {
return Realm (realm )
}
type Realm []byte
func (n Realm ) String () string {
return string (n )
}
const maxRealmB = 763
func (n Realm ) AddTo (m *Message ) error {
return TextAttribute (n ).AddToAs (m , AttrRealm , maxRealmB )
}
func (n *Realm ) GetFrom (m *Message ) error {
return (*TextAttribute )(n ).GetFromAs (m , AttrRealm )
}
const softwareRawMaxB = 763
type Software []byte
func (s Software ) String () string {
return string (s )
}
func NewSoftware (software string ) Software {
return Software (software )
}
func (s Software ) AddTo (m *Message ) error {
return TextAttribute (s ).AddToAs (m , AttrSoftware , softwareRawMaxB )
}
func (s *Software ) GetFrom (m *Message ) error {
return (*TextAttribute )(s ).GetFromAs (m , AttrSoftware )
}
type Nonce []byte
func NewNonce (nonce string ) Nonce {
return Nonce (nonce )
}
func (n Nonce ) String () string {
return string (n )
}
const maxNonceB = 763
func (n Nonce ) AddTo (m *Message ) error {
return TextAttribute (n ).AddToAs (m , AttrNonce , maxNonceB )
}
func (n *Nonce ) GetFrom (m *Message ) error {
return (*TextAttribute )(n ).GetFromAs (m , AttrNonce )
}
type TextAttribute []byte
func (v TextAttribute ) AddToAs (m *Message , t AttrType , maxLen int ) error {
if err := CheckOverflow (t , len (v ), maxLen ); err != nil {
return err
}
m .Add (t , v )
return nil
}
func (v *TextAttribute ) GetFromAs (m *Message , t AttrType ) error {
a , err := m .Get (t )
if err != nil {
return err
}
*v = a
return nil
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .