Skip to content

Commit

Permalink
OSCQuery WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenithVal committed Aug 2, 2023
1 parent ca56a0a commit e9944b9
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 36 deletions.
16 changes: 10 additions & 6 deletions App.config
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0"/>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.1" newVersion="7.0.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /></startup></configuration>
1 change: 1 addition & 0 deletions Configs/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public static void Reset() {
File.Delete("app.pass");
File.WriteAllText(CONFIG_FILE, TomletMain.TomlStringFrom(new MainConfig {

oscQuery = true,
ipAddress = "127.0.0.1",
listener_port = 9001,
write_port = 9000,
Expand Down
4 changes: 4 additions & 0 deletions Configs/MainConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

namespace OSCLock.Configs {
public class MainConfig {
[TomlProperty("OSCQuery")]
[TomlInlineComment("Enable OSCQuery; Custom Port/IP settings will be ignored.")]
public bool oscQuery { get; set; }

[TomlProperty("ip")]
public string ipAddress { get; set; }

Expand Down
54 changes: 51 additions & 3 deletions OSCLock.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -44,6 +59,12 @@
<Reference Include="FluentColorConsole, Version=2.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\FluentColorConsole.2.0.1\lib\netstandard2.0\FluentColorConsole.dll</HintPath>
</Reference>
<Reference Include="MeaMod.DNS, Version=1.0.70.2032, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\MeaMod.DNS.1.0.70\lib\net47\MeaMod.DNS.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.Logging.Abstractions.7.0.1\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand All @@ -53,22 +74,35 @@
<HintPath>References\SharpOSC\SharpOSC.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
<Private>True</Private>
Expand All @@ -89,9 +123,11 @@
</Reference>
<Reference Include="System.Windows" />
<Reference Include="System.Xml" />
<Reference Include="Tomlet, Version=5.1.3.0, Culture=neutral, PublicKeyToken=null">
<HintPath>packages\Samboy063.Tomlet.5.1.3\lib\net35\Tomlet.dll</HintPath>
<Private>True</Private>
<Reference Include="Tomlet, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Samboy063.Tomlet.5.2.0\lib\net35\Tomlet.dll</HintPath>
</Reference>
<Reference Include="vrc-oscquery-lib">
<HintPath>References\OSCQuery\vrc-oscquery-lib.dll</HintPath>
</Reference>
<Reference Include="Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime">
<HintPath>C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.19041.0\Windows.winmd</HintPath>
Expand Down Expand Up @@ -132,6 +168,18 @@
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\System.Runtime.WindowsRuntime.5.0.0-preview.5.20278.1\build\net461\System.Runtime.WindowsRuntime.targets" Condition="Exists('packages\System.Runtime.WindowsRuntime.5.0.0-preview.5.20278.1\build\net461\System.Runtime.WindowsRuntime.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
10 changes: 1 addition & 9 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,7 @@ private static async Task CmdPrompt() {

do {
Console.Clear();
//Swithc statements for the possible UI options
//S - await PrintStatus();
//H - await PrintHelp();
//T - await StartTimer();
//U - await UnlockDevice();
//F7 - await EncryptApp();
//F8 - await DecryptApp();
//Q - Quit
//Default - Console.WriteLine($"Unknown command {Key}"); and PrintHelp();
//Switch statements for the possible UI options

switch (Key) {
case 's':
Expand Down
Binary file added References/OSCQuery/vrc-oscquery-lib.dll
Binary file not shown.
Binary file added References/OSCQuery/vrc-oscquery-lib.pdb
Binary file not shown.
57 changes: 40 additions & 17 deletions VRChatConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using OSCLock.Configs;
using OSCLock.Logic;
using SharpOSC;

using VRC.OSCQuery;

namespace OSCLock {
public static class VRChatConnector {
Expand All @@ -20,6 +20,7 @@ public static class VRChatConnector {
private static UDPListener oscListener;
private static UDPSender oscSender;
public static bool debugging;
private static bool oscQuery;
private static int listener_port;
private static int write_port;
private static string ipAddress;
Expand All @@ -37,36 +38,62 @@ public static void Start() {

//Load VRchat Connector settings.
try {
oscQuery = ConfigManager.ApplicationConfig.oscQuery;
listener_port = ConfigManager.ApplicationConfig.listener_port;
write_port = ConfigManager.ApplicationConfig.write_port;
ipAddress = ConfigManager.ApplicationConfig.ipAddress ?? "127.0.0.1";
debugging = ConfigManager.ApplicationConfig.debugging;
}
catch (Exception e) {
ColorConsole.WithRedText.WriteLine($"Connector config load failed: {e.Message}\n\nPlease check your config file and reboot.");
Task.Delay(5000).Wait();
Environment.Exit(0);
}

if (oscQuery) {
try {
write_port = Extensions.GetAvailableTcpPort();
listener_port = Extensions.GetAvailableUdpPort();

var oscQuery = new OSCQueryServiceBuilder()
.WithDefaults()
.WithTcpPort(write_port)
.WithUdpPort(listener_port)
.WithServiceName("OSCLock")
.Build();
}
catch (Exception e) {
ColorConsole.WithRedText.WriteLine($"OSCQuery failed: {e.Message}\n\n");
Task.Delay(5000).Wait();
Environment.Exit(0);
}

if (ipAddress == "127.0.0.1") Console.WriteLine("ip: LocalHost");
}

//Config readout
Console.WriteLine($"OSCQuery: {oscQuery}");

if (ipAddress == "127.0.0.1") Console.WriteLine("ip: LocalHost");
//If debugging, display the whole IP.
else if (debugging) Console.WriteLine("ip: " + ipAddress);
//If not localhost, partially hide the IP. Just in case.
else Console.WriteLine("ip: " + ipAddress.Substring(0, 3) + "###.###." + ipAddress.Substring(ipAddress.Length - 3, 3));

Console.WriteLine("listener_port: " + listener_port);
Console.WriteLine("write_port: " + write_port);
Console.WriteLine("listener_port: " + listener_port);
Console.WriteLine("write_port: " + write_port);

Console.WriteLine($"mode: {ConfigManager.ApplicationConfig.mode}");
Console.WriteLine($"debugging: {debugging}");
}
catch (Exception e) {
ColorConsole.WithRedText.WriteLine($"Connector config load failed: {e.Message}\n\nPlease check your config file and reboot.");
Task.Delay(5000).Wait();
Environment.Exit(0);
}
Console.WriteLine($"mode: {ConfigManager.ApplicationConfig.mode}");
Console.WriteLine($"debugging: {debugging}");

Task.Delay(5000).Wait();

//Boot OSC Listener and Sender
try {
oscListener = new UDPListener(listener_port, OnOscMessage);
oscSender = new UDPSender(ipAddress, write_port);

}
//90% of the time this will fail because the port they attempted to use is already occupied.
//Usually this only fails if the port it attempted to use was occupied by another app.
catch (Exception e) {
Console.WriteLine($"\nUDPListener failed: {e.Message}\n\n");
ColorConsole.WithRedText.WriteLine("Make sure you're not attempting to run two apps on the same port.");
Expand Down Expand Up @@ -101,10 +128,6 @@ public static void Start() {


}


//todo: add one for avatar change' - Neet
//Actually, what would be the purpose of that? - Zeni
}


Expand Down
8 changes: 7 additions & 1 deletion packages.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentColorConsole" version="2.0.1" targetFramework="net48" />
<package id="MeaMod.DNS" version="1.0.70" targetFramework="net48" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="7.0.1" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="Samboy063.Tomlet" version="5.1.3" targetFramework="net48" />
<package id="Samboy063.Tomlet" version="5.2.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.IO" version="4.3.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime" version="4.3.1" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
<package id="System.Runtime.WindowsRuntime" version="5.0.0-preview.5.20278.1" targetFramework="net48" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net48" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net48" />
Expand Down

0 comments on commit e9944b9

Please sign in to comment.