@@ -330,6 +330,10 @@ function pruneLinks()
330330 /**
331331 * Resecure all currently secured sites with a fresh configuration.
332332 *
333+ * There are only two supported values: tld and loopback
334+ * And those must be submitted in pairs else unexpected results may occur.
335+ * eg: both $old and $new should contain the same indexes.
336+ *
333337 * @param array $old
334338 * @param array $new
335339 * @return void
@@ -765,37 +769,55 @@ function proxyDelete($url)
765769 function aliasLoopback ($ oldLoopback , $ loopback )
766770 {
767771 if ($ oldLoopback !== VALET_LOOPBACK ) {
768- $ this ->cli ->run (sprintf (
769- 'sudo ifconfig lo0 -alias %s ' , $ oldLoopback
770- ));
771-
772- info ('Old loopback interface alias removed [ ' .$ oldLoopback .'] ' );
772+ $ this ->removeLoopbackAlias ($ oldLoopback );
773773 }
774774
775775 if ($ loopback !== VALET_LOOPBACK ) {
776- $ this ->cli ->run (sprintf (
777- 'sudo ifconfig lo0 alias %s ' , $ loopback
778- ));
779-
780- info ('New loopback interface alias added [ ' .$ loopback .'] ' );
776+ $ this ->addLoopbackAlias ($ loopback );
781777 }
782778
783- $ this ->updatePlist ($ loopback );
779+ $ this ->updateLoopbackPlist ($ loopback );
784780 }
785781
786782 /**
787- * Remove old LaunchDaemon and create a new one if necessary .
783+ * Remove loopback interface alias .
788784 *
789785 * @param string $loopback
790786 * @return void
791787 */
792- function updatePlist ($ loopback )
788+ function removeLoopbackAlias ($ loopback )
793789 {
794- if ($ this ->files ->exists ($ this ->plistPath ())) {
795- $ this ->files ->unlink ($ this ->plistPath ());
790+ $ this ->cli ->run (sprintf (
791+ 'sudo ifconfig lo0 -alias %s ' , $ loopback
792+ ));
796793
797- info ('Old plist file removed [ ' .$ this ->plistPath ().'] ' );
798- }
794+ info ('[ ' .$ loopback .'] loopback interface alias removed. ' );
795+ }
796+
797+ /**
798+ * Remove loopback interface alias.
799+ *
800+ * @param string $loopback
801+ * @return void
802+ */
803+ function addLoopbackAlias ($ loopback )
804+ {
805+ $ this ->cli ->run (sprintf (
806+ 'sudo ifconfig lo0 alias %s ' , $ loopback
807+ ));
808+
809+ info ('[ ' .$ loopback .'] loopback interface alias added. ' );
810+ }
811+
812+ /**
813+ * Remove old LaunchDaemon and create a new one if necessary.
814+ *
815+ * @param string $loopback
816+ * @return void
817+ */
818+ function updateLoopbackPlist ($ loopback )
819+ {
820+ $ this ->removeLoopbackPlist ();
799821
800822 if ($ loopback !== VALET_LOOPBACK ) {
801823 $ this ->files ->put (
@@ -807,8 +829,36 @@ function updatePlist($loopback)
807829 )
808830 );
809831
810- info ('New plist file added [ ' .$ this ->plistPath ().'] ' );
832+ info ('[ ' .$ this ->plistPath ().'] persistent loopback interface alias launch daemon added. ' );
833+ }
834+ }
835+
836+ /**
837+ * Remove loopback interface alias launch daemon plist file.
838+ *
839+ * @return void
840+ */
841+ function removeLoopbackPlist ()
842+ {
843+ if ($ this ->files ->exists ($ this ->plistPath ())) {
844+ $ this ->files ->unlink ($ this ->plistPath ());
845+
846+ info ('[ ' .$ this ->plistPath ().'] persistent loopback interface alias launch daemon removed. ' );
847+ }
848+ }
849+
850+ /**
851+ * Remove loopback interface alias and launch daemon plist file for uninstall purpose.
852+ *
853+ * @return void
854+ */
855+ function uninstallLoopback ()
856+ {
857+ if (($ loopback = $ this ->valetLoopback ()) !== VALET_LOOPBACK ) {
858+ $ this ->removeLoopbackAlias ($ loopback );
811859 }
860+
861+ $ this ->removeLoopbackPlist ();
812862 }
813863
814864 function valetHomePath ()
@@ -824,8 +874,11 @@ function valetLoopback()
824874 /**
825875 * Get the path to loopback LaunchDaemon.
826876 *
827- * @return
828- return '/Library/LaunchDaemons.plist';
877+ * @return string
878+ */
879+ function plistPath ()
880+ {
881+ return '/Library/LaunchDaemons/com.laravel.valet.loopback.plist ' ;
829882 }
830883
831884 /**
0 commit comments