passes tests with no rewrites
This commit is contained in:
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"local/rproxy3/storage/packable"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@@ -60,8 +61,16 @@ func GetRate() (int, int) {
|
||||
b := packable.NewString()
|
||||
conf.Get(nsConf, flagBurst, b)
|
||||
|
||||
rate, _ := strconv.Atoi(r.String())
|
||||
rate, err := strconv.Atoi(r.String())
|
||||
if err != nil {
|
||||
log.Printf("illegal rate: %v", err)
|
||||
rate = 5
|
||||
}
|
||||
burst, _ := strconv.Atoi(b.String())
|
||||
if err != nil {
|
||||
log.Printf("illegal burst: %v", err)
|
||||
burst = 5
|
||||
}
|
||||
|
||||
return rate, burst
|
||||
}
|
||||
@@ -77,3 +86,18 @@ func GetTimeout() int {
|
||||
|
||||
return timeout
|
||||
}
|
||||
|
||||
func GetRewrites() map[string]string {
|
||||
v := packable.NewString()
|
||||
conf.Get(nsConf, flagRewrites, v)
|
||||
m := make(map[string]string)
|
||||
for _, v := range strings.Split(v.String(), ",") {
|
||||
if len(v) == 0 {
|
||||
return m
|
||||
}
|
||||
from := v[:strings.Index(v, ":")]
|
||||
to := v[strings.Index(v, ":")+1:]
|
||||
m[from] = to
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user