make connectionparameters return its map in GetSHLOMap

This commit is contained in:
Lucas Clemente
2016-05-05 22:58:52 +02:00
parent b5a27d3aa2
commit 76d279ed8f

View File

@@ -12,7 +12,8 @@ import (
// ConnectionParametersManager stores the connection parameters
type ConnectionParametersManager struct {
params map[Tag][]byte
mutex sync.RWMutex
// TODO: We can probably remove this mutex.
mutex sync.RWMutex
}
// ErrTagNotInConnectionParameterMap is returned when a tag is not present in the connection parameters
@@ -20,16 +21,14 @@ var ErrTagNotInConnectionParameterMap = errors.New("Tag not found in Connections
// NewConnectionParamatersManager creates a new connection parameters manager
func NewConnectionParamatersManager() *ConnectionParametersManager {
cpm := &ConnectionParametersManager{
params: make(map[Tag][]byte),
return &ConnectionParametersManager{
params: map[Tag][]byte{
TagSFCW: {0x0, 0x40, 0x0, 0x0}, // Stream Flow Control Window
TagCFCW: {0x0, 0x40, 0x0, 0x0}, // Connection Flow Control Window
TagICSL: {0x1e, 0x00, 0x00, 0x00}, // idle connection state lifetime = 30s
TagMSPC: {0x64, 0x00, 0x00, 0x00}, // Max streams per connection = 100
},
}
// set default parameters
cpm.mutex.Lock()
cpm.params[TagSFCW] = []byte{0x0, 0x40, 0x0, 0x0} // Stream Flow Control Window
cpm.params[TagCFCW] = []byte{0x0, 0x40, 0x0, 0x0} // Connection Flow Control WindowWindow
cpm.mutex.Unlock()
return cpm
}
// SetFromMap reads all params
@@ -56,10 +55,8 @@ func (h *ConnectionParametersManager) GetRawValue(tag Tag) ([]byte, error) {
// GetSHLOMap gets all values (except crypto values) needed for the SHLO
func (h *ConnectionParametersManager) GetSHLOMap() map[Tag][]byte {
return map[Tag][]byte{
TagICSL: []byte{0x1e, 0x00, 0x00, 0x00}, //30
TagMSPC: []byte{0x64, 0x00, 0x00, 0x00}, //100
}
// TODO: This races.
return h.params
}
// GetStreamFlowControlWindow gets the size of the stream-level flow control window