Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FTP - Add proxy support to FTP, SFTP, and FTPS connectors #1907

Merged
merged 13 commits into from
Aug 30, 2019

Conversation

mjp426
Copy link
Contributor

@mjp426 mjp426 commented Aug 28, 2019

Purpose

Adds proxy support to FTP, SFTP, and FTPS connectors

References

References #600

Changes

  • Add withProxy method on all three FTPSettings builders that takes a java.net.Proxy object
  • Pass the proxy object to the underlying client before the connection is made
  • Added tests for the three supported protocols via a proxy
  • Added squid proxy and configuration to docker-compose so this can be tested.

Background Context

The approach is relatively straight forward. The extra option fits neatly into to existing builder pattern and passing the proxy to the client at the start of the connect operation is the natural place for it to go.

I've chosen to use a squid proxy in the testing as this is a widely used proxy.

 * Add optional proxy to the three FTPSettings case classes
 * Apply the proxy to the underlying client before connection is made
 * Add squid proxy to docker compose for testing
 * Add test classes for each of the three protocols
The hbase dependency uses an old version of hadoop-common, which in
turns uses an old version of commons-net which is getting picked up in
the unidoc task in favour of the later commons-net lib.
@probot-autolabeler probot-autolabeler bot added the dependency-change For PRs changing the version of a dependency. label Aug 29, 2019
@mjp426
Copy link
Contributor Author

mjp426 commented Aug 29, 2019

The build is now failing on the MiMa check. Could someone from the core team confirm I'm ok to add an exception for this change?

@mjp426
Copy link
Contributor Author

mjp426 commented Aug 29, 2019

Also, the unidoc task was failing because is was picking up an old version of commons-net from the hbase dependency. I've fixed it by upgrading that dependency, but perhaps there's a better way to do this?

@ennru
Copy link
Member

ennru commented Aug 29, 2019

Hi @mjp426 - Welcome to Alpakka!

Thank you for working on this, as you've seen this feature has been requested for a long while.

The Mima exclusions for the settings classes are OK to add.
The Unidoc problem should be fixed in here instead:

alpakka/build.sbt

Lines 69 to 77 in e48dd81

// unidoc combines sources and jars from all connectors and that
// might include some incompatible ones. Depending on the
// classpath order that might lead to scaladoc compilation errors.
// Therefore some versions are exlcuded here.
ScalaUnidoc / unidoc / fullClasspath := {
(ScalaUnidoc / unidoc / fullClasspath).value
.filterNot(_.data.getAbsolutePath.contains("protobuf-java-2.5.0.jar"))
.filterNot(_.data.getAbsolutePath.contains("guava-27.1-android.jar"))
},

 * Added commons-net filter to the unidoc task.
 * Revert Dependencies to origin/master
@mjp426
Copy link
Contributor Author

mjp426 commented Aug 29, 2019

Hi @ennru, thanks for the pointers. I've made the changes you suggested.

My FTP tests are passing, but there are a few failing modules. I can't reproduce the failures locally, and they seem unrelated to my changes. Do you have any tips to get the tests green?

@mjp426
Copy link
Contributor Author

mjp426 commented Aug 29, 2019

Also, I think the dependency-change flag can be removed now.

Copy link
Member

@ennru ennru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copy method shouldn't overwrite a configured proxy.
A short note in the docs ftp.md would be great.

Looks nice and simple otherwise.

)

override def toString =
s"""FtpSettings(host=$host,port=$port,credentials=$credentials,binary=$binary,passiveMode=$passiveMode,configureConnection=$configureConnection)"""
s"""FtpSettings(host=$host,port=$port,credentials=$credentials,binary=$binary,passiveMode=$passiveMode,configureConnection=$configureConnection),proxy=$proxy"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ) should move to the end. You may make this a single-" string and split it with one field per line, so this doesn't happen again.

ftp/src/main/scala/akka/stream/alpakka/ftp/model.scala Outdated Show resolved Hide resolved
)

override def toString =
s"""FtpsSettings(host=$host,port=$port,credentials=$credentials,binary=$binary,passiveMode=$passiveMode,configureConnection=$configureConnection)"""
s"""FtpsSettings(host=$host,port=$port,credentials=$credentials,binary=$binary,passiveMode=$passiveMode,configureConnection=$configureConnection),proxy=$proxy"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing with the ).

ftp/src/main/scala/akka/stream/alpakka/ftp/model.scala Outdated Show resolved Hide resolved
ftp/src/main/scala/akka/stream/alpakka/ftp/model.scala Outdated Show resolved Hide resolved
@ennru ennru removed the dependency-change For PRs changing the version of a dependency. label Aug 29, 2019
@@ -37,6 +37,8 @@ The example demonstrates optional use of `configureConnection` option available

For non-anonymous connection, please provide an instance of @scaladoc[NonAnonFtpCredentials](akka.stream.alpakka.ftp.FtpCredentials$$NonAnonFtpCredentials) instead.

For connection via a proxy, please provide an instance of `java.net.Proxy`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, there is this. Maybe refer to the withProxy method.

mjp426 and others added 5 commits August 29, 2019 16:47
@mjp426
Copy link
Contributor Author

mjp426 commented Aug 29, 2019

Good catch on the copy method. I've committed your suggestions.

Copy link
Member

@ennru ennru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ennru
Copy link
Member

ennru commented Aug 30, 2019

Failures were
#1909
#1801
#1723

@ennru ennru merged commit d4221e6 into akka:master Aug 30, 2019
@ennru
Copy link
Member

ennru commented Aug 30, 2019

Thank you! Great to see this long-standing feature request fixed.

@ennru ennru added this to the 2.0.0 milestone Aug 30, 2019
@ennru ennru mentioned this pull request Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants