Giter Club home page Giter Club logo

connectionkit's People

Contributors

abizern avatar andypotion avatar dodgio avatar fjaeger avatar ghulands avatar mikeabdullah avatar mrnoodle avatar samdeane avatar swillits avatar vincent-le-normand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

connectionkit's Issues

ARC support

The readme specifies ConnectionKit supports OSX 10.6 or later, which means ARC support is possible with weak reference support provided by PLWeakCompatibility.

I'm not requesting this, I just want to ask whether you would be willing to merge it in if I do it myself.

New Folder button shouldn’t be enabled until actually connected

In doing some testing for Mike, I noticed that even while attempting to connect the New Folder button is active. If you have a slow connection, or just try a password that doesn’t work, the file browser window/sheet will sit there with a spinning progress indicator. You can then press New Folder and a second window with another spinning progress indicator comes up suggesting you can create a new folder. But of course you can’t really.

It would be much nicer if New Folder were disabled until the connection was active and there was actually somewhere to create a new folder.

NSURLErrorDomain error -1012 on Sierra?

Connecting to the same server from two different OS versions (El Cap and Sierra), I get different results. It works on El Cap but on Sierra I keep getting this error.

This is connecting via SFTP using public key. Testing against a webdav server seems fine on both OSes. I suspect something changed in authentication on Sierra.

License Details?

Please could someone direct me to wherever ConnectionKit's license is available?

Support for FTP using SSL in Swift 3?

Hey,

Does your package support FTP using SSL? I want to use it in Swift 3.

It would be very helpful if you can let me know how to use it.

Regards,
Shorabh

Down/Upload and a Crash in Release Build

Sorry for my maybe stupid question, but I don't understand this Framework really well :/

I need to Download a file from STFP.
Which method must I use?

And I need to Upload a file to SFTP.
Which method must I use here?

And for booth things I need to have something like a progress, to show the up/download progress for user.

And there is something strange when I click in Xcode on Product->Archive->Distribute->Export As Application. I export the Application to Desktop. When I'm trying to open the App, it fails.

I click on Report and become this message:

Crashed Thread: 0

Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
Library not loaded: @rpath/ConnectionKit.framework/Versions/A/ConnectionKit
Referenced from: /Users/USER/Desktop/AppName.app/Contents/MacOS/AppName
Reason: image not found

In Debug Mode (cmd+r in xcode) the App start running without problem.

Add cocoapod

Would be fabulous to see this as a cocoapod so I don't need to include this manually into my project :)

FTP URLs with usernames with an @ in the string

On some of my servers, usernames have an '@' in the field; this is causing problems with a recent merge I just made with Connection Kit. Only problem is, I can't find where the problem originates. All I know is that FTP URLs now include the username in the URL. I guess this could be fixed by encoding any special characters, but I can't even find where the URL is being altered.

Dependencies?

It would be very helpful for me if there was even a short note about dependencies, particularly:

What is required
Where it may be acquired
Tips on incorporating dependencies with ConnectionKit

Define a clear software license

Currently, the type of licenses related to these libraries are not clearly defined; otherwise they are useless for most cases for obvious copyright reasons.

Can you determine whether these libraries are under copyrights or copyleft (GNU GPL, ...)

Thank you

Removal of file via SFTP throws error

Bugfix:

--- ConnectionKit/CK2SFTPProtocol.m
+++ ConnectionKit/CK2SFTPProtocol.m
@@ -148,7 +148,11 @@
                                           // TODO - it would be better if either we could work out ahead of time whether it's a file or folder we're deleting, or failing that, if the deletion retrying happened at the CKFileManager level instead.
                                           error = nil;
                                           break;
-
+                                          
+                                      case LIBSSH2_FX_OK:
+                                          error = nil;
+                                          break;
+                                          
                                       default:
                                           // our default for other failures is generic
                                           error = [self standardCouldntWriteErrorWithUnderlyingError:error];

No documentation

There is no documentation for this framework. How is one supposed to know how to use it?

Nevermind

Finally found how to use the framework...

Authentication

I realised that a stupid typo on my part meant that ConnectionKit 2 up until now has not actually been checking SSH host keys. This is a bit of a security weakness, as it makes it a little (maybe a lot?) easier for someone to impersonate a server and perform a man-in-the-middle attack.

I've fixed that in 96b559b. For clients this might be a surprise as they'll now receive an extra authentication callback.

Additionally, I'm considering modernising the auth callback to match NSURLSession's approach. Something like this:

- (void)fileManager:(CK2FileManager *)manager didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler;
- (void)fileManager:(CK2FileManager *)manager operation:(id)op didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler;

That would make CK's implementation a little easier, and going forward should be the API that people come to expect, thanks to NSURLSession. Would that be OK by you, @MrNoodle ? Anybody else drastically affected?

Private Key Authentication

I don't get private key authentication to work with ConnectionKit. Could you give some more information on how to use it? Everything else is working fantastically.

Is there a special authentication method like CK2AuthenticationMethodPrivateKey or similar? Currently, I am simply responding to NSURLAuthenticationMethodHTTPBasic and NSURLAuthenticationMethodHTTPDigest with a [NSURLCredential ck2_credentialWithUser...] if the user provides a private key file, but this does not seem to work :-(

Any kind of help is highly appreciated.

High CPU Load When Using ConnectionKit

When using contentsOfDirectoryAtURL: or createFileAtURL:, for example, I notice that my app's cpu load spikes to around 120%, whereas it will idle at a fraction of that amount before I use ConnectionKit.

Once the operation is complete (finished uploading a file, getting the contents of a directory, etc), the CPU usage remains at the high level.

I'm also struggling to track down the actual cause within ConnectionKit, though I have narrowed it to that. Creating a new project that only contains the minimum to get the contents of a directory still cause the spike at roughly the same %.

If you need more info, I'd be happy to supply it.

Path for V1.2.3 to support 64bit also added some comment about

Added comments to about DropletLauncher and configuration.ckhost files.
changed int to NSInteger / NSUIntegers for bette support of 64bit.
Added some case to remove warnings.

diff ../karelia-ConnectionKit-21b2243/CKAbstractQueueConnection.m ../karelia-ConnectionKit-64bit/CKAbstractQueueConnection.m
204c204

< - (void)setState:(int)aState // Safe "setter" -- do NOT just change raw variable. Called by EITHER thread.

  • (void)setState:(CKConnectionState)aState // Safe "setter" -- do NOT just change raw variable. Called by EITHER thread.
    diff ../karelia-ConnectionKit-21b2243/CKBookmarkStorage.m ../karelia-ConnectionKit-64bit/CKBookmarkStorage.m
    653c653
    < - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item

  • (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
    688c688
    < - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item

  • (id)outlineView:(NSOutlineView )outlineView child:(NSInteger)index ofItem:(id)item
    882c882
    < - (BOOL)outlineView:(NSOutlineView
    )outlineView acceptDrop:(id )info item:(id)item childIndex:(int)index

  • (BOOL)outlineView:(NSOutlineView*)outlineView acceptDrop:(id )info item:(id)item childIndex:(NSInteger)index
    914c914
    < unsigned currentIndex = NSNotFound;

    NSUInteger currentIndex = NSNotFound;
    diff ../karelia-ConnectionKit-21b2243/CKCollectionBasedBookmarkController.m ../karelia-ConnectionKit-64bit/CKCollectionBasedBookmarkController.m
    51c51
    < - (int)numberOfRowsInTableView:(NSTableView *)aTableView

  • (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
    69c69
    < - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item

  • (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
    diff ../karelia-ConnectionKit-21b2243/CKDirectoryNode.m ../karelia-ConnectionKit-64bit/CKDirectoryNode.m
    203c203
    < int CKDirectoryContentsSort(id obj1, id obj2, void *context)

    NSInteger CKDirectoryContentsSort(id obj1, id obj2, void *context)
    diff ../karelia-ConnectionKit-21b2243/CKDirectoryTreeController.m ../karelia-ConnectionKit-64bit/CKDirectoryTreeController.m
    1342c1342
    < - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item

  • (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
    1344c1344
    < int result = 0;

    NSInteger result = 0;
    1368c1368
    < - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item

  • (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
    diff ../karelia-ConnectionKit-21b2243/CKSFTPTServer.m ../karelia-ConnectionKit-64bit/CKSFTPTServer.m
    301c301,302
    < if (![directoryListingBufferString rangeOfString:@"Can't ls"].location != NSNotFound)

      NSRange r = [directoryListingBufferString rangeOfString:@"Can't ls"];
      if (r.location != NSNotFound)
    

    diff ../karelia-ConnectionKit-21b2243/CKStreamBasedConnection.m ../karelia-ConnectionKit-64bit/CKStreamBasedConnection.m
    229c229
    < return [NSString stringWithCString:addr];

    return [NSString stringWithCString:addr encoding:NSUTF8StringEncoding];
    diff ../karelia-ConnectionKit-21b2243/CKTableBasedBrowser.h ../karelia-ConnectionKit-64bit/CKTableBasedBrowser.h
    152,153c152,153
    < - (id)itemAtColumn:(unsigned)column row:(unsigned)row;
    < - (void)column:(unsigned *)column row:(unsigned *)row forItem:(id)item;

  • (id)itemAtColumn:(NSUInteger)column row:(NSUInteger)row;
  • (void)column:(NSUInteger *)column row:(NSUInteger *)row forItem:(id)item;
    diff ../karelia-ConnectionKit-21b2243/CKTableBasedBrowser.m ../karelia-ConnectionKit-64bit/CKTableBasedBrowser.m
    78c78
    < - (unsigned)rowForItem:(id)item;

  • (NSInteger)rowForItem:(id)item;
    490c490
    < unsigned row, col;

        NSUInteger row, col;
    

    727c727
    < unsigned column = NSNotFound;

    NSUInteger column = NSNotFound;
    731c731
    < unsigned i, c = [myColumns count];

    NSUInteger i, c = [myColumns count];
    955c955
    < unsigned column = [self columnToItem:item];

    NSUInteger column = [self columnToItem:item];
    969c969
    < - (id)itemAtColumn:(unsigned)column row:(unsigned)row

  • (id)itemAtColumn:(NSUInteger)column row:(NSUInteger)row
    999c999
    < - (unsigned)rowForItem:(id)item

  • (NSInteger)rowForItem:(id)item
    1013c1013
    < - (void)column:(unsigned *)column row:(unsigned *)row forItem:(id)item

  • (void)column:(NSUInteger *)column row:(NSUInteger *)row forItem:(id)item
    1129,1130c1129,1130
    < int column = [self columnWithTable:sender];
    < int row = [sender selectedRow];

    NSInteger column = [self columnWithTable:sender];
    NSInteger row = [sender selectedRow];
    1292c1292
    < - (int)numberOfRowsInTableView:(NSTableView *)aTableView

  • (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
    1302c1302
    < - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex

  • (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
    diff ../karelia-ConnectionKit-21b2243/CKTransferController.h ../karelia-ConnectionKit-64bit/CKTransferController.h
    168c168
    < - (BOOL)problemsTransferringCountingErrors:(int *)outErrors successes:(int *)outSuccesses;

  • (BOOL)problemsTransferringCountingErrors:(NSInteger *)outErrors successes:(NSInteger *)outSuccesses;
    diff ../karelia-ConnectionKit-21b2243/CKTransferController.m ../karelia-ConnectionKit-64bit/CKTransferController.m
    482c482
    < BOOL showing = [sender state] == NSOnState;

    BOOL showing = ([(NSCell *) sender state] == NSOnState);
    694c694
    < - (BOOL)problemsTransferringCountingErrors:(int *)outErrors successes:(int *)outSuccesses;

  • (BOOL)problemsTransferringCountingErrors:(NSInteger *)outErrors successes:(NSInteger *)outSuccesses;
    880c880
    < - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item

  • (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
    889c889
    < - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item

  • (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
    1000,1001c1000,1001
    < int countErrorUploads = 0;
    < int countSuccessUploads = 0;

      NSInteger countErrorUploads = 0;
      NSInteger countSuccessUploads = 0;
    

    diff ../karelia-ConnectionKit-21b2243/CKTransferRecord.h ../karelia-ConnectionKit-64bit/CKTransferRecord.h
    114c114
    < - (BOOL)problemsTransferringCountingErrors:(int *)outErrors successes:(int *)outSuccesses;

  • (BOOL)problemsTransferringCountingErrors:(NSInteger *)outErrors successes:(NSInteger *)outSuccesses;
    Common subdirectories: ../karelia-ConnectionKit-21b2243/Connection.xcodeproj and ../karelia-ConnectionKit-64bit/Connection.xcodeproj
    diff ../karelia-ConnectionKit-21b2243/DropletController.m ../karelia-ConnectionKit-64bit/DropletController.m
    0a1,3
    // command line arg 1 = configuration file path (with CKHost *myHost - NSKeyedArchiver),
    // arg 2... n = files to upload.

33a37

51a56

64a70
// CKHost *myHost - NSKeyedUnarchiver
141c147

< NSSize newSize = [sender state] == NSOnState ? sFilesExpandedSize : sFilesCollapsedSize;

NSSize newSize = ([(NSCell *)sender state] == NSOnState) ? sFilesExpandedSize : sFilesCollapsedSize;
148c154

< [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[sender state] == NSOnState]

[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[(NSCell *)sender state] == NSOnState]
332c338

< - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item

  • (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
    346c352
    < - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item

  • (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
    diff ../karelia-ConnectionKit-21b2243/DropletLauncher.m ../karelia-ConnectionKit-64bit/DropletLauncher.m
    7a8,27

// Info.plist key: CKApplication = creator where framework is.
// In resource of droplet is a Configuration file for location of upload: configuration.ckhost
// format of the file is: NSKeyedArchiver of CKHost myHost.
/

CKHost keys:

[coder encodeInt:[CKHost version] forKey:@"version"];
[coder encodeObject:_UUID forKey:@"uuid"];
[coder encodeObject:_host forKey:@"host"];
[coder encodeObject:_port forKey:@"port"];
[coder encodeObject:_username forKey:@"username"];
[coder encodeObject:_connectionType forKey:@"type"];
[coder encodeObject:_description forKey:@"description"];
[coder encodeObject:_initialPath forKey:@"initialPath"];
if (_icon)
[coder encodeObject:[_icon TIFFRepresentation] forKey:@"icon"];
[coder encodeObject:_properties forKey:@"properties"];

*/
38a59
NSString *path = nil;
41,44c62,68
< NSString *dyldPath = [[applicationPath stringByAppendingPathComponent:@"Contents"] stringByAppendingPathComponent:@"Frameworks"];
< NSString *ckFrameworkPath = [[dyldPath stringByAppendingPathComponent:@"Connection"] stringByAppendingPathExtension:@"framework"];
< NSString *dropletPath = [[NSBundle bundleWithPath:ckFrameworkPath] pathForResource:@"DropletHelper" ofType:@"app"];

< NSString *path = [[NSBundle bundleWithPath:dropletPath] executablePath];

if (applicationPath == nil) NSLog(@"error missing application with creator %@", dropletCreator);
else {
NSString *dyldPath = [[applicationPath stringByAppendingPathComponent:@"Contents"] stringByAppendingPathComponent:@"Frameworks"];
NSString *ckFrameworkPath = [[dyldPath stringByAppendingPathComponent:@"Connection"] stringByAppendingPathExtension:@"framework"];
NSString *dropletPath = [[NSBundle bundleWithPath:ckFrameworkPath] pathForResource:@"DropletHelper" ofType:@"app"];
path = [[NSBundle bundleWithPath:dropletPath] executablePath];
}
60c84

< [args addObjectsFromArray:files];

[args addObjectsFromArray:files]; // add files to upload
diff ../karelia-ConnectionKit-21b2243/EMKeychainItem.m ../karelia-ConnectionKit-64bit/EMKeychainItem.m
246c246

< attributes[0].data = (void *)newProtocol;

attributes[0].data = (void *)&newProtocol;
Common subdirectories: ../karelia-ConnectionKit-21b2243/Example and ../karelia-ConnectionKit-64bit/Example
diff ../karelia-ConnectionKit-21b2243/KTLog.m ../karelia-ConnectionKit-64bit/KTLog.m
262c262

< NSString *filename = [NSString stringWithCString:file];

NSString *filename = [NSString stringWithCString:file encoding:NSUTF8StringEncoding];
484c484

< - (int)numberOfRowsInTableView:(NSTableView *)aTableView

  • (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
    489c489
    < - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex

  • (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
    503c503
    < - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex

  • (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
    diff ../karelia-ConnectionKit-21b2243/NSFileManager+Connection.m ../karelia-ConnectionKit-64bit/NSFileManager+Connection.m
    44c44
    < int filenameSort(id obj1, id obj2, void *context)

    NSInteger filenameSort(id obj1, id obj2, void *context)
    222c222
    < int lastDateColumnIndex = [words indexOfObject:lastColumnStringOfDate];

    NSInteger lastDateColumnIndex = [words indexOfObject:lastColumnStringOfDate];
    diff ../karelia-ConnectionKit-21b2243/NSString+Connection.m ../karelia-ConnectionKit-64bit/NSString+Connection.m
    33c33
    <

    #include <openssl/md5.h>
    177c177,178
    < unsigned char *digest = (unsigned char *)MD5([toHash bytes], [toHash length], NULL);

    CC_LONG hashSize = [toHash length];
    unsigned char *digest = (unsigned char *)MD5([toHash bytes], hashSize, NULL);
    diff ../karelia-ConnectionKit-21b2243/UKKQueue.m ../karelia-ConnectionKit-64bit/UKKQueue.m
    272c272
    < int index = 0;

    NSInteger index = 0;

Use 100 (Continue) for WebDAV connections when server supports it

Apple tell me this is supported by NSURLConnection since at least OS X 10.7:

set the "Expect" header to "100-continue"

This needs to be implemented in DAVKit, but I've had to file an issue here since GitHub only supports issues on the root repository it seems.

Possible API changes

Here is a list of API changes floating round my head that could be made before we declare 2.0 final:

Delegate lifecycle

Presently CK2FileManager references its delegate weakly. The number one issue to my mind is that changing is a messy business, and something clients almost certainly shouldn't be doing. We could turn the system round so that delegate is a strong reference and specified at initialisation. The client is then responsible for shutting the manager down in order to release the delegate.

Also gives a chance for the client to specify a queue for delivering delegate messages on.

Configuration

Clients would probably like to control things like timeouts for operations. Again like the delegate, awkward questions arise if such settings can be changed mid-lifecycle. It would be neat to provide this info upfront, but doing so can easily result in a ridiculously large init… method.

One option is to have CK2Configuration class which encapsulates all these details.

Another idea that springs to mind is the concept of a prototypeRequest. The client would provide a URL request configured to its liking that all operations would be derived from. There does seem a little impedance mismatch here. e.g. upload data and many HTTP headers would have to be ignored.

Task/Operation API

Presently ConnectionKit exposes the concept of an operation purely as an id. We could make this a public class with its own API for cancelling etc. CK2Task is nicely terse. CK2Operation is pretty good too, but I think subtly carries the expectation it be a subclass of NSOperation. Of course, perhaps it should be just such a subclass!

Include Task/Operation in delegate methods

Delegate methods could pass in a reference to the task/operation which they relate to, allowing the delegate to make an educated decision if multiple operations are in flight. The trick there is a subtle race condition exists whereby a delegate message could arrive before the client has had a chance to store a reference to the task/operation, leaving it unsure how to handle it.

A simple solution to that is to make the client explicitly start each operation itself. Something like:

CK2Operation *op = [fileManager createFileAtURL:…
[self addUploadOperation:op];
[op start];

If the client doesn't care about referencing the op, it can do:

[[fileManager createFileAtURL:…] start];

Would that be more confusing for clients? Perhaps the APIs ought to be renamed to reflect that they're creating a task/operation object, rather than acting immediately.

Another solution would be to ask that clients manage some form of synchronisation around calling the file manager to avoid such races. I have a nasty suspicion most wouldn't, and would only se the race condition happen sporadically once out in the wild. Hmmmm.

Oh, one other advantage of having clients explicitly start operations/tasks is that they could easily hand off to some form of queuing mechanism to manage that.

Move a little more in favour of delegate methods over blocks

For some of the more complex operations, the current block-based system might seem a little overwhelming. It might be better to shift back some control work to being done in delegate methods. This would require something as described in the previous section.

In particular uploads are an interesting problem since to handle arbitrary schemes requires handling/notification of three things:

  • Upload progress
  • Providence of a fresh stream
  • Completion

Having three blocks passed to a method seems pretty damn unwieldy to me (I still find two to be awkward!)

Dual authentication delegate methods

CK2FileManager could make the distinction in its delegate methods between authenticating an individual operation, and a connection. This might be too confusing for clients though, I wonder. Technically I guess FTP and SFTP work purely by authenticating a connection.

Asynchronous delegation methods

It might be nice to standardise on a model where the delegate is free to take as long as it wants responding to a message, signalling it is ready to continue by calling a block provided by the manager.

NSURLAuthenticationChallenge already encapsulates a means of doing this in a pre-blocks world. Might be nice to generalise the principle.

Session

Originally, the main class in ConnectionKit was CK2Session which tended to confuse people in practice into thinking it represented a single connection. With upcoming Apple APIs, that may be less confusing. If we renamed it CK2FileSession that would produce delegate methods which carry less risk of conflicting with Apple's own ones in future. This is a pretty big change to make though!

Receiving URL of form https://@dav.box.com/dav

Possibly related to #75.

In this case, the username is a full email address so it has an @ in it. Oddly, I created an account on the same server (which also is a full email address) as this user and it works fine for me. It seems that sometimes the user is disappearing from the URL though I can't figure out a pattern for it. It happens consistently for this user but not for me.

Concurrent transfers

Is there any way of making transfers concurrent? I'm using an NSOperationQueue on my end, and files can be created concurrently, but transferring files is done one at a time.

If it's not done, is it possible or impossible to implement?

-[CK2OpenPanelController pathControlItemSelected:] exception

We're receiving a number of exception reports like so:

           Name : NSInvalidArgumentException
          Reason : *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]
    Stack Trace : 0 CoreFoundation 0x00007fff8a2c241c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff836e5e75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8a2c1fc9 -[NSException raise] + 9
3 ExceptionHandling 0x00007fff84627b12 NSExceptionHandlerExceptionRaiser + 208
4 libobjc.A.dylib 0x00007fff836e5e75 objc_exception_throw + 43
5 CoreFoundation 0x00007fff8a17add6 -[__NSPlaceholderArray initWithObjects:count:] + 358
6 CoreFoundation 0x00007fff8a1de840 +[NSArray arrayWithObjects:count:] + 48
7 ConnectionKitUI 0x00000001005666d3 -[CK2OpenPanelController pathControlItemSelected:] + 144
8 AppKit 0x00007fff81d603d0 -[NSApplication sendAction:to:from:] + 327

@MrNoodle have you seen anything like this or have a good idea how to fix it?

Failed to git submodule update --recursive --init

mimac1:ConnectionKit imariettaone$ git submodule update --recursive --init
Submodule 'CurlHandle' (https://github.com/karelia/CurlHandle.git) registered for path 'CurlHandle'
Submodule 'DAVKit' (https://github.com/karelia/DAVKit.git) registered for path 'DAVKit'
Cloning into 'CurlHandle'...
remote: Counting objects: 3721, done.
remote: Compressing objects: 100% (1064/1064), done.
remote: Total 3721 (delta 2574), reused 3644 (delta 2506)
Receiving objects: 100% (3721/3721), 16.96 MiB | 29 KiB/s, done.
Resolving deltas: 100% (2574/2574), done.
Submodule path 'CurlHandle': checked out 'f1f058668854925949dbb3f0690dd78f7b1cea2c'
Submodule 'CURLHandleSource/Tests/MockServer' ([email protected]:karelia/MockServer.git) registered for path 'CURLHandleSource/Tests/MockServer'
Submodule 'SFTP' (https://github.com/karelia/libssh2_sftp-Cocoa-wrapper.git) registered for path 'SFTP'
Submodule 'c-ares' (git://github.com/bagder/c-ares.git) registered for path 'c-ares'
Submodule 'curl' (git://github.com/karelia/curl.git) registered for path 'curl'
Cloning into 'CURLHandleSource/Tests/MockServer'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Clone of '[email protected]:karelia/MockServer.git' into submodule path 'CURLHandleSource/Tests/MockServer' failed
Cloning into 'DAVKit'...
remote: Counting objects: 819, done.
remote: Compressing objects: 100% (389/389), done.
remote: Total 819 (delta 475), reused 746 (delta 410)
Receiving objects: 100% (819/819), 136.38 KiB | 28 KiB/s, done.
Resolving deltas: 100% (475/475), done.
Submodule path 'DAVKit': checked out 'a81c734a20a62caef797663da610cb0cf2bb2ad2'
Submodule 'Tests/MockServer' ([email protected]:karelia/MockServer.git) registered for path 'Tests/MockServer'
Submodule 'Tests/OCUnit2JUnit' (https://github.com/ciryon/OCUnit2JUnit) registered for path 'Tests/OCUnit2JUnit'
Submodule 'iso-8601-date-formatter' (https://github.com/boredzo/iso-8601-date-formatter.git) registered for path 'iso-8601-date-formatter'
Cloning into 'Tests/MockServer'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Clone of '[email protected]:karelia/MockServer.git' into submodule path 'Tests/MockServer' failed
Failed to recurse into submodule path 'CurlHandle'
Failed to recurse into submodule path 'DAVKit'

Invalid parameter not satisfying: multi

I pulled the most recent version of ConnectionKit and when I try reading the contents of a directory now, it'll give me the following error:

2013-06-21 18:39:45.290 Orbitink[41117:1803] *** Assertion failure in -[CURLTransfer initWithRequest:credential:delegate:delegateQueue:multi:], /Users/imariettaone/Desktop/Obj-C/Orbitink/ConnectionKit/CurlHandle/CURLHandleSource/CURLTransfer.m:182
2013-06-21 18:39:45.291 Orbitink[41117:1803] An uncaught exception was raised
2013-06-21 18:39:45.291 Orbitink[41117:1803] Invalid parameter not satisfying: multi
2013-06-21 18:39:45.292 Orbitink[41117:1803] (
    0   CoreFoundation                      0x00007fff8e311b06 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff8c7723f0 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8e311948 +[NSException raise:format:arguments:] + 104
    3   Foundation                          0x00007fff8f97fc82 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
    4   CURLHandle                          0x000000010010e77a -[CURLTransfer initWithRequest:credential:delegate:delegateQueue:multi:] + 250
    5   Connection                          0x00000001000cfa92 -[CK2CURLBasedProtocol startWithCredential:] + 338
    6   Connection                          0x00000001000d0a70 -[CK2CURLBasedProtocol useCredential:forAuthenticationChallenge:] + 144
    7   Connection                          0x00000001000d4dc7 __81-[CK2AuthenticationChallengeTrampoline useCredential:forAuthenticationChallenge:]_block_invoke + 87
    8   libdispatch.dylib                   0x00007fff9121cf01 _dispatch_call_block_and_release + 15
    9   libdispatch.dylib                   0x00007fff912190b6 _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x00007fff9121a47f _dispatch_queue_drain + 235
    11  libdispatch.dylib                   0x00007fff9121a2f1 _dispatch_queue_invoke + 52
    12  libdispatch.dylib                   0x00007fff9121a1c3 _dispatch_worker_thread2 + 249
    13  libsystem_c.dylib                   0x00007fff8f124d0b _pthread_wqthread + 404
    14  libsystem_c.dylib                   0x00007fff8f10f1d1 start_wqthread + 13
)
2013-06-21 18:39:45.292 Orbitink[41117:1803] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: multi'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff8e311b06 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff8c7723f0 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8e311948 +[NSException raise:format:arguments:] + 104
    3   Foundation                          0x00007fff8f97fc82 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
    4   CURLHandle                          0x000000010010e77a -[CURLTransfer initWithRequest:credential:delegate:delegateQueue:multi:] + 250
    5   Connection                          0x00000001000cfa92 -[CK2CURLBasedProtocol startWithCredential:] + 338
    6   Connection                          0x00000001000d0a70 -[CK2CURLBasedProtocol useCredential:forAuthenticationChallenge:] + 144
    7   Connection                          0x00000001000d4dc7 __81-[CK2AuthenticationChallengeTrampoline useCredential:forAuthenticationChallenge:]_block_invoke + 87
    8   libdispatch.dylib                   0x00007fff9121cf01 _dispatch_call_block_and_release + 15
    9   libdispatch.dylib                   0x00007fff912190b6 _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x00007fff9121a47f _dispatch_queue_drain + 235
    11  libdispatch.dylib                   0x00007fff9121a2f1 _dispatch_queue_invoke + 52
    12  libdispatch.dylib                   0x00007fff9121a1c3 _dispatch_worker_thread2 + 249
    13  libsystem_c.dylib                   0x00007fff8f124d0b _pthread_wqthread + 404
    14  libsystem_c.dylib                   0x00007fff8f10f1d1 start_wqthread + 13
)
libc++abi.dylib: terminate called throwing an exception
(lldb) 

Is this something I can track down in my code or is this framework related?

private ssh key authentication on sftp

Hi I'm using ConnectionKit for an OSX App. The App should be a simple file uploader, because in our company there is every time a big workaround to upload stuff on server.

The authentication on server is working with private/public ssh keys.
It's a SFTP Server.

To test ConnectionKit I was trying to make a connection with it.

-(void)listDirectoryAtPath:(NSString *)path
 {
 // path is here: @"download"
   NSURL *ftpServer = [NSURL URLWithString:@"sftp://companyname.eu"];
   NSURL *directory = [CK2FileManager URLWithPath:path relativeToURL:ftpServer];

   CK2FileManager *fileManager = [[CK2FileManager alloc] init];
   fileManager.delegate = self;

   [fileManager contentsOfDirectoryAtURL:directory
              includingPropertiesForKeys:nil
                                 options:NSDirectoryEnumerationSkipsHiddenFiles
                       completionHandler:^(NSArray *contents, NSError *error) {

                           if (!error) {
                               NSLog(@"%@", contents);
                           } else {
                               NSLog(@"ERROR: %@", error.localizedDescription);
                           }

                           // Display contents in your UI, or present the error if failed
                       }];
}

and the delegate looks like:

-(void)fileManager:(CK2FileManager *)manager operation:(CK2FileOperation *)operation
didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
completionHandler:(void (^)(CK2AuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
{
    NSURLCredential * C = [NSURLCredential ck2_credentialWithUser:@"<username>"
                                                     publicKeyURL:nil
                                                    privateKeyURL:[NSURL URLWithString:@"/Users/<myUserNameOnLocalMachine>/.ssh/id_rsa"]
                                                         password:nil
                                                      persistence:NSURLCredentialPersistenceForSession];
    [[challenge sender] useCredential:C forAuthenticationChallenge:challenge];
}

For me it doesn't work and I'm asking me why?
Can anyone help me?

App is compiling for 64bit, OS X 10.9.1

Open Panel error-handling

Having a fresh play here with CK2OpenPanel, I'm a bit worried about error-handling.

In my code, I call -setDirectoryURL:completionHandler: and show the panel. If the completion handler reports a failure, I camel the panel, and present the error in its place. That handles the common case.

But what about errors mid-browsing? Say, the user's internet connection goes down. I see no feedback mechanism for the open panel to report that to its delegate at present. In such circumstances, I can think of a few approaches that could be taken:

  1. Quietly fail loading and go back to the previously visible directory
  2. Close the panel and have client deal with the error as they see fit
  3. Present the error above the panel in some fashion; acknowledging the error cancels the panel
  4. Present the error above the panel in some fashion; acknowledging returns the panel to its previous directory

In both 3 and 4 above, could potentially include a "Retry" button to the user to help them cope with temporary issues.

Presently, I think we take option 1 which is probably the worst of the bunch. Can we do better?

Support commands with responses

I see in the CurlHandle delegate there's a didReceiveResponse method - are there plans to leverage this for commands that take responses? For example, the "SYST" command on an FTP server.

Server denied you to change to the given directory - withIntermediateDirectories:YES

I'm using the this code to generate & upload a test file:

[_fileManager createFileAtURL:[self rootURLWithFile:@"hw.html"] contents:[@"<h1>Hello World!</h1>" dataUsingEncoding:NSUTF8StringEncoding] withIntermediateDirectories:YES openingAttributes:nil progressBlock:nil completionHandler:^(NSError *error)
{
    BOOL success = (error == nil) ? YES : NO;
    [_delegate uploader:self testFileWritten:success atPath:[_url stringByAppendingPathComponent:@"hw.html"]];
}];

The same error is given on 2 different FTP servers:

2013-05-09 00:17:38.556 Orbitink[1369:1217] ERR Error Domain=se.haxx.curl.libcurl.CURLcode Code=9 "Server denied you to change to the given directory" UserInfo=0x1004bd750 {NSLocalizedDescription=Server denied you to change to the given directory, NSErrorFailingURLStringKey=ftp://192.168.100.178:21/../orbitink/blog/, NSErrorFailingURLKey=ftp://192.168.100.178:21/../orbitink/blog/, 2097154=550, NSLocalizedFailureReason=Access denied to remote resource}

If I create the blog directory with another FTP Client, the upload will succeed. Any suggestions on how I could approach a fix?

Thanks

URLs with foreign characters

If I try and rename a file or folder on an FTP server with a foreign character, the percent encoding fails. Instead of what I expect, I get a URL with a percent encoding that is totally different.

The code is in CK2CURLBasedProtocol, at line:

NSURL *aURL = [directoryURL URLByAppendingPathComponent:name isDirectory:isDirectory];

Try it with name containing the Ğ character, for example.

EDIT: I'm running a build that's maybe 2 weeks old - it looks like the above line was changed because <10.7 doesn't support that method.

Support for renaming items

Some sort of -moveItemAtURL:toURL:completionHandler: method.

For WebDAV, I have no idea if DAVKit already supports this. If not, we'll have to do it ourselves following the spec: http://www.ietf.org/rfc/rfc4918.txt . Either way, make sure to supply Overwrite: F to match the Finder's behaviour.

Failed to git submodule update --recursive --init (again)

I have trouble getting all the submodules. I have seen ticket #40, which is similar, but for the libssh2 and openssl submodules. Here is what I get:

[19:12] ConnectionKit > git submodule update --recursive --init
Submodule 'CurlHandle' (https://github.com/karelia/CurlHandle.git) registered for path 'CurlHandle'
Submodule 'DAVKit' (https://github.com/karelia/DAVKit.git) registered for path 'DAVKit'
Cloning into 'CurlHandle'...
remote: Counting objects: 4225, done.
remote: Compressing objects: 100% (1201/1201), done.
remote: Total 4225 (delta 2932), reused 4141 (delta 2858)
Receiving objects: 100% (4225/4225), 19.53 MiB | 231 KiB/s, done.
Resolving deltas: 100% (2932/2932), done.
Submodule path 'CurlHandle': checked out '5f8e07c03878437ffa69479dfaf7c58851309638'
Submodule 'CURLHandleSource/Tests/MockServer' (https://github.com/karelia/MockServer.git) registered for path 'CURLHandleSource/Tests/MockServer'
Submodule 'SFTP' (https://github.com/karelia/libssh2_sftp-Cocoa-wrapper.git) registered for path 'SFTP'
Submodule 'c-ares' (https://github.com/bagder/c-ares.git) registered for path 'c-ares'
Submodule 'curl' (https://github.com/karelia/curl.git) registered for path 'curl'
Cloning into 'CURLHandleSource/Tests/MockServer'...
remote: Counting objects: 1702, done.
remote: Compressing objects: 100% (685/685), done.
remote: Total 1702 (delta 927), reused 1687 (delta 913)
Receiving objects: 100% (1702/1702), 3.10 MiB | 267 KiB/s, done.
Resolving deltas: 100% (927/927), done.
Submodule path 'CURLHandleSource/Tests/MockServer': checked out '038870f1e301ee08542d117ce2c8cd612ce42c00'
Submodule 'UnitTests/OCUnit2JUnit' (https://github.com/ciryon/OCUnit2JUnit) registered for path 'UnitTests/OCUnit2JUnit'
Cloning into 'UnitTests/OCUnit2JUnit'...
remote: Counting objects: 149, done.
remote: Compressing objects: 100% (96/96), done.
remote: Total 149 (delta 52), reused 130 (delta 36)
Receiving objects: 100% (149/149), 60.18 KiB, done.
Resolving deltas: 100% (52/52), done.
Submodule path 'UnitTests/OCUnit2JUnit': checked out 'e5ea527cc036eb6227ddd7989767a889b4656be5'
Cloning into 'SFTP'...
remote: Counting objects: 10743, done.
remote: Compressing objects: 100% (3984/3984), done.
remote: Total 10743 (delta 6417), reused 10696 (delta 6381)
Receiving objects: 100% (10743/10743), 29.71 MiB | 371 KiB/s, done.
Resolving deltas: 100% (6417/6417), done.
Submodule path 'SFTP': checked out 'c628a936d45f8a2f68ad1e771035f55d0b5dd1a9'
Submodule 'libssh2' (git://git.libssh2.org/libssh2.git) registered for path 'libssh2'
Submodule 'openssl' (git://git.openssl.org/openssl.git) registered for path 'openssl'
Cloning into 'libssh2'...
fatal: unable to connect to git.libssh2.org:
git.libssh2.org[0: 212.116.89.126]: errno=Connection refused

-createFileAtURL:... with intermediate directories set to YES doesn't seem to work?

This might have broken at some point recently as I'm pretty sure it was working before. Get the following response (using WebDAV) when uploading a file with some non-existent intermediate directories. Everything up to "testsubdir" exists:

Error Domain=org.w3.http Code=404 "The operation couldn’t be completed. not found" UserInfo=0x10071a170 {NSLocalizedFailureReason=not found, response=<NSHTTPURLResponse: 0x10071a9e0> { URL: https://XXXXXXXXXXX/test/39744-uploadtest/testsubdir/testsubfile } { status code: 404, headers {
Connection = close;
"Content-Encoding" = gzip;
"Content-Length" = 20;
"Content-Type" = "text/html";
Date = "Mon, 06 Oct 2014 00:48:54 GMT";
Server = "Apache/2.2.16 (Debian)";
Vary = "Accept-Encoding";
} }}

Open panel kicks off a directory listing when being cancelled

I go through steps along these lines:

  1. Show the a connection open panel. This goes fine, directory listing comes up etc.
  2. Click the Cancel button.

This is where things are a bit odd. As you can see from the stack trace below, the act of cancelling the panel attempts to kick off a directory listing.

#0  0x00000001009205c7 in -[CK2OpenPanelController childrenForURL:] at /Users/Mike/Code/Karelia/Sandvox/Code/ConnectionKit/ConnectionKit/CK2OpenPanelController.m:637
#1  0x0000000100927f31 in -[CK2OpenPanelColumnViewController browser:numberOfChildrenOfItem:] at /Users/Mike/Code/Karelia/Sandvox/Code/ConnectionKit/ConnectionKit/CK2OpenPanelColumnViewController.m:368
#2  0x00007fff90c9aecc in -[NSTableView _uncachedNumberOfRows] ()
#3  0x00007fff90c9add3 in -[_NSTableRowHeightStorage numberOfRows] ()
#4  0x00007fff90ca1a45 in -[NSTableView _verifySelectionIsOK] ()
#5  0x00007fff90ca143e in -[NSTableView _tileAndRedisplayAll] ()
#6  0x00007fff90f1d5ad in -[_NSBrowserTableColumnViewController setView:] ()
#7  0x00007fff90f1e203 in -[NSBrowserColumnViewController setColumnView:forcingFlippedBehavior:] ()
#8  0x00007fff90f1dbca in -[_NSBrowserTableColumnViewController loadView] ()
#9  0x00007fff9102dcf7 in -[NSViewController _loadViewIfRequired] ()
#10 0x00007fff90cfef91 in -[NSViewController view] ()
#11 0x00007fff90f1d887 in -[NSBrowserColumnViewController setMenu:] ()
#12 0x00007fff90f1cf64 in -[NSBrowser addColumn] ()
#13 0x00007fff90f1c7b4 in -[NSBrowser loadColumnZero] ()
#14 0x0000000100927416 in -[CK2OpenPanelColumnViewController reload] at /Users/Mike/Code/Karelia/Sandvox/Code/ConnectionKit/ConnectionKit/CK2OpenPanelColumnViewController.m:211
#15 0x000000010091f6bf in -[CK2OpenPanelController resetSession] at /Users/Mike/Code/Karelia/Sandvox/Code/ConnectionKit/ConnectionKit/CK2OpenPanelController.m:432
#16 0x000000010091b565 in -[CK2OpenPanel endWithCode:] at /Users/Mike/Code/Karelia/Sandvox/Code/ConnectionKit/ConnectionKit/CK2OpenPanel.m:221
#17 0x000000010091b9c4 in -[CK2OpenPanel cancel:] at /Users/Mike/Code/Karelia/Sandvox/Code/ConnectionKit/ConnectionKit/CK2OpenPanel.m:266
#18 0x0000000100922066 in -[CK2OpenPanelController cancel:] at /Users/Mike/Code/Karelia/Sandvox/Code/ConnectionKit/ConnectionKit/CK2OpenPanelController.m:911
#19 0x00007fff8a062cd7 in _os_activity_initiate ()
#20 0x00007fff90e0f6d7 in -[NSApplication sendAction:to:from:] ()

This becomes somewhat of a nuisance because the directory listing needs authentication for something like FTP. The panel controller gets asked to authenticate; it sees it has no delegate any more, so asks the file manager to perform its default handling. The default handling is to have a go with whatever username and password are present in the URL, so in all likelihood fails (because there's no password there).

The end result is every time I close the open panel, one failed FTP logic attempt results. Given a little time, this could easily get the user blacklisted on some servers.

This used to much more of a problem before commit c8bd2cd as the default handling would go round in circles retrying auth forever more.

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.