Originally Posted by
Clownhair
Thanks for putting your time into this however you've lost me.
As I understand it: you created a new java app where your main class is client.java and you run that to get a 'smart' client going? Even if I would get this working (atm doesn't work -> content is null so can't get contentlength in downloadPage)
How am I going to get it to work together with Simba? Are you implieing to start a client with java app and then use the 'select a client' feature in simba?
No. I modified the existing SMART application and added those two lines..
Then I recompiled SMART with the modifications and voila.
Downloads:
Here's the project for OSX: SMART-master.zip
Here's the SMART loader to test for OSX: SMARTLoader.zip
Debug Downloads: (prints JVM arguments)
SMART-master-debug.zip
Screenshots:
http://i.imgur.com/h2VzuDi.jpg
http://i.imgur.com/XLooFo8.jpg
If you're using Windows, you only need to download the above Jar file from Smart-master.zip dist folder. If you're using OSX or Linux, you need to download all of the above files.
Details of my modifications: ( @BenLand100; this argument passing or similar might need to be added to the official SMART Github Repository.. Don't know if you also want to add proxy authentication support as well..)
What I did was modify SmartRemote.cpp (only needed for OSX and Linux.. Windows already has this) to allow Java arguments for Linux and OSX by changing the execution function to:
C++ Code:
//Passes JVM arguments on Linux and OSX..char *args
[256] = {0}; int i
= 0; args
[i
++] = java_exec
; if (javaargs
) { char *str
= strdup
(javaargs
); //because strtok doesn't work on const char*. Must be char*. char *ch
= strtok(str
, " "); while (ch
!= NULL
) { args
[i
++] = ch
; //might need strdup but meh.. it works.. ch
= strtok(NULL
, " "); } free(str
); } args
[i
++] = bootclasspath
; args
[i
++] = "smart.Main"; args
[i
++] = library
; args
[i
++] = root
; args
[i
++] = params
; args
[i
++] = _width
; args
[i
++] = _height
; args
[i
++] = initseq
; args
[i
++] = useragent
; args
[i
++] = remote_path
; args
[i
++] = plugins
; args
[i
++] = NULL
; args
[i
++] = NULL
; //execlp(java_exec,java_exec,javaargs,bootclasspath,"smart.Main",library,root,params,_width,_height,initseq,useragent, remote_path, plugins, NULL); execvp
(java_exec
, args
); debug
<< "Process terminating. If nothing happened, make sure java is on your path and that SMART is installed correctly.\n"; exit(1);
Then I modified Client.java to increase the connect and read timeout:
Java Code:
private String downloadHTML
(String address
) { try { URL url
= new URL(address
); URLConnection conn
= url.
openConnection(); conn.
setConnectTimeout(15000); conn.
setReadTimeout(15000); //Firefox didn't set anything important that java didn't set by default, besides the useragent //this useragent is for your browser, modify at will //conn.addRequestProperty("Protocol", "HTTP/1.1"); //conn.addRequestProperty("Connection", "keep-alive"); //conn.addRequestProperty("Keep-Alive", "200"); conn.
addRequestProperty("User-Agent",useragent
== null ? USER_AGENT
: useragent
); conn.
connect(); BufferedReader in
= new BufferedReader(new InputStreamReader(conn.
getInputStream())); StringBuilder builder
= new StringBuilder
(); String inputLine
; while ((inputLine
= in.
readLine()) != null) { builder.
append(inputLine
).
append("\n"); } in.
close(); return builder.
toString(); } catch (Exception e
) { Main.
debug(e.
getMessage()); return null; } }
Finally, I compiled all of it and voila.. Can connect to any proxy.. I have attached the compiled files above. Simba will load it just fine. I tested using the following arguments:
Simba Code:
.
-DsocksProxyHost=93.92.200.67 -DsocksProxyPort=9050 -Dhttp.nonProxyHosts=local|*.local|169.254/16|*.169.254/16
.
EDIT: I just got an PM from clown hair that his/her SOCKS5 proxy doesn't work and requires authentication. He/she did confirm that it worked with public proxies though.. I had to add a further modification to SMART for authentication:
I modified Main.java and added the following code:
Java Code:
public static void main
(String[] exec_args
) { if (exec_args.
length != 9) System.
exit(1); if (Boolean.
valueOf(System.
getProperty("socksCustomAuthentication"))) { Authenticator.
setDefault(new Authenticator() { @Override
protected PasswordAuthentication getPasswordAuthentication
() { String username
= System.
getProperty("java.net.socks.username"); String password
= System.
getProperty("java.net.socks.password"); return new PasswordAuthentication(username, password
== null ? new char[]{} : password.
toCharArray()); } }); } System.
clearProperty("socksCustomAuthentication"); //Just in case Jagex decides to check for custom JVM flags.. //Rest of SMART's code here..}
Now when the new arguments to SMART's command line is as follows:
Simba Code:
.
-DsocksCustomAuthentication=true -DsocksProxyHost=IpOrHostNameHere -DsocksProxyPort=PortNumberHere -Djava.net.socks.username=UserNameHere -Djava.net.socks.password=PasswordHere -Dhttp.nonProxyHosts=local|*.local|169.254/16|*.169.254/16
.
The -DsocksCustomAuthentication=true will set my boolean to true and allow it to use the custom password authentication. I've tested this using the Proxy provided by clown hair.
I have re-uploaded the files with the new modifications. You can feel free to download and test them.