Bug - Fixed Proxy Settings in r10587

Catch-22

Active member
So, while I'm in a bug reporting mood I figure I'd point out that the proxy settings in KoLmafia seem to do nothing.

java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

OS Name Microsoft Windows 7 Professional
Version 6.1.7601 Service Pack 1 Build 7601
System Type x64-based PC

On the connection tab I mark use proxy as checked, entered in the host and port of my proxy (no username/password required). When I login, I see no activity on the proxy, seems as though KoLmafia just completely ignores the proxy settings.

I don't know how long this has been broken for, because honestly I have never used it before now.

Edit: Seems to work if you have "Improve handling of semi-random lag spikes" unchecked, could be related to this bug?

Edit: Works in 10589 regardless of whether or not "Improve handling of semi-random lag spikes" is checked, but does NOT work if you have "Improve handling of semi-random lag spikes" checked and "Switch to HTTPS for login" checked, but logging in that way is currently bugged for me anyway. I figure this bug is just a side-effect of the way HTTPS logins are being handled at the moment, but it might help the devs to know that my proxy doesn't see any requests come through when HTTPS is ticked and the "semi-random lag spikes" is also checked.
 
Last edited:

Catch-22

Active member
Okay just some more info, in r10590, HTTPS login doesn't work for me at all (no matter what I have checked) if I have a proxy enabled.
 

Catch-22

Active member
r10591, proxy doesn't work at all. HTTPS login method appears to ignore the proxy completely, HTTP method says "Encountered error in login.", let me know if you'd like debug logs.
 

Winterbay

Active member
r10594: I cannot log in with any combination of "Use a proxy", "Switch to HTTPS" and "Improve lag handling"
Situation: Windows XP Pro, Java 6.23 (I think), sitting behind a corporate firewall that requires me to connect to the internet via a proxy.

The latest revision that seem to work is r10584 (i.e. before the https-stuff started) r10590 gave me a debug-log which I guess is expected given the changes afetr that.

Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
         KoLmafia v15.1 r10590, Windows XP, Java 1.6.0_23
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post this log in the KoLmafia thread. If you
 would like the dev team to look at it, please write a bug report
 at kolmafia.us. Include specific information about what you were 
 doing when you made this and include the log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Fri Feb 24 09:47:07 CET 2012
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Unexpected error, debug log printed.
class java.lang.NumberFormatException: For input string: "10.242.11.16"
java.lang.NumberFormatException: For input string: "10.242.11.16"
	at java.lang.NumberFormatException.forInputString(Unknown Source)
	at java.lang.Integer.parseInt(Unknown Source)
	at java.lang.Integer.parseInt(Unknown Source)
	at com.velocityreviews.forums.HttpTimeoutClient.getInstance(HttpTimeoutClient.java:38)
	at com.velocityreviews.forums.HttpTimeoutURLConnection.connect(HttpTimeoutURLConnection.java:36)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:1551)
	at net.sourceforge.kolmafia.request.GenericRequest.execute(GenericRequest.java:1342)
	at net.sourceforge.kolmafia.request.GenericRequest.run(GenericRequest.java:1235)
	at net.sourceforge.kolmafia.request.LoginRequest.detectChallenge(LoginRequest.java:143)
	at net.sourceforge.kolmafia.request.LoginRequest.run(LoginRequest.java:250)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:219)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:182)
	at net.sourceforge.kolmafia.swingui.LoginFrame$LoginPanel.doLogin(LoginFrame.java:347)
	at net.sourceforge.kolmafia.swingui.LoginFrame$LoginPanel.actionConfirmed(LoginFrame.java:294)
	at net.sourceforge.kolmafia.swingui.panel.GenericPanel$ConfirmedListener.execute(GenericPanel.java:604)
	at net.sourceforge.kolmafia.swingui.listener.ThreadedListener.run(ThreadedListener.java:239)
	at net.sourceforge.kolmafia.RequestThread$ThreadWrappedRunnable.run(RequestThread.java:338)
 

Winterbay

Active member
r10600M: I can now log in from behind my little proxy as long as I don't use https, which is a lot better than before at least :)
 

Winterbay

Active member
Monday and back at work, so able to test this. r10646: Can still log in fine with the https-option turned off with my proxy.
I created the following debug-log while failing to log in (with https-login set to true) but have no idea if it's in any way helpful.

Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
         KoLmafia v15.1 r10646, Windows XP, Java 1.6.0_23
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post this log in the KoLmafia thread. If you
 would like the dev team to look at it, please write a bug report
 at kolmafia.us. Include specific information about what you were 
 doing when you made this and include the log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Mon Feb 27 08:18:02 CET 2012
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Sending login request...
class net.sourceforge.kolmafia.request.LoginRequest
Connecting to login.php...

Requesting: https://www.kingdomofloathing.com/login.php?password=<redacted>&secure=0&loginname=molman&loggingin=Yup.
2 request properties

Field: User-Agent = [KoLmafia v15.1]
Field: Content-Type = [application/x-www-form-urlencoded]

Time out during data post (login.php).  This could be bad...
Retrieving server reply...
Time out during response (login.php).
Connecting to login.php...

Requesting: https://www.kingdomofloathing.com/login.php?password=<redacted>&secure=0&loginname=molman&loggingin=Yup.
2 request properties

Field: User-Agent = [KoLmafia v15.1]
Field: Content-Type = [application/x-www-form-urlencoded]

Time out during data post (login.php).  This could be bad...
Retrieving server reply...
Time out during response (login.php).
Requests complete.

I can log in fine from https://www.kingdomofloathing.com if I go there in the browser (tested in both FF8.0.1 and IE8) so it's not that the URL is somehow disallowed.
 

holatuwol

Developer
When you say "ignored" do you mean that it skips the proxy and directly connects to KoL without it, or that nothing happens on the proxy that you can see?

10649 basically disables the native SSL security stuff that's in Java since some random posts throughout the Internet suggest it as a first step in debugging the problem, but since I don't know of any proxy software that's easy to setup/configure for debugging purposes, it's really just a guess.
 

Winterbay

Active member
10650: No change from my pov. No idea why the https-version can't even reach the server while the normal version works just fine.
I guess that this could indicate that it is indeed just skipping the proxy since that is what happenes if I try to connect anywhere outside of the proxy as well.
 

Catch-22

Active member
When you say "ignored" do you mean that it skips the proxy and directly connects to KoL without it, or that nothing happens on the proxy that you can see?

Correct, I don't require a proxy to login (not behind a restrictive firewall), but I use a proxy to capture HTTP traffic for analysis (similar to Wireshark). What basically seems to happen for me with HTTPS is that the proxy setting is completely ignored and KoLmafia just sends the HTTPS requests directly.

The logic behind the way proxies work seems a bit odd anyway, for example, if I put "localhost" as the host and "8989" as the port (nothing listening) for the HTTP proxy, it will still connect directly. Most programs would say something like "Proxy refused connection", but KoLmafia seems to just try to use a proxy and if it doesn't work it just ignores the setting and connects directly.

I'll see what I can do to provide some more information.
 

Catch-22

Active member
Okay, so I commented out line 210 of GenericRequest.java
PHP:
//GenericRequest.applyProxySettings();
in r10654. Then I compiled the JAR and ran it like this:

Code:
javaw -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8888 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8888 -jar KoLmafia-10654.jar

I figured that would rule out any potentially funky logic that might be removing the HTTPS proxy settings in KoLmafia. Using my custom build, I'm not able to login using the HTTPS method at all, and I don't see any traffic on my proxy. I switched to the old fashioned method and all the HTTP traffic flows through the proxy as expected. I then performed the following test in the CLI, debug log below:

Code:
> ash visit_url("https://www.google.com/")

<SCOPE>
   <TYPES>
   <VARIABLES>
   <FUNCTIONS>
   <COMMANDS>
      <CALL visit_url>
         <VALUE string [https://www.google.com/]>
Executing top-level commands
      Param #1: "https://www.google.com/"
      [NORMAL] <- "https://www.google.com/"
      Entering function visit_url
class net.sourceforge.kolmafia.request.GenericRequest
Connecting to https://www.google.com/...

Requesting: https://www.kingdomofloathing.com/https://www.google.com/
1 request properties

Field: User-Agent = [KoLmafia v15.1]

Retrieving server reply...
Time out during response (https://www.google.com/).
      Function visit_url returned: 
   [NORMAL] <- ""
Returned:

Performing the same test on an unmodified r10646 without the HTTPS proxy set returns the correct results.

Hopefully this provides some more clues...
 
Last edited:

holatuwol

Developer
Debugging this myself, I determined that the settings weren't actually saving for https.*, so that part is now fixed.

I installed a small web proxy (polipo) and it seems like HTTP traffic coming out of KoLmafia is logged, but HTTPS traffic doesn't get logged in it, which matches what you've been saying. However, I tested with Firefox and got similar symptoms, so I'm thinking my proxy isn't capturing the right data. I'll have to setup a VirtualBox VM later with a host-only adapter to see if login works at all.
 

Winterbay

Active member
Tried r10658 just now and got a debuglog while trying to log in with all the three options set (proxy, https and lag spikes):
Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
         KoLmafia v15.1 r10658, Windows XP, Java 1.6.0_23
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post this log in the KoLmafia thread. If you
 would like the dev team to look at it, please write a bug report
 at kolmafia.us. Include specific information about what you were 
 doing when you made this and include the log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Tue Feb 28 08:17:20 CET 2012
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Unexpected error, debug log printed.
class java.lang.NullPointerException: null
java.lang.NullPointerException
	at sun.net.www.protocol.http.HttpURLConnection.doTunneling(Unknown Source)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.setProxiedClient(Unknown Source)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.setProxiedClient(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
	at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:1542)
	at net.sourceforge.kolmafia.request.GenericRequest.execute(GenericRequest.java:1354)
	at net.sourceforge.kolmafia.request.GenericRequest.run(GenericRequest.java:1247)
	at net.sourceforge.kolmafia.request.LoginRequest.run(LoginRequest.java:268)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:221)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:184)
	at net.sourceforge.kolmafia.swingui.LoginFrame$LoginPanel.doLogin(LoginFrame.java:335)
	at net.sourceforge.kolmafia.swingui.LoginFrame$LoginPanel.actionConfirmed(LoginFrame.java:294)
	at net.sourceforge.kolmafia.swingui.panel.GenericPanel$ConfirmedListener.execute(GenericPanel.java:604)
	at net.sourceforge.kolmafia.swingui.listener.ThreadedListener.run(ThreadedListener.java:239)
	at net.sourceforge.kolmafia.RequestThread$ThreadWrappedRunnable.run(RequestThread.java:340)

Edit: In case it is in any way relevant to the thing, the proxy I'm connecting to is set to connect at port 8080.
 

holatuwol

Developer
An exception in the middle of Sun/Oracle's source code. While I introduced it to try to fix the issue, it's possible that the code I added for naive SSL caused it, so I've made it opt-in. Can you try again to see if you get the same stack trace?
 

Winterbay

Active member
A renewed attempt 2 hours later gave the same stack trace, so it's reproducible at least. I'm not sure if that's better or not though :)
 

Catch-22

Active member
However, I tested with Firefox and got similar symptoms, so I'm thinking my proxy isn't capturing the right data.
I believe you'll need to increase the logLevel in Polipo such that tunneled connections are logged.

I'm about to build from SVN and try out the latest changes, I'll let you know if there's anything new to report.

Edit:

Tried with the same options ticked as Winterbay:

Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        KoLmafia v15.1 r10674, Windows 7, Java 1.7.0_04-ea
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post this log in the KoLmafia thread. If you
 would like the dev team to look at it, please write a bug report
 at kolmafia.us. Include specific information about what you were 
 doing when you made this and include the log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Wed Feb 29 11:03:12 CST 2012
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Unexpected error, debug log printed.
class java.lang.IllegalArgumentException: no default SSLSocketFactory specified
java.lang.IllegalArgumentException: no default SSLSocketFactory specified
	at javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(Unknown Source)
	at net.sourceforge.kolmafia.utilities.NaiveSecureSocketLayer.uninstall(NaiveSecureSocketLayer.java:90)
	at net.sourceforge.kolmafia.request.GenericRequest.applySettings(GenericRequest.java:237)
	at net.sourceforge.kolmafia.request.LoginRequest.detectChallenge(LoginRequest.java:117)
	at net.sourceforge.kolmafia.request.LoginRequest.run(LoginRequest.java:254)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:221)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:184)
	at net.sourceforge.kolmafia.swingui.LoginFrame$LoginPanel.doLogin(LoginFrame.java:335)
	at net.sourceforge.kolmafia.swingui.LoginFrame$LoginPanel.actionConfirmed(LoginFrame.java:294)
	at net.sourceforge.kolmafia.swingui.panel.GenericPanel$ConfirmedListener.execute(GenericPanel.java:604)
	at net.sourceforge.kolmafia.swingui.listener.ThreadedListener.run(ThreadedListener.java:239)
	at net.sourceforge.kolmafia.RequestThread$ThreadWrappedRunnable.run(RequestThread.java:340)

and again with the new "Don't validate SSL certificates" option ticked:

Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        KoLmafia v15.1 r10674, Windows 7, Java 1.7.0_04-ea
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post this log in the KoLmafia thread. If you
 would like the dev team to look at it, please write a bug report
 at kolmafia.us. Include specific information about what you were 
 doing when you made this and include the log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Wed Feb 29 11:03:16 CST 2012
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Unexpected error, debug log printed.
class java.lang.IllegalArgumentException: no default SSLSocketFactory specified
java.lang.IllegalArgumentException: no default SSLSocketFactory specified
	at javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(Unknown Source)
	at net.sourceforge.kolmafia.utilities.NaiveSecureSocketLayer.install(NaiveSecureSocketLayer.java:84)
	at net.sourceforge.kolmafia.request.GenericRequest.applySettings(GenericRequest.java:233)
	at net.sourceforge.kolmafia.request.LoginRequest.detectChallenge(LoginRequest.java:117)
	at net.sourceforge.kolmafia.request.LoginRequest.run(LoginRequest.java:254)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:221)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:184)
	at net.sourceforge.kolmafia.swingui.LoginFrame$LoginPanel.doLogin(LoginFrame.java:335)
	at net.sourceforge.kolmafia.swingui.LoginFrame$LoginPanel.actionConfirmed(LoginFrame.java:294)
	at net.sourceforge.kolmafia.swingui.panel.GenericPanel$ConfirmedListener.execute(GenericPanel.java:604)
	at net.sourceforge.kolmafia.swingui.listener.ThreadedListener.run(ThreadedListener.java:239)
	at net.sourceforge.kolmafia.RequestThread$ThreadWrappedRunnable.run(RequestThread.java:340)

Edit 2:

Hola, there's something wrong with this line in NaiveSecureSocketLayer.java

Code:
sslContext.init( null, naiveTrustManagers, new SecureRandom() );

There's more than just this bug though, I have a feeling there's also something funky in GenericRequest.java

Edit 3:

Compiled after changing
Code:
sslContext.init( null, naiveTrustManagers, new SecureRandom() );
to
Code:
sslContext.init( null, null, null );
in NativeSecureSocketLayer.java, the exception no longer throws, but still no joy with HTTPS login.

Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        KoLmafia v15.1 r10674, Windows 7, Java 1.7.0_04-ea
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post this log in the KoLmafia thread. If you
 would like the dev team to look at it, please write a bug report
 at kolmafia.us. Include specific information about what you were 
 doing when you made this and include the log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Wed Feb 29 11:37:39 CST 2012
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


> login player

Sending login request...
class net.sourceforge.kolmafia.request.LoginRequest
Connecting to login.php...

Requesting: https://www.kingdomofloathing.com/login.php?password=password&secure=0&loginname=player%2Fq&loggingin=Yup.
2 request properties

Field: User-Agent = [KoLmafia v15.1]
Field: Content-Type = [application/x-www-form-urlencoded]

Time out during data post (login.php).  This could be bad...
Retrieving server reply...
Time out during response (login.php).
Connecting to login.php...

Requesting: https://www.kingdomofloathing.com/login.php?password=password&secure=0&loginname=player%2Fq&loggingin=Yup.
2 request properties

Field: User-Agent = [KoLmafia v15.1]
Field: Content-Type = [application/x-www-form-urlencoded]

Time out during data post (login.php).  This could be bad...
Retrieving server reply...
Time out during response (login.php).
Requests complete.

> debug off
 
Last edited:
Top