Skip to content

Commit

Permalink
NOnion: use tor official mirror (#13)
Browse files Browse the repository at this point in the history
Tor Github mirror has been removed [1], this commit changes the
URLs to the official GitLab.

[1] https://github.com/torproject/tor/commi/27d4ba90f6dbf0c80d518a358b9600ae789509e4
  • Loading branch information
aarani authored Mar 31, 2024
1 parent 5180574 commit f488d76
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
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

0 comments on commit f488d76

Please sign in to comment.