-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from InvisibleManVPN/develop
InvisibleMan XRay version 2.3.2
- Loading branch information
Showing
18 changed files
with
400 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
|
||
namespace InvisibleManXRay.Handlers | ||
{ | ||
using DeepLinks; | ||
using Values; | ||
|
||
public class DeepLinkHandler : Handler | ||
{ | ||
private IDeepLink deepLink; | ||
|
||
private Action<string> onConfigLinkFetched; | ||
private Action<string> onSubscriptionLinkFetched; | ||
|
||
public DeepLinkHandler() | ||
{ | ||
InitializeDeepLink(); | ||
} | ||
|
||
public void Setup( | ||
ref Action<string> onReceiveArg, | ||
Action<string> onConfigLinkFetched, | ||
Action<string> onSubscriptionLinkFetched | ||
) | ||
{ | ||
onReceiveArg = TryFetchLink; | ||
this.onConfigLinkFetched = onConfigLinkFetched; | ||
this.onSubscriptionLinkFetched = onSubscriptionLinkFetched; | ||
} | ||
|
||
private void InitializeDeepLink() | ||
{ | ||
this.deepLink = GetDeepLink(); | ||
deepLink.Register(); | ||
} | ||
|
||
private IDeepLink GetDeepLink() | ||
{ | ||
WindowsDeepLink windowsDeepLink = new WindowsDeepLink(); | ||
return windowsDeepLink; | ||
} | ||
|
||
private void TryFetchLink(string arg) | ||
{ | ||
if (IsValidConfigLink()) | ||
onConfigLinkFetched.Invoke(GetConfigLink()); | ||
else if (IsValidSubscriptionLink()) | ||
onSubscriptionLinkFetched.Invoke(GetSubscriptionLink()); | ||
|
||
bool IsValidConfigLink() | ||
{ | ||
return arg.StartsWith(DeepLink.CONFIG) | ||
&& !string.IsNullOrEmpty(GetConfigLink()); | ||
} | ||
|
||
bool IsValidSubscriptionLink() | ||
{ | ||
return arg.StartsWith(DeepLink.SUBSCRIPTION) | ||
&& !string.IsNullOrEmpty(GetSubscriptionLink()); | ||
} | ||
|
||
string GetConfigLink() => arg.Replace(DeepLink.CONFIG, "").Trim(); | ||
|
||
string GetSubscriptionLink() => arg.Replace(DeepLink.SUBSCRIPTION, "").Trim(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace InvisibleManXRay.Handlers.DeepLinks | ||
{ | ||
public interface IDeepLink | ||
{ | ||
void Register(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Windows; | ||
using Microsoft.Win32; | ||
|
||
namespace InvisibleManXRay.Handlers.DeepLinks | ||
{ | ||
using Values; | ||
|
||
public class WindowsDeepLink : IDeepLink | ||
{ | ||
private const string URI_SCHEME = $@"Software\Classes\{DeepLink.SCHEME}"; | ||
private const string SHELL_OPEN_COMMAND = @"shell\open\command"; | ||
private const string URL_PROTOCOL = "URL Protocol"; | ||
|
||
private string AppName => Application.ResourceAssembly.GetName().Name; | ||
private string AppPath => Environment.ProcessPath; | ||
|
||
public void Register() | ||
{ | ||
try | ||
{ | ||
RegistryKey registry = GetApplicationClassRegistery(); | ||
|
||
registry.SetValue("", $"URL:{AppName}"); | ||
registry.SetValue(URL_PROTOCOL, ""); | ||
registry.CreateSubKey(SHELL_OPEN_COMMAND).SetValue( | ||
name: "", | ||
value: $"\"{AppPath}\" \"%1\"" | ||
); | ||
} | ||
catch | ||
{ | ||
} | ||
} | ||
|
||
private RegistryKey GetApplicationClassRegistery() | ||
{ | ||
RegistryKey registry = Registry.CurrentUser.CreateSubKey(URI_SCHEME); | ||
return registry; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.IO; | ||
using System.IO.Pipes; | ||
using System.Windows; | ||
using System.Threading.Tasks; | ||
|
||
namespace InvisibleManXRay.Managers | ||
{ | ||
public static class PipeManager | ||
{ | ||
private const string PIPE_NAME = "InvisibleManXRayPipe"; | ||
|
||
public static Action<string> OnReceiveArg = delegate{}; | ||
|
||
public static void ListenForPipes() | ||
{ | ||
Task.Run(() => { | ||
while(true) | ||
{ | ||
NamedPipeServerStream pipeServer = new NamedPipeServerStream(PIPE_NAME); | ||
pipeServer.WaitForConnection(); | ||
|
||
StreamReader reader = new StreamReader(pipeServer); | ||
string message = reader.ReadToEnd(); | ||
Application.Current.Dispatcher.BeginInvoke(new Action(delegate { | ||
OnReceiveArg.Invoke(message); | ||
})); | ||
|
||
pipeServer.Close(); | ||
pipeServer.Dispose(); | ||
} | ||
}); | ||
} | ||
|
||
public static void SignalOpenedApp(string[] args) | ||
{ | ||
NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", PIPE_NAME); | ||
pipeClient.Connect(); | ||
|
||
StreamWriter writer = new StreamWriter(pipeClient); | ||
writer.WriteLine(args[0]); | ||
writer.Flush(); | ||
writer.Close(); | ||
} | ||
|
||
public static void SignalThisApp(string[] args) | ||
{ | ||
OnReceiveArg.Invoke(args[0]); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
InvisibleMan-XRay/Services/Analytics/Configuration/ShareButtonClickedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace InvisibleManXRay.Services.Analytics.Configuration | ||
{ | ||
public class ShareButtonClickedEvent : ConfigurationEvent | ||
{ | ||
|
||
} | ||
} |
Oops, something went wrong.