SchoofsKelvin / vscode-sshfs

Extension for Visual Studio Code: File system provider using SSH
GNU General Public License v3.0
543 stars 36 forks source link

Allow specifying default port forwardings from config files #253

Closed SchoofsKelvin closed 3 years ago

SchoofsKelvin commented 3 years ago

Add some form of config fields where port forwardings can be defined beforehand, and re-started every time a connection is created.

Only design decision left is what to do when a port forwarding fails:

The config field type can reuse these existing types, for a simple one-on-one mapping: https://github.com/SchoofsKelvin/vscode-sshfs/blob/0a4c8a21a360937ce7a7c6983c6928e7e882b52b/src/portForwarding.ts#L11-L33

SchoofsKelvin commented 3 years ago

Current implementation (c217261) expects a list of strings like the following:

"forwardings": [
    // LocalForward (L / Local / LocalForward)
    "L4080 localhost:80",
    "L 10.0.0.1:4081 /tmp/some.socket",
    "L /tmp/socket google.com:443",
    // RemoteForward that actually forwards (R / Remote / RemoteForward)
    "Remote localhost:4040 80",
    "Remote localhost:4041 /tmp/some.socket",
    "Remote google.com:443 /tmp/some.socket",
    // RemoteForward in SOCKSv5 proxy mode (R / Remote / RemoteForward)
    "Remote localhost:4008",
    "Remote /tmp/some.socket",
    // DynamicForward (D / Dynamic / DynamicForward)
    "Dynamic 4004",
    "Dynamic localhost:4005",
    "Dynamic /tmp/socket"
],

At times, giving a port is sufficient if it's the origin of a connection (e.g. from in Local from to, Remote to from, Remote from and Dynamic from) which will (currently) result in it binding to localhost, which should be the loopback for both IPv4 and IPv6. In the future, a GatewayPorts (similar to ssh_config) might be added to change this default. The address can also be * in those cases, meaning that the port should be bound on all (IPv4 and IPv6) interfaces. Mind that connection targets (e.g. to in the previous examples) does require a "full destination", either being a Unix socket path (thus no port) or a full on address:port combination. Giving only a port will error.

The proxies (RemoteForward without local port/address/path and DynamicForward) use SOCKSv5. SOCKSv4 and SOCKSv4a are (for now?) not supported. The proxy has no authentication, nor does it currently give the user the option to add authentication.