Permalink
Browse files

#66 set proxy host based on address Netty reports it is using

  • Loading branch information...
1 parent 31b9e4a commit 17e51a2cb192ff875d013aaa0778b98af8b7f07c Rob Fletcher committed Aug 5, 2013
@@ -26,6 +26,7 @@ import org.junit.runners.model.Statement
import static TapeMode.READ_WRITE
import static co.freeside.betamax.MatchRule.*
import static java.util.Collections.EMPTY_MAP
+import static java.util.logging.Level.SEVERE
/**
* This is the main interface to the Betamax proxy. It allows control of Betamax configuration and inserting and
* ejecting `Tape` instances. The class can also be used as a _JUnit @Rule_ allowing tests annotated with `@Betamax` to
@@ -148,6 +149,8 @@ class Recorder implements TestRule {
try {
start(tapeName, arguments)
closure()
+ } catch (Exception e) {
+ log.log SEVERE, "Caught exception starting Betamax", e
} finally {
stop()
}
@@ -30,7 +30,7 @@ public InetSocketAddress run() throws Exception {
.option(ChannelOption.SO_BACKLOG, 128)
.childOption(ChannelOption.SO_KEEPALIVE, true);
- channel = bootstrap.bind(port).sync().channel();
+ channel = bootstrap.bind("localhost", port).sync().channel();
return (InetSocketAddress) channel.localAddress();
}
@@ -56,7 +56,7 @@ class ProxyServer implements HttpInterceptor {
address = proxyServer.run()
running = true
- overrideProxySettings()
+ overrideProxySettings address
overrideSSLSettings()
}
@@ -95,13 +95,12 @@ class ProxyServer implements HttpInterceptor {
httpClient
}
- private void overrideProxySettings() {
- def proxyHost = InetAddress.localHost.hostAddress
+ private void overrideProxySettings(InetSocketAddress address) {
def nonProxyHosts = recorder.ignoreHosts as Set
if (recorder.ignoreLocalhost) {
nonProxyHosts.addAll(Network.localAddresses)
}
- proxyOverrider.activate proxyHost, port, nonProxyHosts
+ proxyOverrider.activate address.hostName, address.port, nonProxyHosts
}
private void restoreOriginalProxySettings() {

0 comments on commit 17e51a2

Please sign in to comment.