static bool EnableICS(string shared_uuid_or_name, string home_uuid_or_name) { var connectionToShare = IcsManager.FindConnectionByIdOrName(shared_uuid_or_name); if (connectionToShare == null) { throw new Exception(string.Format("Connection not found: {0}", shared_uuid_or_name)); } var homeConnection = IcsManager.FindConnectionByIdOrName(home_uuid_or_name); if (homeConnection == null) { throw new Exception(string.Format("Connection not found: {0}", home_uuid_or_name)); } var currentShare = IcsManager.GetCurrentlySharedConnections(); if (currentShare.Exists) { Console.WriteLine("Internet Connection Sharing is already enabled:"); Console.WriteLine(currentShare); Console.WriteLine("Sharing will be disabled first."); } IcsManager.ShareConnection(connectionToShare, homeConnection); return(Status()); }
static void EnableICS(string shared, string home, bool force) { var connectionToShare = IcsManager.FindConnectionByIdOrName(shared); if (connectionToShare == null) { Console.WriteLine("Connection not found: {0}", shared); return; } var homeConnection = IcsManager.FindConnectionByIdOrName(home); if (homeConnection == null) { Console.WriteLine("Connection not found: {0}", home); return; } var currentShare = IcsManager.GetCurrentlySharedConnections(); if (currentShare.Exists) { Console.WriteLine("Internet Connection Sharing is already enabled:"); Console.WriteLine(currentShare); if (!force) { Console.WriteLine("Please disable it if you want to configure sharing for other connections"); return; } Console.WriteLine("Sharing will be disabled first."); } IcsManager.ShareConnection(connectionToShare, homeConnection); }
static bool DisableICS() { var currentShare = IcsManager.GetCurrentlySharedConnections(); if (currentShare.Exists) { IcsManager.ShareConnection(null, null); } return(!Status()); }
static void DisableICS() { var currentShare = IcsManager.GetCurrentlySharedConnections(); if (!currentShare.Exists) { Console.WriteLine("Internet Connection Sharing is already disabled"); return; } Console.WriteLine("Internet Connection Sharing will be disabled:"); Console.WriteLine(currentShare); IcsManager.ShareConnection(null, null); }