Skip to content

Commit e7715f7

Browse files
authored
Revert "fix hostname params and add full-disable params (#226) (#227)" (#235)
This reverts commit 6c378aa.
1 parent d321448 commit e7715f7

File tree

3 files changed

+6
-35
lines changed

3 files changed

+6
-35
lines changed

cmd/attack/network.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ func NewNetworkDelayCommand(dep fx.Option, options *core.NetworkCommand) *cobra.
8585
cmd.Flags().StringVarP(&options.IPProtocol, "protocol", "p", "",
8686
"only impact traffic using this IP protocol, supported: tcp, udp, icmp, all")
8787
cmd.Flags().StringVarP(&options.AcceptTCPFlags, "accept-tcp-flags", "", "", "only the packet which match the tcp flag can be accepted, others will be dropped. only set when the protocol is tcp.")
88-
cmd.Flags().BoolVar(&options.FullDisable, "full-disable", false, "network on device full disable flag")
8988

9089
return cmd
9190
}
@@ -115,7 +114,6 @@ func NewNetworkLossCommand(dep fx.Option, options *core.NetworkCommand) *cobra.C
115114
cmd.Flags().StringVarP(&options.Hostname, "hostname", "H", "", "only impact traffic to these hostnames")
116115
cmd.Flags().StringVarP(&options.IPProtocol, "protocol", "p", "",
117116
"only impact traffic using this IP protocol, supported: tcp, udp, icmp, all")
118-
cmd.Flags().BoolVar(&options.FullDisable, "full-disable", false, "network on device full disable flag")
119117

120118
return cmd
121119
}
@@ -145,7 +143,7 @@ func NewNetworkCorruptCommand(dep fx.Option, options *core.NetworkCommand) *cobr
145143
cmd.Flags().StringVarP(&options.Hostname, "hostname", "H", "", "only impact traffic to these hostnames")
146144
cmd.Flags().StringVarP(&options.IPProtocol, "protocol", "p", "",
147145
"only impact traffic using this IP protocol, supported: tcp, udp, icmp, all")
148-
cmd.Flags().BoolVar(&options.FullDisable, "full-disable", false, "network on device full disable flag")
146+
149147
return cmd
150148
}
151149

@@ -174,7 +172,7 @@ func NetworkDuplicateCommand(dep fx.Option, options *core.NetworkCommand) *cobra
174172
cmd.Flags().StringVarP(&options.Hostname, "hostname", "H", "", "only impact traffic to these hostnames")
175173
cmd.Flags().StringVarP(&options.IPProtocol, "protocol", "p", "",
176174
"only impact traffic using this IP protocol, supported: tcp, udp, icmp, all")
177-
cmd.Flags().BoolVar(&options.FullDisable, "full-disable", false, "network on device full disable flag")
175+
178176
return cmd
179177
}
180178

pkg/core/network.go

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ type NetworkCommand struct {
4343
IPProtocol string `json:"ip-protocol,omitempty"`
4444
Hostname string `json:"hostname,omitempty"`
4545

46-
Direction string `json:"direction,omitempty"`
47-
FullDisable bool `json:"full-disable,omitempty"`
46+
Direction string `json:"direction,omitempty"`
4847

4948
// used for DNS attack
5049
DNSServer string `json:"dns-server,omitempty"`
@@ -143,10 +142,6 @@ func (n *NetworkCommand) validNetworkDelay() error {
143142
return errors.Errorf("protocol should be 'tcp' when set accept-tcp-flags")
144143
}
145144

146-
if err := checkNetworkLimitParams(n.Hostname, n.IPAddress, n.FullDisable); err != nil {
147-
return err
148-
}
149-
150145
return checkProtocolAndPorts(n.IPProtocol, n.SourcePort, n.EgressPort)
151146
}
152147

@@ -155,9 +150,7 @@ func (n *NetworkCommand) validNetworkBandwidth() error {
155150
return errors.Errorf("rate, limit and buffer both are required when action is bandwidth")
156151
}
157152

158-
err := checkNetworkLimitParams(n.Hostname, n.IPAddress, n.FullDisable)
159-
160-
return err
153+
return nil
161154
}
162155

163156
func (n *NetworkCommand) validNetworkCommon() error {
@@ -181,10 +174,6 @@ func (n *NetworkCommand) validNetworkCommon() error {
181174
return errors.Errorf("ip addressed %s not valid", n.IPAddress)
182175
}
183176

184-
if err := checkNetworkLimitParams(n.Hostname, n.IPAddress, n.FullDisable); err != nil {
185-
return err
186-
}
187-
188177
return checkProtocolAndPorts(n.IPProtocol, n.SourcePort, n.EgressPort)
189178
}
190179

@@ -209,9 +198,7 @@ func (n *NetworkCommand) validNetworkPartition() error {
209198
return errors.Errorf("ip protocols %s not valid", n.IPProtocol)
210199
}
211200

212-
err := checkNetworkLimitParams(n.Hostname, n.IPAddress, n.FullDisable)
213-
214-
return err
201+
return nil
215202
}
216203

217204
func (n *NetworkCommand) validNetworkDNS() error {
@@ -346,20 +333,6 @@ func checkProtocolAndPorts(p string, sports string, dports string) error {
346333
return nil
347334
}
348335

349-
func checkNetworkLimitParams(hostname string, ipaddress string, fullDisable bool) error { // revive:disable-line:flag-parameter
350-
if len(hostname) == 0 && len(ipaddress) == 0 && !fullDisable {
351-
return errors.New("hostname or ip address is required")
352-
}
353-
354-
if fullDisable {
355-
if len(hostname) > 0 || len(ipaddress) > 0 {
356-
return errors.New("the host and address are set, but the flag full-disable is enabled")
357-
}
358-
}
359-
360-
return nil
361-
}
362-
363336
func (n NetworkCommand) RecoverData() string {
364337
data, _ := json.Marshal(n)
365338

test/integration_test/jvm/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export MYSQL_USER=root
8484
export MYSQL_CONNECTOR_VERSION=8
8585
mvn exec:java -Dexec.mainClass="com.mysqldemo.App" > mysqldemo.log 2>&1 &
8686
# make sure it works
87-
for (( i=0; i<=30; i++ ))
87+
for (( i=0; i<=20; i++ ))
8888
do
8989
tail_log=`tail -1 mysqldemo.log`
9090
if [ "$tail_log" == "Server start!" ]; then

0 commit comments

Comments
 (0)