|
@ -7,6 +7,7 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
type Config struct { |
|
|
type Config struct { |
|
|
|
|
|
Log int `yaml:"log" json:"log"` |
|
|
Enable bool `yaml:"enable" json:"enable"` |
|
|
Enable bool `yaml:"enable" json:"enable"` |
|
|
Client []string `yaml:"client" json:"client"` |
|
|
Client []string `yaml:"client" json:"client"` |
|
|
Option map[string]string `yaml:"option" json:"option"` |
|
|
Option map[string]string `yaml:"option" json:"option"` |
|
@ -40,9 +41,9 @@ func loadOption(options map[string]string, intend int) string { // load options |
|
|
return ret |
|
|
return ret |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func loadClient(clients []string) string { |
|
|
func loadClient(clients []string) string { // load radvd client configure
|
|
|
if len(clients) == 0 { // without client settings
|
|
|
if len(clients) == 0 { |
|
|
return "" |
|
|
return "" // without client settings
|
|
|
} |
|
|
} |
|
|
ret := genSpace(4) + "clients {\n" |
|
|
ret := genSpace(4) + "clients {\n" |
|
|
for _, client := range clients { |
|
|
for _, client := range clients { |
|
@ -52,32 +53,32 @@ func loadClient(clients []string) string { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func loadPrefix(prefix string, option map[string]string) string { // load radvd prefix configure
|
|
|
func loadPrefix(prefix string, option map[string]string) string { // load radvd prefix configure
|
|
|
if prefix == "" { // without prefix settings
|
|
|
if prefix == "" { |
|
|
return "" |
|
|
return "" // without prefix settings
|
|
|
} |
|
|
} |
|
|
header := genSpace(4) + "prefix " + prefix + " {\n" |
|
|
header := genSpace(4) + "prefix " + prefix + " {\n" |
|
|
return header + loadOption(option, 8) + genSpace(4) + "};\n" |
|
|
return header + loadOption(option, 8) + genSpace(4) + "};\n" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func loadRoute(cidr string, option map[string]string) string { // load radvd route configure
|
|
|
func loadRoute(cidr string, option map[string]string) string { // load radvd route configure
|
|
|
if cidr == "" { // without route settings
|
|
|
if cidr == "" { |
|
|
return "" |
|
|
return "" // without route settings
|
|
|
} |
|
|
} |
|
|
header := genSpace(4) + "route " + cidr + " {\n" |
|
|
header := genSpace(4) + "route " + cidr + " {\n" |
|
|
return header + loadOption(option, 8) + genSpace(4) + "};\n" |
|
|
return header + loadOption(option, 8) + genSpace(4) + "};\n" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func loadRdnss(ip []string, option map[string]string) string { |
|
|
func loadRdnss(ip []string, option map[string]string) string { // load radvd RDNSS configure
|
|
|
if len(ip) == 0 { // without rdnss settings
|
|
|
if len(ip) == 0 { |
|
|
return "" |
|
|
return "" // without rdnss settings
|
|
|
} |
|
|
} |
|
|
header := genSpace(4) + "RDNSS " + strings.Join(ip, " ") + " {\n" |
|
|
header := genSpace(4) + "RDNSS " + strings.Join(ip, " ") + " {\n" |
|
|
return header + loadOption(option, 8) + genSpace(4) + "};\n" |
|
|
return header + loadOption(option, 8) + genSpace(4) + "};\n" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func loadDnssl(suffix []string, option map[string]string) string { |
|
|
func loadDnssl(suffix []string, option map[string]string) string { // load radvd DNSSL configure
|
|
|
if len(suffix) == 0 { // without dnssl settings
|
|
|
if len(suffix) == 0 { |
|
|
return "" |
|
|
return "" // without dnssl settings
|
|
|
} |
|
|
} |
|
|
header := genSpace(4) + "DNSSL " + strings.Join(suffix, " ") + " {\n" |
|
|
header := genSpace(4) + "DNSSL " + strings.Join(suffix, " ") + " {\n" |
|
|
return header + loadOption(option, 8) + genSpace(4) + "};\n" |
|
|
return header + loadOption(option, 8) + genSpace(4) + "};\n" |
|
|