Browse Source

Fixed SFTP server panic if upnp enabled but no UPNP router is found

Toby Chui 2 năm trước cách đây
mục cha
commit
3d5ccc76f5
1 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 3 3
      mod/fileservers/servers/sftpserv/sftpserv.go

+ 3 - 3
mod/fileservers/servers/sftpserv/sftpserv.go

@@ -79,7 +79,7 @@ func (m *Manager) closeInstance() {
 	//Remove the UPNP rules if enabled
 	enableUPnP := getUpnPEnabled(m.option.Sysdb)
 
-	if enableUPnP {
+	if enableUPnP && m.option.Upnp != nil {
 		m.option.Upnp.ClosePort(m.listeningPort)
 	}
 }
@@ -88,7 +88,7 @@ func (m *Manager) closeInstance() {
 	Handlers for handling config change
 */
 
-//Get or Set listening port for SFTP
+// Get or Set listening port for SFTP
 func (m *Manager) HandleListeningPort(w http.ResponseWriter, r *http.Request) {
 	newport, _ := utils.PostPara(r, "port")
 	if newport == "" {
@@ -185,7 +185,7 @@ func (m *Manager) HandleToogleUPnP(w http.ResponseWriter, r *http.Request) {
 }
 
 /*
-	Functions requested by the file server service router
+Functions requested by the file server service router
 */
 func (m *Manager) ServerToggle(enabled bool) error {
 	if m.instance != nil && !enabled {