Преглед изворни кода

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

Toby Chui пре 2 година
родитељ
комит
3d5ccc76f5
1 измењених фајлова са 3 додато и 3 уклоњено
  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 {