only take specific values from the params map

This commit is contained in:
Lucas Clemente
2016-05-06 11:43:28 +02:00
parent f7d3da74b7
commit bfe7117329
2 changed files with 6 additions and 8 deletions

View File

@@ -13,6 +13,7 @@ import (
// ConnectionParametersManager stores the connection parameters
// Warning: Writes may only be done from the crypto stream, see the comment
// in GetSHLOMap().
// TODO: Separate our SFCW from the client's
type ConnectionParametersManager struct {
params map[Tag][]byte
mutex sync.RWMutex
@@ -37,7 +38,10 @@ func NewConnectionParamatersManager() *ConnectionParametersManager {
func (h *ConnectionParametersManager) SetFromMap(params map[Tag][]byte) error {
h.mutex.Lock()
for key, value := range params {
h.params[key] = value
switch key {
case TagSFCW, TagCFCW, TagICSL, TagMSPC:
h.params[key] = value
}
}
h.mutex.Unlock()
return nil

View File

@@ -15,20 +15,14 @@ var _ = Describe("ConnectionsParameterManager", func() {
})
It("stores and retrieves a value", func() {
kexs := []byte{0xDE, 0xCA, 0xFB, 0xAD}
icsl := []byte{0x13, 0x37}
values := map[Tag][]byte{
TagKEXS: kexs,
TagICSL: icsl,
}
cpm.SetFromMap(values)
val, err := cpm.GetRawValue(TagKEXS)
Expect(err).ToNot(HaveOccurred())
Expect(val).To(Equal(kexs))
val, err = cpm.GetRawValue(TagICSL)
val, err := cpm.GetRawValue(TagICSL)
Expect(err).ToNot(HaveOccurred())
Expect(val).To(Equal(icsl))
})