Correctinos and enhancements for domain options testing via sockets.
This commit is contained in:
parent
d3c62505b3
commit
984d169e2c
@ -296,11 +296,15 @@ public class DomainTest {
|
||||
public boolean isOptionConfigured(String domain)
|
||||
throws UnknownHostException, IOException {
|
||||
String host = "test-h99.hostsharing.net";
|
||||
String answer = socketQuery(host, 25, "HELO " + domain + "\n"
|
||||
+ "MAIL FROM: hsadmin-testing@" + domain + "\n"
|
||||
+ "RCPT TO: postmaster@" + domain + "\n" + "DATA\n"
|
||||
+ ".\n");
|
||||
return answer.contains("450") && answer.contains("reylisting");
|
||||
String[] query = {
|
||||
"HELO " + domain + "\n" ,
|
||||
"MAIL FROM: hsadmin-testing@" + domain + "\n" ,
|
||||
"RCPT TO: postmaster@" + domain + "\n" ,
|
||||
"DATA\n" ,
|
||||
".\n" ,
|
||||
"QUIT\n" } ;
|
||||
String[] answer = socketQuery(host, 25, query ) ;
|
||||
return answer[3].contains("450") && answer[3].contains("reylisting");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -318,12 +322,12 @@ public class DomainTest {
|
||||
public boolean isOptionConfigured(String domain)
|
||||
throws UnknownHostException, IOException {
|
||||
String host = "test-h99.hostsharing.net";
|
||||
String answer = socketQuery(host, 80, "GET / HTTP/1.1\n"
|
||||
String[] answer = socketQuery(host, 80, "GET / HTTP/1.1\n"
|
||||
+ "Host: x.y.z." + domain
|
||||
+ "User-Agent: hsAdmin Test\n"
|
||||
+ "Connection: close\n");
|
||||
answer = answer.substring(0, answer.indexOf("\n"));
|
||||
return answer.contains("404");
|
||||
// answer = answer.substring(0, answer.indexOf("\n"));
|
||||
return answer[1].contains("404");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -342,12 +346,12 @@ public class DomainTest {
|
||||
throws UnknownHostException, IOException {
|
||||
String host = "test-h99.hostsharing.net";
|
||||
// TODO dieser Test ist Humbug
|
||||
String answer = socketQuery(host, 80, "GET / HTTP/1.1\n"
|
||||
String[] answer = socketQuery(host, 80, "GET / HTTP/1.1\n"
|
||||
+ "Host: " + domain
|
||||
+ "User-Agent: hsAdmin Test\n"
|
||||
+ "Connection: close\n");
|
||||
answer = answer.substring(0, answer.indexOf("\n"));
|
||||
return answer.contains("404");
|
||||
// answer = answer.substring(0, answer.indexOf("\n"));
|
||||
return answer[1].contains("404");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -366,12 +370,12 @@ public class DomainTest {
|
||||
throws UnknownHostException, IOException {
|
||||
String host = "test-h99.hostsharing.net";
|
||||
// TODO dieser Test ist Humbug
|
||||
String answer = socketQuery(host, 80, "GET / HTTP/1.1\n"
|
||||
String[] answer = socketQuery(host, 80, "GET / HTTP/1.1\n"
|
||||
+ "Host: " + domain
|
||||
+ "User-Agent: hsAdmin Test\n"
|
||||
+ "Connection: close\n");
|
||||
answer = answer.substring(0, answer.indexOf("\n"));
|
||||
return answer.contains("404");
|
||||
// answer = answer.substring(0, answer.indexOf("\n"));
|
||||
return answer[1].contains("404");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -390,12 +394,12 @@ public class DomainTest {
|
||||
throws UnknownHostException, IOException {
|
||||
String host = "test-h99.hostsharing.net";
|
||||
// TODO dieser Test ist Humbug
|
||||
String answer = socketQuery(host, 80, "GET / HTTP/1.1\n"
|
||||
String[] answer = socketQuery(host, 80, "GET / HTTP/1.1\n"
|
||||
+ "Host: " + domain
|
||||
+ "User-Agent: hsAdmin Test\n"
|
||||
+ "Connection: close\n");
|
||||
answer = answer.substring(0, answer.indexOf("\n"));
|
||||
return answer.contains("404");
|
||||
// answer = answer.substring(0, answer.indexOf("\n"));
|
||||
return answer[1].contains("404");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -469,13 +473,35 @@ public class DomainTest {
|
||||
return count;
|
||||
}
|
||||
|
||||
private String socketQuery( String host, int port, String query) throws UnknownHostException, IOException{
|
||||
private static String[] socketQuery( String host, int port, String command) throws UnknownHostException, IOException{
|
||||
String[] query = { command } ;
|
||||
return socketQuery( host , port , query );
|
||||
}
|
||||
|
||||
private static String[] socketQuery( String host, int port, String[] query) throws UnknownHostException, IOException{
|
||||
Socket socket = new Socket( host, port );
|
||||
socketQueryWriter( socket, query );
|
||||
return socketQueryReader(socket);
|
||||
String[] retval = socketQuery( socket, query );
|
||||
socket.close();
|
||||
return retval;
|
||||
}
|
||||
|
||||
private static String[] socketQuery( Socket socket, String command) throws UnknownHostException, IOException{
|
||||
String[] query = { command } ;
|
||||
return socketQuery( socket , query );
|
||||
}
|
||||
|
||||
private static String[] socketQuery( Socket socket, String[] query) throws UnknownHostException, IOException{
|
||||
int l = query.length;
|
||||
String[] retval = new String[l];
|
||||
retval[0] = socketQueryReader(socket);
|
||||
for(int i=0; i<l; ){
|
||||
socketQueryWriter( socket, query[i] );
|
||||
retval[i++] = socketQueryReader(socket);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
private void socketQueryWriter( Socket socket, String buffer) throws IOException{
|
||||
private static void socketQueryWriter( Socket socket, String buffer) throws IOException{
|
||||
PrintWriter printWriter =
|
||||
new PrintWriter(
|
||||
new OutputStreamWriter(
|
||||
@ -484,7 +510,7 @@ public class DomainTest {
|
||||
printWriter.flush();
|
||||
}
|
||||
|
||||
private String socketQueryReader( Socket socket ) throws IOException{
|
||||
private static String socketQueryReader( Socket socket ) throws IOException{
|
||||
int maxbufferbytecount = 4099;
|
||||
BufferedReader bufferedReader =
|
||||
new BufferedReader(
|
||||
|
Loading…
Reference in New Issue
Block a user