@@ -19,12 +19,16 @@ package network
19
19
import (
20
20
"context"
21
21
"fmt"
22
+ "strings"
23
+
22
24
"github.com/chaosblade-io/chaosblade-exec-os/exec/category"
23
25
"github.com/chaosblade-io/chaosblade-exec-os/exec/network/tc"
24
26
"github.com/chaosblade-io/chaosblade-spec-go/log"
25
27
"github.com/chaosblade-io/chaosblade-spec-go/spec"
26
28
)
27
29
30
+ const sep = ","
31
+
28
32
type DnsActionSpec struct {
29
33
spec.BaseExpActionCommandSpec
30
34
}
@@ -109,6 +113,7 @@ const hosts = "/etc/hosts"
109
113
const tmpHosts = "/tmp/chaos-hosts.tmp"
110
114
111
115
func (ns * NetworkDnsExecutor ) start (ctx context.Context , domain , ip string ) * spec.Response {
116
+ domain = strings .ReplaceAll (domain , sep , " " )
112
117
dnsPair := createDnsPair (domain , ip )
113
118
response := ns .channel .Run (ctx , "grep" , fmt .Sprintf (`-q "%s" %s` , dnsPair , hosts ))
114
119
if response .Success {
@@ -118,6 +123,7 @@ func (ns *NetworkDnsExecutor) start(ctx context.Context, domain, ip string) *spe
118
123
}
119
124
120
125
func (ns * NetworkDnsExecutor ) stop (ctx context.Context , domain , ip string ) * spec.Response {
126
+ domain = strings .ReplaceAll (domain , sep , " " )
121
127
dnsPair := createDnsPair (domain , ip )
122
128
response := ns .channel .Run (ctx , "grep" , fmt .Sprintf (`-q "%s" %s` , dnsPair , hosts ))
123
129
if ! response .Success {
0 commit comments