func (pm *PasswdManager) updatePortPasswd(port, password string) {
	pl, ok := pm.get(port)
	if !ok {
		log.Printf("new port %s added\n", port)
	} else {
		if pl.password == password {
			return
		}
		log.Printf("closing port %s to update password\n", port)
		pl.listener.Close()
	}
	// run will add the new port listener to passwdManager.
	// So there maybe concurrent access to passwdManager and we need lock to protect it.
	go run(port, password)
	if udp {
		pl, ok := pm.getUDP(port)
		if !ok {
			log.Printf("new udp port %s added\n", port)
		} else {
			if pl.password == password {
				return
			}
			log.Printf("closing udp port %s to update password\n", port)
			pl.listener.Close()
		}
		go runUDP(port, password)
	}
}
// Update port password would first close a port and restart listening on that
// port. A different approach would be directly change the password used by
// that port, but that requires **sharing** password between the port listener
// and password manager.
Update port password would first close a port and restart listening on that
port. A different approach would be directly change the password used by
that port, but that requires **sharing** password between the port listener
and password manager.
// Update port password would first close a port and restart listening on that // port . A different approach would be directly change the password used by // that port but that requires ** sharing ** password between the port listener // and password manager .
func (pm *PasswdManager) updatePortPasswd(port, password string) {
	pl, ok := pm.get(port)
	if !ok {
		log.Printf("new port %s added\n", port)
	} else {
		if pl.password == password {
			return
		}
		log.Printf("closing port %s to update password\n", port)
		pl.listener.Close()
	}
	go run(port, password)
	if udp {
		pl, ok := pm.getUDP(port)
		if !ok {
			log.Printf("new udp port %s added\n", port)
		} else {
			if pl.password == password {
				return
			}
			log.Printf("closing udp port %s to update password\n", port)
			pl.listener.Close()
		}
		go runUDP(port, password)
	}
}
func ( pm * PasswdManager ) updatePortPasswd ( port , password string ) { pl , ok := pm . get ( port ) if ! ok { log . Printf ( " \n " , port ) } else { if pl . password == password { return } log . Printf ( " \n " , port ) pl . listener . Close ( ) } go run ( port , password ) if udp { pl , ok := pm . getUDP ( port ) if ! ok { log . Printf ( " \n " , port ) } else { if pl . password == password { return } log . Printf ( " \n " , port ) pl . listener . Close ( ) } go runUDP ( port , password ) } }
Update port password would first close a port and restart listening on that
port.
Update port password would first close a port and restart listening on that port .
// run will add the new port listener to passwdManager. // So there maybe concurrent access to passwdManager and we need lock to protect it.