-
Notifications
You must be signed in to change notification settings - Fork 0
/
rdata_hinfo.go
45 lines (37 loc) · 1002 Bytes
/
rdata_hinfo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package dns
import (
"fmt"
"strings"
)
// RDataHINFO HINFO records are used to acquire general information about a
// host. The main use is for protocols such as FTP that can use special
// procedures when talking between machines or operating systems of the same
// type.
type RDataHINFO struct {
CPU []byte
OS []byte
}
// unpack the HINFO RDATA from DNS message.
func (hinfo *RDataHINFO) unpack(packet []byte) error {
var (
x int
)
for ; x < len(packet); x++ {
if packet[x] == 0 {
break
}
}
hinfo.CPU = append(hinfo.CPU, packet[0:x]...)
x++
hinfo.OS = append(hinfo.OS, packet[x:]...)
return nil
}
// String return readable representation of HINFO record.
func (hinfo *RDataHINFO) String() string {
var b strings.Builder
fmt.Fprintf(&b, "{CPU:%s OS:%s}", hinfo.CPU, hinfo.OS)
return b.String()
}