reflector dns

This commit is contained in:
wencaiwulue
2021-08-07 11:32:15 +08:00
parent 53cf14a296
commit 1cd7d98a8f
8 changed files with 44 additions and 93 deletions

View File

@@ -4,7 +4,6 @@ import (
"bufio"
"crypto/tls"
"crypto/x509"
"encoding/json"
"errors"
gost2 "kubevpn/gost"
@@ -64,23 +63,6 @@ func loadCA(caFile string) (cp *x509.CertPool, err error) {
return
}
func parseKCPConfig(configFile string) (*gost2.KCPConfig, error) {
if configFile == "" {
return nil, nil
}
file, err := os.Open(configFile)
if err != nil {
return nil, err
}
defer file.Close()
config := &gost2.KCPConfig{}
if err = json.NewDecoder(file).Decode(config); err != nil {
return nil, err
}
return config, nil
}
func parseUsers(authFile string) (users []*url.Userinfo, err error) {
if authFile == "" {
return

View File

@@ -127,15 +127,9 @@ func main() {
log.Fatal(err)
}
//time.Sleep(time.Second * 5)
dnsServiceIp := dns.GetDNSServiceIpFromPod(clientset, restclient, config, remote.TrafficManager, namespace)
if runtime.GOOS != "windows" {
if err := dns.Dns(dnsServiceIp); err != nil {
log.Fatal(err)
}
} else {
if err := dns.Windows(dnsServiceIp); err != nil {
log.Fatal(err)
}
dnsServiceIp := util.GetDNSServiceIpFromPod(clientset, restclient, config, remote.TrafficManager, namespace)
if err := dns.DNS(dnsServiceIp); err != nil {
log.Fatal(err)
}
log.Info("dns service ok")
_ = exec.Command("ping", "-c", "4", "192.168.254.100").Run()

View File

@@ -6,7 +6,7 @@ import (
"encoding/json"
"io"
"io/ioutil"
gost2 "kubevpn/gost"
"kubevpn/gost"
"strconv"
"strings"
"time"
@@ -18,8 +18,8 @@ type peerConfig struct {
FailTimeout time.Duration
period time.Duration // the period for live reloading
Nodes []string `json:"nodes"`
group *gost2.NodeGroup
baseNodes []gost2.Node
group *gost.NodeGroup
baseNodes []gost.Node
stopped chan struct{}
}
@@ -45,14 +45,14 @@ func (cfg *peerConfig) Reload(r io.Reader) error {
group := cfg.group
group.SetSelector(
nil,
gost2.WithFilter(
&gost2.FailFilter{
gost.WithFilter(
&gost.FailFilter{
MaxFails: cfg.MaxFails,
FailTimeout: cfg.FailTimeout,
},
&gost2.InvalidFilter{},
&gost.InvalidFilter{},
),
gost2.WithStrategy(gost2.NewStrategy(cfg.Strategy)),
gost.WithStrategy(gost.NewStrategy(cfg.Strategy)),
)
gNodes := cfg.baseNodes