mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 05:46:32 +00:00
reject with reset
This commit is contained in:
@@ -44,15 +44,13 @@ func (p Provider) KillTendermint(ctx context.Context, n *e2e.Node) error {
|
||||
}
|
||||
func (p Provider) Disconnect(ctx context.Context, n *e2e.Node) error {
|
||||
return e2essh.MultiExec(p.SSHConfig, fmt.Sprintf("%s:%d", n.IP, sshPort),
|
||||
"iptables -A INPUT -p tcp --destination-port 26656 -j DROP",
|
||||
"iptables -A OUTPUT -p tcp --destination-port 26656 -j DROP",
|
||||
"service iptables save",
|
||||
"iptables -A INPUT -p tcp --destination-port 26656 -j REJECT --reject-with tcp-reset",
|
||||
"iptables -A OUTPUT -p tcp --destination-port 26656 -j REJECT --reject-with tcp-reset",
|
||||
)
|
||||
}
|
||||
func (p Provider) Connect(ctx context.Context, n *e2e.Node) error {
|
||||
return e2essh.MultiExec(p.SSHConfig, fmt.Sprintf("%s:%d", n.IP, sshPort),
|
||||
"iptables -D INPUT -p tcp --destination-port 26656 -j DROP",
|
||||
"iptables -D OUTPUT -p tcp --destination-port 26656 -j DROP",
|
||||
"service iptables save",
|
||||
"iptables -D INPUT -p tcp --destination-port 26656 -j REJECT --reject-with tcp-reset",
|
||||
"iptables -D OUTPUT -p tcp --destination-port 26656 -j REJECT --reject-with tcp-reset",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,11 @@ func Exec(cfg *ssh.ClientConfig, addr, cmd string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer c.Close()
|
||||
s, err := c.NewSession()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer s.Close()
|
||||
err = s.Run(cmd)
|
||||
if err != nil {
|
||||
@@ -29,16 +33,21 @@ func Exec(cfg *ssh.ClientConfig, addr, cmd string) error {
|
||||
|
||||
func MultiExec(cfg *ssh.ClientConfig, addr string, cmds ...string) error {
|
||||
c, err := ssh.Dial("tcp", addr, cfg)
|
||||
s, err := c.NewSession()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer s.Close()
|
||||
defer c.Close()
|
||||
for _, cmd := range cmds {
|
||||
err := s.Run(cmd)
|
||||
s, err := c.NewSession()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = s.Run(cmd)
|
||||
if err != nil {
|
||||
s.Close()
|
||||
return err
|
||||
}
|
||||
s.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user