You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
549 B
Go

package main
import (
"fmt"
"strings"
)
type forwardRules map[string]string
func (fr forwardRules) Get(uri string) string {
if fw, ok := fr[uri]; ok {
return fw
}
return ""
}
func (fr forwardRules) GetN(uri string, port int) string {
fw := fr.Get(uri)
if fw != "" {
return fw
}
if fw = fr.Get(fmt.Sprintf("*:%d", port)); fw != "" {
fw = strings.Replace(fw, "*", uri, 1)
return fw
}
return ""
}
type conf struct {
Timeout int
Listen []int
Default string
ForwardRules forwardRules `yaml:"forward_rules"`
}