Skip to content

Commit f2414fa

Browse files
committed
refine
1 parent 532db5d commit f2414fa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

exec/network/network_dns.go

+6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ package network
1919
import (
2020
"context"
2121
"fmt"
22+
"strings"
23+
2224
"github.com/chaosblade-io/chaosblade-exec-os/exec/category"
2325
"github.com/chaosblade-io/chaosblade-exec-os/exec/network/tc"
2426
"github.com/chaosblade-io/chaosblade-spec-go/log"
2527
"github.com/chaosblade-io/chaosblade-spec-go/spec"
2628
)
2729

30+
const sep = ","
31+
2832
type DnsActionSpec struct {
2933
spec.BaseExpActionCommandSpec
3034
}
@@ -109,6 +113,7 @@ const hosts = "/etc/hosts"
109113
const tmpHosts = "/tmp/chaos-hosts.tmp"
110114

111115
func (ns *NetworkDnsExecutor) start(ctx context.Context, domain, ip string) *spec.Response {
116+
domain = strings.ReplaceAll(domain, sep, " ")
112117
dnsPair := createDnsPair(domain, ip)
113118
response := ns.channel.Run(ctx, "grep", fmt.Sprintf(`-q "%s" %s`, dnsPair, hosts))
114119
if response.Success {
@@ -118,6 +123,7 @@ func (ns *NetworkDnsExecutor) start(ctx context.Context, domain, ip string) *spe
118123
}
119124

120125
func (ns *NetworkDnsExecutor) stop(ctx context.Context, domain, ip string) *spec.Response {
126+
domain = strings.ReplaceAll(domain, sep, " ")
121127
dnsPair := createDnsPair(domain, ip)
122128
response := ns.channel.Run(ctx, "grep", fmt.Sprintf(`-q "%s" %s`, dnsPair, hosts))
123129
if !response.Success {

0 commit comments

Comments
 (0)