2 // Copyright © 2011-2019 Guy M. Allard
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
26 "github.com/gmallard/stompngo/senv"
30 HexData returns a dump formatted value of a byte slice.
32 func HexData(b
[]uint8) string {
34 m
:= senv
.MaxBodyLength()
40 return "\n" + hex
.Dump(td
)
44 Sha1 returns a SHA1 hash for a specified string.
46 func Sha1(q
string) string {
49 return fmt
.Sprintf("%x", g
.Sum(nil))
53 Uuid returns a type 4 UUID.
57 _
, _
= io
.ReadFull(rand
.Reader
, b
)
58 b
[6] = (b
[6] & 0x0F) |
0x40
59 b
[8] = (b
[8] &^ 0x40) |
0x80
60 return fmt
.Sprintf("%x-%x-%x-%x-%x", b
[:4], b
[4:6], b
[6:8], b
[8:10], b
[10:])
64 Supported checks if a particular STOMP version is supported in the current
67 func Supported(v
string) bool {
68 return hasValue(supported
, v
)
72 Protocols returns a slice of client supported protocol levels.
74 func Protocols() []string {