Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOnion: use tor official mirror #13

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NOnion.Tests/FallbackDirectorySelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static internal IPEndPoint GetRandomFallbackDirectory()
{
if (fallbackDirectories == null)
{
var urlToTorServerList = "https://raw.githubusercontent.com/torproject/tor/main/src/app/config/fallback_dirs.inc";
var urlToTorServerList = "https://gitlab.torproject.org/tpo/core/tor/-/raw/main/src/app/config/fallback_dirs.inc";
using var webClient = new WebClient();
var fetchedInfo = webClient.DownloadString(urlToTorServerList);

Expand Down
10 changes: 5 additions & 5 deletions NOnion.Tests/HiddenServicesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void Init()

private async Task CreateIntroductionCircuit()
{
using TorClient torClient = await TorClient.BootstrapWithGithubAsync(cachePath);
using TorClient torClient = await TorClient.BootstrapWithGitlabAsync(cachePath);
var circuit = await torClient.CreateCircuitAsync(1, CircuitPurpose.Unknown, FSharpOption<CircuitNodeDetail>.None);
await circuit.RegisterAsIntroductionPointAsync(FSharpOption<AsymmetricCipherKeyPair>.None, StubCallback, DisconnectionCallback);
}
Expand All @@ -76,7 +76,7 @@ private async Task CreateRendezvousCircuit()
var array = new byte[Constants.RendezvousCookieLength];
RandomNumberGenerator.Create().GetNonZeroBytes(array);

using TorClient torClient = await TorClient.BootstrapWithGithubAsync(cachePath);
using TorClient torClient = await TorClient.BootstrapWithGitlabAsync(cachePath);
var circuit = await torClient.CreateCircuitAsync(2, CircuitPurpose.Unknown, FSharpOption<CircuitNodeDetail>.None);
await circuit.RegisterAsRendezvousPointAsync(array);
}
Expand All @@ -103,7 +103,7 @@ private async Task<int> ReadExact(TorStream stream, byte[] buffer, int off, int

public async Task BrowseFacebookOverHS()
{
using TorClient torClient = await TorClient.BootstrapWithGithubAsync(cachePath);
using TorClient torClient = await TorClient.BootstrapWithGitlabAsync(cachePath);

var serviceClient = await TorServiceClient.ConnectAsync(torClient, "facebookwkhpilnemxj7asaniu7vnjjbiltxjqhye3mhbshg7kx5tfyd.onion");
var stream = await serviceClient.GetStreamAsync();
Expand All @@ -129,7 +129,7 @@ public void CanBrowseFacebookOverHS()

public async Task BrowseFacebookOverHSWithTLS()
{
using TorClient torClient = await TorClient.BootstrapWithGithubAsync(cachePath);
using TorClient torClient = await TorClient.BootstrapWithGitlabAsync(cachePath);

var serviceClient = await TorServiceClient.ConnectAsync(torClient, "facebookwkhpilnemxj7asaniu7vnjjbiltxjqhye3mhbshg7kx5tfyd.onion:443");
var stream = await serviceClient.GetStreamAsync();
Expand Down Expand Up @@ -159,7 +159,7 @@ public void CanBrowseFacebookOverHSWithTLS()

public async Task EstablishAndCommunicateOverHSConnectionOnionStyle()
{
using TorClient torClient = await TorClient.BootstrapWithGithubAsync(cachePath);
using TorClient torClient = await TorClient.BootstrapWithGitlabAsync(cachePath);

TorLogger.Log("Finished bootstraping");

Expand Down
8 changes: 4 additions & 4 deletions NOnion.Tests/TorClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ namespace NOnion.Tests
{
public class TorClientTests
{
private async Task BootstrapWithGithub()
private async Task BootstrapWithGitlab()
{
await TorClient.BootstrapWithGithubAsync(FSharpOption<DirectoryInfo>.None);
await TorClient.BootstrapWithGitlabAsync(FSharpOption<DirectoryInfo>.None);
}

[Test]
public void CanBootstrapWithGithub()
public void CanBootstrapWithGitlab()
{
Assert.DoesNotThrowAsync(BootstrapWithGithub);
Assert.DoesNotThrowAsync(BootstrapWithGitlab);
}

private async Task BootstrapWithEmbeddedList()
Expand Down
8 changes: 4 additions & 4 deletions NOnion/Client/TorClient.fs
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,23 @@ type TorClient internal (directory: TorDirectory) =
=
TorClient.AsyncBootstrapWithEmbeddedList cachePath |> Async.StartAsTask

static member AsyncBootstrapWithGithub(cachePath: Option<DirectoryInfo>) =
static member AsyncBootstrapWithGitlab(cachePath: Option<DirectoryInfo>) =
async {
// Don't put this inside the fallbackListString or it gets disposed
// before the task gets executed
use httpClient = new HttpClient()

let! fallbackListString =
let urlToTorServerList =
"https://raw.githubusercontent.com/torproject/tor/main/src/app/config/fallback_dirs.inc"
"https://gitlab.torproject.org/tpo/core/tor/-/raw/main/src/app/config/fallback_dirs.inc"

httpClient.GetStringAsync urlToTorServerList |> Async.AwaitTask

return! CreateClientFromFallbackString fallbackListString cachePath
}

static member BootstrapWithGithubAsync(cachePath: Option<DirectoryInfo>) =
TorClient.AsyncBootstrapWithGithub cachePath |> Async.StartAsTask
static member BootstrapWithGitlabAsync(cachePath: Option<DirectoryInfo>) =
TorClient.AsyncBootstrapWithGitlab cachePath |> Async.StartAsTask

member __.Directory = directory

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Install via NuGet:
To utilize the Tor network, start by bootstrapping your directory. This step involves downloading the most recent information about available routers and their identity keys.

To initiate the bootstrapping process, you require a list of initial nodes for communication. In NOnion, there are two methods to obtain this list:
1- [Download from Github](https://github.com/torproject/tor/blob/main/src/app/config/fallback_dirs.inc)
1- [Download from GitLab](https://gitlab.torproject.org/tpo/core/tor/-/raw/main/src/app/config/fallback_dirs.inc)
2- Utilize the embedded list in the NOnion binary (Note: this list could potentially be outdated)

Based on what option you choose use one of the following commands to bootstrap a TorClient object:
Expand All @@ -41,7 +41,7 @@ let! torClient = TorClient.AsyncBootstrapWithEmbeddedList None
```
### OR
```
let! torClient = TorClient.AsyncBootstrapWithGithub None
let! torClient = TorClient.AsyncBootstrapWithGitlab None
```
## Browsing the web

Expand Down
Loading