mirror of
https://github.com/zr-hebo/sniffer-agent.git
synced 2025-08-12 00:26:28 +08:00
merge ranges
This commit is contained in:
@@ -17,14 +17,14 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
configMapLock sync.RWMutex
|
||||
configMap map[string]configItem
|
||||
configMapLock sync.RWMutex
|
||||
configMap map[string]configItem
|
||||
throwPacketRate *throwPacketRateConfig
|
||||
)
|
||||
|
||||
func init() {
|
||||
func init() {
|
||||
flag.IntVar(&communicatePort, "communicate_port", 8088, "http server port. Default is 8088")
|
||||
|
||||
configMap = make(map[string]configItem)
|
||||
tprc := newThrowPacketRateConfig()
|
||||
configMap[tprc.name] = tprc
|
||||
throwPacketRate = newThrowPacketRateConfig()
|
||||
}
|
||||
|
@@ -81,3 +81,7 @@ func outletSetConfig(resp http.ResponseWriter, req *http.Request) {
|
||||
|
||||
mp.Err = SetConfig(ep.ConfigName, ep.Value)
|
||||
}
|
||||
|
||||
func GetThrowPacketRate() float64 {
|
||||
return throwPacketRate.value
|
||||
}
|
@@ -4,6 +4,11 @@ import "fmt"
|
||||
|
||||
// SetConfig set config by config key(name) and value
|
||||
func SetConfig(key string, val interface{}) (err error) {
|
||||
if key == throwPacketRate.name {
|
||||
err = throwPacketRate.setVal(val)
|
||||
return
|
||||
}
|
||||
|
||||
configMapLock.Lock()
|
||||
defer configMapLock.Unlock()
|
||||
|
||||
|
@@ -34,3 +34,7 @@ func (tc *throwPacketRateConfig) setVal (val interface{}) (err error){
|
||||
func (tc *throwPacketRateConfig) getVal () (val interface{}){
|
||||
return tc.value
|
||||
}
|
||||
|
||||
func (tc *throwPacketRateConfig) GetValFloat64 () (val float64){
|
||||
return tc.value
|
||||
}
|
||||
|
Reference in New Issue
Block a user