passes tests with no rewrites

This commit is contained in:
Bel LaPointe
2019-04-10 10:08:47 -06:00
parent 3bd1527b98
commit f72ecc5e53
3 changed files with 78 additions and 7 deletions

View File

@@ -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
}