mirror of
https://github.com/pion/stun.git
synced 2025-09-26 20:01:18 +08:00
Simplify MappedAddress IP slice initialization
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
This commit is contained in:
12
addr.go
12
addr.go
@@ -84,15 +84,13 @@ func (a *MappedAddress) GetFromAs(m *Message, t AttrType) error {
|
||||
}
|
||||
// Ensuring len(a.IP) == ipLen and reusing a.IP.
|
||||
if len(a.IP) < ipLen {
|
||||
a.IP = a.IP[:cap(a.IP)]
|
||||
for len(a.IP) < ipLen {
|
||||
a.IP = append(a.IP, 0)
|
||||
a.IP = make(net.IP, ipLen)
|
||||
} else {
|
||||
a.IP = a.IP[:ipLen]
|
||||
for i := range a.IP {
|
||||
a.IP[i] = 0
|
||||
}
|
||||
}
|
||||
a.IP = a.IP[:ipLen]
|
||||
for i := range a.IP {
|
||||
a.IP[i] = 0
|
||||
}
|
||||
a.Port = int(bin.Uint16(value[2:4]))
|
||||
copy(a.IP, value[4:])
|
||||
|
||||
|
Reference in New Issue
Block a user