Skip to content

QFJ-285 Proxy support fixes #92

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

Merged
merged 1 commit into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ private static ProxyRequest createHttpProxyRequest(InetSocketAddress address,
String proxyPassword,
String proxyDomain,
String proxyWorkstation) {
String uri = "http://" + address.getAddress().getHostAddress() + ":" + address.getPort();
HashMap<String, String> props = new HashMap<>();
props.put(HttpProxyConstants.USER_PROPERTY, proxyUser);
props.put(HttpProxyConstants.PWD_PROPERTY, proxyPassword);
Expand All @@ -169,7 +168,7 @@ private static ProxyRequest createHttpProxyRequest(InetSocketAddress address,
props.put(HttpProxyConstants.WORKSTATION_PROPERTY, proxyWorkstation);
}

HttpProxyRequest req = new HttpProxyRequest(uri);
HttpProxyRequest req = new HttpProxyRequest(address);
req.setProperties(props);
if (proxyVersion != null && proxyVersion.equalsIgnoreCase("1.1")) {
req.setHttpVersion(HttpProxyConstants.HTTP_1_1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.mina.core.service.IoConnector;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.logging.LoggingFilter;
import org.apache.mina.proxy.ProxyConnector;
import org.apache.mina.transport.socket.SocketConnector;
import org.slf4j.Logger;
Expand Down Expand Up @@ -145,7 +144,7 @@ public ConnectTask(boolean sslEnabled, SocketAddress[] socketAddresses,
private void setupIoConnector() throws ConfigError, GeneralSecurityException {
final CompositeIoFilterChainBuilder ioFilterChainBuilder = new CompositeIoFilterChainBuilder(userIoFilterChainBuilder);

boolean hasProxy = proxyType != null && proxyPort > 0 && socketAddresses[0] instanceof InetSocketAddress;
boolean hasProxy = proxyType != null && proxyPort > 0 && socketAddresses[nextSocketAddressIndex] instanceof InetSocketAddress;

SSLFilter sslFilter = null;
if (sslEnabled) {
Expand All @@ -155,14 +154,14 @@ private void setupIoConnector() throws ConfigError, GeneralSecurityException {
ioFilterChainBuilder.addLast(FIXProtocolCodecFactory.FILTER_NAME, new ProtocolCodecFilter(new FIXProtocolCodecFactory()));

IoConnector newConnector;
newConnector = ProtocolFactory.createIoConnector(socketAddresses[0]);
newConnector = ProtocolFactory.createIoConnector(socketAddresses[nextSocketAddressIndex]);
newConnector.setHandler(new InitiatorIoHandler(fixSession, networkingOptions, eventHandlingStrategy));
newConnector.setFilterChainBuilder(ioFilterChainBuilder);

if (hasProxy) {
ProxyConnector proxyConnector = ProtocolFactory.createIoProxyConnector(
(SocketConnector) newConnector,
(InetSocketAddress) socketAddresses[0],
(InetSocketAddress) socketAddresses[nextSocketAddressIndex],
new InetSocketAddress(proxyHost, proxyPort),
proxyType, proxyVersion, proxyUser, proxyPassword, proxyDomain, proxyWorkstation
);
Expand Down