Code Monkey home page Code Monkey logo

dotnet-tor's Introduction

Icon dotnet-tor

Version Downloads License

Installing or updating (same command can be used for both):

dotnet tool update -g dotnet-tor

Usage:

> dotnet tor -?
tor
  Tor proxy service

Usage:
  tor [options] [command]

Options:
  -p, --proxy <proxy>      Proxy port [default: 1337]
  -s, --socks <socks>      Socks port [default: 1338]
  -c, --control <control>  Control port [default: 1339]
  --version                Show version information
  -?, -h, --help           Show help and usage information

Commands:
  add <name> <service>  Adds a service to register on the Tor network
  config                Edits the full torrc configuration file.

The program will automatically check for updates once a day and recommend updating if there is a new version available.

Configured services are persisted in the global dotnet-config file at %userprofile%\tor\.netconfig, and on first run (after configuration), their .onion address and keys will be available in a sub-directory alongside the .netconfig. This allows the tool to self-update while preserving all configurations and services.

Exposing local HTTP APIs via Tor

After installation, you might want to expose an .NET Core HTTP service from local port 7071 over the Tor network on port 80. You could configure the service with:

> dotnet tor add api 127.0.0.1:7071 -p 80

Then start the Tor proxy normally with:

> dotnet tor

There will now be a %userprofile%\tor\.netconfig\api\hostname file with the .onion address for the service, like 2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion. You can now reach web API endpoints natively via a .NET 6 client with:

using System;
using System.Net;
using System.Net.Http;

var http = new HttpClient(new HttpClientHandler
{
    Proxy = new WebProxy("socks5://127.0.0.1:1338")
});

var response = await http.GetAsync("http://2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion/[endpoint]"));

The client can just use another dotnet-tor proxy running locally with default configuration values and things will Just Work™ and properly reach the destination service running anywhere in the world :).

You can even expose the local HTTPS endpoint instead. In this case, the client would need to perform custom validation (or entirely bypass it) of the certificate, but otherwise, things work as-is too.

Service-side:

> dotnet tor add api 127.0.0.1:5001 -p 443

Note that since we're exposing the service over the default port for SSL, we don't need to specify the port in the client:

var http = new HttpClient(new HttpClientHandler
{
    ClientCertificateOptions = ClientCertificateOption.Manual,
    ServerCertificateCustomValidationCallback = (_, _, _, _) => true,
    Proxy = new WebProxy("socks5://127.0.0.1:1338"),
});

var response = await http.SendAsync(new HttpRequestMessage(HttpMethod.Get, "https://kbu3mvegpytu4gewdgvjae7zhrzszmetmr5jdlwk5ct5pfzlbaqbdqqd.onion")
{
    Content = new StringContent("Hello World!")
});

response.EnsureSuccessStatusCode();

You can play around with a trivial echo service by installing the dotnet-echo tool and exposing it over the Tor network.

Dogfooding

CI Version Build

We also produce CI packages from branches and pull requests so you can dogfood builds as quickly as they are produced.

The CI feed is https://pkg.kzu.io/index.json.

The versioning scheme for packages is:

  • PR builds: 42.42.42-pr[NUMBER]
  • Branch builds: 42.42.42-[BRANCH].[COMMITS]

Sponsors

Clarius Org Kirill Osenkov MFB Technologies, Inc. Stephen Shaw Torutek DRIVE.NET, Inc. Daniel Gnägi Ashley Medway Keith Pickford Thomas Bolon Kori Francis Sean Killeen Toni Wenzel Giorgi Dalakishvili Mike James Dan Siegel Reuben Swartz Jacob Foshee Eric Johnson Norman Mackay Certify The Web Ix Technologies B.V. David JENNI Jonathan Oleg Kyrylchuk Charley Wu Jakob Tikjøb Andersen Seann Alexander Tino Hager Mark Seemann Angelo Belchior Ken Bonny Simon Cropp agileworks-eu sorahex Zheyu Shen Vezel

Sponsor this project  

Learn more about GitHub Sponsors

dotnet-tor's People

Contributors

dependabot[bot] avatar devlooped-bot avatar kzu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

piano1029

dotnet-tor's Issues

Add support for registering hidden services

We should support registering services and properly configuring them:

> dotnet tor add echo 127.0.0.1:8080

The port for the onion service should default to the hidden service port.
The service directory should be under ~/tor/[name], since the service keys and address should be reused across tool reinstalls/updates (especially updates of the tor binaries themselves).

The configuration should also be at ~/tor/.netconfig, and would look like the following:

[tor]
	proxy = 1337
	socks = 1338
	control = 1339
[tor "echo"]
	port = 8080
	service = 127.0.0.1:8080

Across dotnet tor restarts, previously configured services in torrc should be cleared and re-added, so that older entries don't pollute the file unnecessarily. A known section separator like #! dotnet-tor will be used to distinguish our settings from user-specified settings (which can be added via dotnet tor config).

Add support for manually configuring the torrc file

Since our tool isn't exposing all possible settings for Tor, as a convenience escape hatch (for now?) provide a dotnet tor config command that should open VS Code (or "notepad.exe" on Windows, "nano" elsewhere) with the torrc file for tweaking.

If only .NET5 SDK is installed, tool fails to run

On a Pi, for example:

It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
  - The following frameworks were found:
      5.0.6 at [/home/**/dotnet/shared/Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=arm64&rid=debian.10-arm64

Failure to locate torrc under Ubuntu

Tool 'dotnet-tor' (version '0.3.0') was successfully installed.
$ dotnet tor add echo 127.0.0.1:8080
$ dotnet tor
Unhandled exception: System.ArgumentException: Tor configuration file not found at expected location /home/kzu/.dotnet/tools/.store/dotnet-tor/0.3.0/dotnet-tor/0.3.0/tools/netcoreapp3.1/any/tor/bin/tor-linux64-10.0.15.tar/Data/Tor/torrc
   at TorCommand.RunAsync(Int32 proxy, Int32 socks, Int32 control, CancellationToken cancellation) in /_/src/dotnet-tor/TorCommand.cs:line 64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.