99 "github.com/1Panel-dev/1Panel/agent/app/model"
1010 "github.com/1Panel-dev/1Panel/agent/app/repo"
1111 "github.com/1Panel-dev/1Panel/agent/buserr"
12+ "github.com/1Panel-dev/1Panel/agent/constant"
1213 "github.com/1Panel-dev/1Panel/agent/utils/encrypt"
1314 "github.com/1Panel-dev/1Panel/agent/utils/ssh"
1415 "github.com/jinzhu/copier"
@@ -22,6 +23,7 @@ type ISettingService interface {
2223
2324 TestConnByInfo (req dto.SSHConnData ) bool
2425 SaveConnInfo (req dto.SSHConnData ) error
26+ SetDefaultIsConn (req dto.SSHDefaultConn ) error
2527 GetSystemProxy () (* dto.SystemProxy , error )
2628 GetLocalConn () dto.SSHConnData
2729 GetSettingByKey (key string ) string
@@ -125,6 +127,15 @@ func (u *SettingService) SaveConnInfo(req dto.SSHConnData) error {
125127 return nil
126128}
127129
130+ func (u * SettingService ) SetDefaultIsConn (req dto.SSHDefaultConn ) error {
131+ if req .DefaultConn == constant .StatusDisable && req .WithReset {
132+ if err := settingRepo .Update ("LocalSSHConn" , "" ); err != nil {
133+ return err
134+ }
135+ }
136+ return settingRepo .Update ("LocalSSHConnShow" , req .DefaultConn )
137+ }
138+
128139func (u * SettingService ) GetSystemProxy () (* dto.SystemProxy , error ) {
129140 systemProxy := dto.SystemProxy {}
130141 systemProxy .Type , _ = settingRepo .GetValueByKey ("ProxyType" )
@@ -138,6 +149,7 @@ func (u *SettingService) GetSystemProxy() (*dto.SystemProxy, error) {
138149
139150func (u * SettingService ) GetLocalConn () dto.SSHConnData {
140151 var data dto.SSHConnData
152+ data .LocalSSHConnShow , _ = settingRepo .GetValueByKey ("LocalSSHConnShow" )
141153 connItem , _ := settingRepo .GetValueByKey ("LocalSSHConn" )
142154 if len (connItem ) == 0 {
143155 return data
0 commit comments