Skip to content

Commit

Permalink
Implements #16 Proxy support (with auth) feature request
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrodan committed Aug 24, 2016
1 parent 9b29e67 commit 7d7f06d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
14 changes: 12 additions & 2 deletions KeeAnywhere/StorageProviders/AmazonDrive/AmazonDriveHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using ACD = Azi.Amazon.CloudDrive;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Azi.Amazon.CloudDrive.JsonObjects;
Expand All @@ -22,10 +23,19 @@ never the real production keys.
*/

//TODO: Change API keys!!!

internal const string AmazonDriveClientId = "dummy";
internal const string AmazonDriveClientSecret = "dummy";

public static ACD.AmazonDrive GetApi()
{
var api = new ACD.AmazonDrive(AmazonDriveClientId, AmazonDriveClientSecret)
{
Proxy = ProxyTools.GetProxy()
};

return api;
}

public static async Task<AmazonNode> GetNodeByPath(this Azi.Amazon.CloudDrive.IAmazonDrive api, string path)
{
var parts = path.Split('/');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class AmazonDriveStorageConfigurator : IStorageConfigurator, IOAuth2Provi

public AmazonDriveStorageConfigurator()
{
_api = new ACD.AmazonDrive(AmazonDriveHelper.AmazonDriveClientId, AmazonDriveHelper.AmazonDriveClientSecret);
_api = AmazonDriveHelper.GetApi();
_api.OnTokenUpdate = this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public AmazonDriveStorageProvider(AccountConfiguration account)
{
if (_api == null)
{
_api = new ACD.AmazonDrive(AmazonDriveHelper.AmazonDriveClientId, AmazonDriveHelper.AmazonDriveClientSecret);
_api = AmazonDriveHelper.GetApi();
var isOk = await _api.AuthenticationByTokens(null, this.account.Secret, DateTime.Now);

if (!isOk)
Expand Down
13 changes: 10 additions & 3 deletions KeeAnywhere/StorageProviders/ProxyTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,22 @@ public static HttpClientHandler CreateHttpClientHandler()

public static void ApplyProxy(this HttpClientHandler handler)
{
var proxy = GetKeePassWebProxy();
var proxy = GetProxy();
if (proxy == null) return;

proxy.Credentials = GetKeePassProxyCredentials();

handler.UseProxy = true;
handler.Proxy = proxy;
}

public static IWebProxy GetProxy()
{
var proxy = GetKeePassWebProxy();
if (proxy == null) return null;

proxy.Credentials = GetKeePassProxyCredentials();
return proxy;
}

public static IWebProxy GetKeePassWebProxy()
{
IWebProxy proxy;
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Supported providers (in alphabetical order):

# Known noteworthy issues:
* Registering a Dropbox account on Windows 7 opens the default browser at the end of the registration process. This window/tab could be ignored/closed.
* Amazon Drive Provider does not support Proxy settings


# Building
Expand Down
Binary file modified lib/AmazonCloudDriveApi.dll
Binary file not shown.

0 comments on commit 7d7f06d

Please sign in to comment.