File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed
backend/utils/firewall/client Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 88
99 "github.com/1Panel-dev/1Panel/backend/buserr"
1010 "github.com/1Panel-dev/1Panel/backend/constant"
11+ "github.com/1Panel-dev/1Panel/backend/global"
1112 "github.com/1Panel-dev/1Panel/backend/utils/cmd"
1213)
1314
@@ -118,6 +119,9 @@ func (f *Firewall) ListPort() ([]FireInfo, error) {
118119}
119120
120121func (f * Firewall ) ListForward () ([]FireInfo , error ) {
122+ if err := f .EnableForward (); err != nil {
123+ global .LOG .Errorf ("init port forward failed, err: %v" , err )
124+ }
121125 stdout , err := cmd .Exec ("firewall-cmd --zone=public --list-forward-ports" )
122126 if err != nil {
123127 return nil , err
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ func (iptables *Iptables) Check() error {
5252}
5353
5454func (iptables * Iptables ) NatNewChain () error {
55- return iptables .runf ("-t nat - N %s" , NatChain )
55+ return iptables .runf ("-N %s" , NatChain )
5656}
5757
5858func (iptables * Iptables ) NatAppendChain () error {
Original file line number Diff line number Diff line change 66
77 "github.com/1Panel-dev/1Panel/backend/buserr"
88 "github.com/1Panel-dev/1Panel/backend/constant"
9+ "github.com/1Panel-dev/1Panel/backend/global"
910 "github.com/1Panel-dev/1Panel/backend/utils/cmd"
1011)
1112
@@ -108,6 +109,12 @@ func (f *Ufw) ListForward() ([]FireInfo, error) {
108109 if err != nil {
109110 return nil , err
110111 }
112+ panelChian , _ := cmd .Execf ("%s iptables -t nat -L -n | grep 'Chain 1PANEL'" , iptables .CmdStr )
113+ if len (strings .ReplaceAll (panelChian , "\n " , "" )) == 0 {
114+ if err := f .EnableForward (); err != nil {
115+ global .LOG .Errorf ("init port forward failed, err: %v" , err )
116+ }
117+ }
111118 rules , err := iptables .NatList ()
112119 if err != nil {
113120 return nil , err
You can’t perform that action at this time.
0 commit comments