lib fetcher ssh: Simplify Fetch method
This commit is contained in:
parent
48acd5ce41
commit
ce5adbe4ba
|
@ -16,11 +16,9 @@
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace SparkleLib {
|
namespace SparkleLib {
|
||||||
|
|
||||||
|
@ -33,13 +31,17 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public override bool Fetch ()
|
public override bool Fetch ()
|
||||||
{
|
{
|
||||||
if (RemoteUrl.Host.EndsWith (".onion")) {
|
|
||||||
// Tor has special domain names called ".onion addresses". They can only be
|
// Tor has special domain names called ".onion addresses". They can only be
|
||||||
// resolved by using a proxy via tor. While the rest of the openssh suite
|
// resolved by using a proxy via tor. While the rest of the openssh suite
|
||||||
// fully supports proxying, ssh-keyscan does not, so we can't use it for .onion
|
// fully supports proxying, ssh-keyscan does not, so we can't use it for .onion
|
||||||
|
if (RemoteUrl.Host.EndsWith (".onion")) {
|
||||||
SparkleLogger.LogInfo ("Auth", "using tor .onion address skipping ssh-keyscan");
|
SparkleLogger.LogInfo ("Auth", "using tor .onion address skipping ssh-keyscan");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RemoteUrl.Scheme.StartsWith ("http"))
|
||||||
|
return true;
|
||||||
|
|
||||||
} else if (!RemoteUrl.Scheme.StartsWith ("http")) {
|
|
||||||
string host_key = FetchHostKey ();
|
string host_key = FetchHostKey ();
|
||||||
|
|
||||||
if (string.IsNullOrEmpty (RemoteUrl.Host) || host_key == null) {
|
if (string.IsNullOrEmpty (RemoteUrl.Host) || host_key == null) {
|
||||||
|
@ -50,6 +52,7 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool warn = true;
|
bool warn = true;
|
||||||
|
|
||||||
if (RequiredFingerprint != null) {
|
if (RequiredFingerprint != null) {
|
||||||
string host_fingerprint;
|
string host_fingerprint;
|
||||||
|
|
||||||
|
@ -80,7 +83,6 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
AcceptHostKey (host_key, warn);
|
AcceptHostKey (host_key, warn);
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +142,10 @@ namespace SparkleLib {
|
||||||
|
|
||||||
private void AcceptHostKey (string host_key, bool warn)
|
private void AcceptHostKey (string host_key, bool warn)
|
||||||
{
|
{
|
||||||
string ssh_config_path = Path.Combine (SparkleConfig.DefaultConfig.HomePath, ".ssh");
|
// TODO: Make a proper member for this
|
||||||
|
string config_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
||||||
|
|
||||||
|
string ssh_config_path = Path.Combine (config_path, "ssh");
|
||||||
string known_hosts_file_path = Path.Combine (ssh_config_path, "known_hosts");
|
string known_hosts_file_path = Path.Combine (ssh_config_path, "known_hosts");
|
||||||
|
|
||||||
if (!File.Exists (known_hosts_file_path)) {
|
if (!File.Exists (known_hosts_file_path)) {
|
||||||
|
|
Loading…
Reference in a new issue