Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 80ce60c

Browse files
fix: Fix port forwarding error issues (1Panel-dev#9700)
Refs 1Panel-dev#9658
1 parent 2758ab0 commit 80ce60c

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

‎agent/utils/firewall/client/iptables.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"regexp"
66
"strings"
7+
"time"
78

89
"github.com/1Panel-dev/1Panel/agent/app/model"
910
"github.com/1Panel-dev/1Panel/agent/global"
@@ -38,20 +39,9 @@ func NewIptables() (*Iptables, error) {
3839
return iptables, nil
3940
}
4041

41-
func (iptables *Iptables) run(rule string) error {
42-
stdout, err := cmd.RunDefaultWithStdoutBashCf("%s iptables -t nat %s", iptables.CmdStr, rule)
43-
if err != nil {
44-
return fmt.Errorf("%s, %s", err, stdout)
45-
}
46-
if stdout != "" {
47-
return fmt.Errorf("iptables error: %s", stdout)
48-
}
49-
50-
return nil
51-
}
52-
5342
func (iptables *Iptables) outf(tab, rule string, a ...any) (stdout string, err error) {
54-
stdout, err = cmd.RunDefaultWithStdoutBashCf("%s iptables -t %s %s", iptables.CmdStr, tab, fmt.Sprintf(rule, a...))
43+
cmdMgr := cmd.NewCommandMgr(cmd.WithIgnoreExist1(), cmd.WithTimeout(20*time.Second))
44+
stdout, err = cmdMgr.RunWithStdoutBashCf("%s iptables -t %s %s", iptables.CmdStr, tab, fmt.Sprintf(rule, a...))
5545
if err != nil && stdout != "" {
5646
global.LOG.Errorf("iptables failed, err: %s", stdout)
5747
}

‎agent/utils/firewall/client/ufw.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"strings"
66

77
"github.com/1Panel-dev/1Panel/agent/buserr"
8+
"github.com/1Panel-dev/1Panel/agent/global"
89
"github.com/1Panel-dev/1Panel/agent/utils/cmd"
910
)
1011

@@ -99,7 +100,9 @@ func (f *Ufw) ListPort() ([]FireInfo, error) {
99100
}
100101

101102
func (f *Ufw) ListForward() ([]FireInfo, error) {
102-
_ = f.EnableForward()
103+
if err := f.EnableForward(); err != nil {
104+
global.LOG.Errorf("init port forward failed, err: %v", err)
105+
}
103106
iptables, err := NewIptables()
104107
if err != nil {
105108
return nil, err

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /