thephpleague / flysystem

Abstraction for local and remote filesystems

Home Page:https://flysystem.thephpleague.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for SFTP SOCKS Proxy URL?

stevenmaguire opened this issue · comments

Feature Request

Q A
Flysystem Version 3.x
Adapter Name SFTP
Adapter version 3.x

Scenario / Use-case

Is there any existing (and undocumented?) support or an appetite for supporting a SOCKS proxy connection?

Summary

Ideally something configured like this:

    new SftpConnectionProvider(
        'localhost', // host (required)
        'foo', // username (required)
        'pass', // password (optional, default: null) set to null if privateKey is used
        '/path/to/my/private_key', // private key (optional, default: null) can be used instead of password, set to null if password is set
        'my-super-secret-passphrase-for-the-private-key', // passphrase (optional, default: null), set to null if privateKey is not used or has no passphrase
        2222, // port (optional, default: 22)
        true, // use agent (optional, default: false)
        30, // timeout (optional, default: 10)
        10, // max tries (optional, default: 4)
        'fingerprint-string', // host fingerprint (optional, default: null),
        null, // connectivity checker (must be an implementation of 'League\Flysystem\PhpseclibV2\ConnectivityChecker' to check if a connection can be established (optional, omit if you don't need some special handling for setting reliable connections)
        // ADDED, OPTIONAL CONFIG
        'user:pass@host:1080', // SOCKS Proxy URL
    ),

Hi @stevenmaguire, I don't see in the PHPSecLib documentation how this would work. Unless you have a pointer or PR, I'm afraid I don't know how to resolve this issue.

@frankdejonge Thanks for the response. I also looked and came up empty handed - which is why I came through this channel. I was hoping someone else with more intimate knowledge of the problem space would have an idea!

There are some smatterings of "here's how you can do it using cURL" on Stack Overflow and elsewhere but those solutions feel very different than what is happening in this library (and in PHPSecLib underneath). So, maybe it's not a good fit or woth the effort. On the other hand, it is def an annoying problem to run up against if you're unlucky enough.

PHPSecLib does have this piece of documentation, but it's not SFTP compatible I think: https://phpseclib.com/docs/connect#using-a-socks5-proxy

You could try making your own connection provider with the logic from that snippet, and pass the $fsock into the SFTP constructor, since it's an SSH2 extension it should be compatible? Maybe?

Hi @stevenmaguire : I was curious to know if you managed something regarding this issue ? I need this as well and be very interested in the approach you had. Thanks.

@Neirda24 I have not made any progress in solving for this use case yet and it still is of interest to me. The startup effort in getting something going is a bit high because of the "let's test using real services" nature of this library. You would need to stand up a service that supports SOCKS and the testing harness for this library to begin tinkering.