Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
Added json configuration to allow for configurable ports
  • Loading branch information
Meister1593 committed Jan 3, 2024
1 parent 362f35a commit a4d2a4a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 25 deletions.
7 changes: 7 additions & 0 deletions ADBForwarder/ADBForwarder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="SharpAdbClient" Version="2.3.23"/>
<PackageReference Include="SharpZipLib" Version="1.4.2"/>
</ItemGroup>
<ItemGroup>
<None Update="config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
22 changes: 20 additions & 2 deletions ADBForwarder/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
Expand All @@ -9,17 +10,32 @@
using System.Threading.Tasks;
using SharpAdbClient;
using ICSharpCode.SharpZipLib.Zip;
using Microsoft.Extensions.Configuration;

namespace ADBForwarder
{
internal class PortConfiguration(List<int> ports)
{
public List<int> Ports { get; init; } = ports;
}

internal static class Program
{
private static readonly AdbClient Client = new();
private static readonly AdbServer Server = new();
private static readonly IPEndPoint EndPoint = new(IPAddress.Loopback, AdbClient.AdbServerPort);
private static PortConfiguration _portConfiguration;

private static void Main()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("config.json", optional: false);

IConfiguration config = builder.Build();

_portConfiguration = config.GetSection("PortConfiguration").Get<PortConfiguration>();

Console.ResetColor();
var currentDirectory = Path.GetDirectoryName(AppContext.BaseDirectory);
if (currentDirectory == null)
Expand Down Expand Up @@ -113,8 +129,10 @@ private static void Forward(DeviceData device)
return;
}

Client.CreateForward(deviceData, 9943, 9943);
Client.CreateForward(deviceData, 9944, 9944);
foreach (var port in _portConfiguration.Ports)
{
Client.CreateForward(deviceData, port, port);
}

Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"Successfully forwarded device: {deviceData.Serial} [{deviceData.Product}]");
Expand Down
8 changes: 8 additions & 0 deletions ADBForwarder/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"PortConfiguration": {
"Ports": [
9943,
9944
]
}
}
36 changes: 13 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,31 @@
# ADBForwarder

Console application designed to handle forwarding TCP Ports (using [ADB](https://developer.android.com/studio/command-line/adb)) between your PC and Quest/Go HMDs, over USB
Console application designed to handle forwarding TCP Ports (using [ADB](https://developer.android.com/studio/command-line/adb)) between your PC and Android devices, over USB

Specifically made for use with [ALVR](https://github.com/alvr-org/ALVR), for now. Supports the Oculus Go, Quest 1 and 2
Specifically made for use with [ALVR](https://github.com/alvr-org/ALVR),
but config.json can be configured to work with any port needed for any other purposes.

### [Download here!](https://github.com/AtlasTheProto/ADBForwarder/releases/latest/download/ADBForwarder.zip)
Supports any ADB compatible device

### [Download here!](https://github.com/alvr-org/ADBForwarder/releases)

## Usage

* [Download the latest release](https://github.com/AtlasTheProto/ADBForwarder/releases/latest/download/ADBForwarder.zip)
* Extract the archive somewhere convenient
* [Download the latest release](https://github.com/alvr-org/ADBForwarder/releases)
* Extract the archive somewhere convenient in a separate directory
* Run the program and ALVR, order does not matter
* ALVR may (or may not) restart
* You should see your device's serial ID show up in the console, if it says the following, all is well!
* `Successfully forwarded device: 1WMHHXXXXXXXXX [hollywood]`
* "hollywood" is Quest 2, "monterey" is Quest 1, "pacific" is Go

## Windows

If the program won't run, try installing the [DotNet 4.6.1 Runtime](https://www.microsoft.com/en-us/download/details.aspx?id=49982)

## Linux

You need to use [Mono](https://www.mono-project.com/download/stable/)
* `Successfully forwarded device: ...`

## Problems?

Don't hesitate to raise an [issue](https://github.com/AtlasTheProto/ADBForwarder/issues) if you encounter problems!

## Future Support

Development on this has basically stopped, I got an Index.

I encourage anyone who finds fixes, bugs, or new features to manage and advertise their own fork, if this repository becomes outdated, ask the ALVR team members to update the proper wiki links for this program to the new fork / etc.
Don't hesitate to raise an [issue](https://github.com/alvr-org/ADBForwarder/issues) if you encounter problems!

## Attributions

Thank you, [Mantas-2155X](https://github.com/Mantas-2155X), for iterating and refactoring my work, to bring Linux support!
Thank you. [AtlasTheProto](https://github.com/AtlasTheProto), for OG ADBForwarder codebase

Thank you, [Mantas-2155X](https://github.com/Mantas-2155X), for iterating and refactoring AtlasTheProto's work, to bring Linux support!

Thank you, [Quamotion](https://github.com/quamotion), for [SharpADBClient](https://github.com/quamotion/madb)!

0 comments on commit a4d2a4a

Please sign in to comment.