Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Pass the request-type (qtype) to iodine
Browse files Browse the repository at this point in the history
Closes #18
  • Loading branch information
yvesf committed Dec 1, 2016
1 parent 13c7e03 commit 52914b0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
14 changes: 13 additions & 1 deletion jni/iodine-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ JNIEXPORT jint JNICALL Java_org_xapek_andiodine_IodineClient_getDnsFd(

JNIEXPORT jint JNICALL Java_org_xapek_andiodine_IodineClient_connect(
JNIEnv *env, jclass klass, jstring j_nameserv_addr, jstring j_topdomain, jboolean j_raw_mode, jboolean j_lazy_mode,
jstring j_password, jint j_request_hostname_size, jint j_response_fragment_size) {
jstring j_password, jint j_request_hostname_size, jint j_response_fragment_size,
jstring j_request_type) {

// XXX strdup leaks
const char *__p_nameserv_addr = (*env)->GetStringUTFChars(env,
Expand All @@ -105,12 +106,22 @@ JNIEXPORT jint JNICALL Java_org_xapek_andiodine_IodineClient_connect(
(*env)->ReleaseStringUTFChars(env, j_topdomain, __p_topdomain);
__android_log_print(ANDROID_LOG_ERROR, "iodine", "Topdomain from vm: %s", p_topdomain);

// extract password parameter
const char *p_password = (*env)->GetStringUTFChars(env, j_password, NULL);
char passwordField[33];
memset(passwordField, 0, 33);
strncpy(passwordField, p_password, 32);
(*env)->ReleaseStringUTFChars(env, j_password, p_password);

// extract request type parameter
const char *p_requestType = (*env)->GetStringUTFChars(env, j_request_type, NULL);
char requestTypeField[8];
memset(requestTypeField, 0, 8);
strncpy(requestTypeField, p_requestType, 7);
(*env)->ReleaseStringUTFChars(env, j_request_type, p_requestType);
__android_log_print(ANDROID_LOG_ERROR, "iodine", "Request Type from vm: %s", requestTypeField);


tun_config_android.request_disconnect = 0;

int selecttimeout = 2; // original: 4
Expand Down Expand Up @@ -140,6 +151,7 @@ JNIEXPORT jint JNICALL Java_org_xapek_andiodine_IodineClient_connect(
client_set_topdomain(p_topdomain);
client_set_hostname_maxlen(hostname_maxlen);
client_set_password(passwordField);
client_set_qtype(requestTypeField);

if ((dns_fd = open_dns_from_host(NULL, 0, AF_INET, AI_PASSIVE)) == -1) {
printf("Could not open dns socket: %s", strerror(errno));
Expand Down
3 changes: 3 additions & 0 deletions jni/iodine/src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ client_set_qtype(char *qtype)
do_qtype = T_SRV;
else if (!strcasecmp(qtype, "TXT"))
do_qtype = T_TXT;
// Added for Andiodine:
else
do_qtype = T_UNSET;
return (do_qtype == T_UNSET);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/xapek/andiodine/IodineClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public class IodineClient {
public static native int getDnsFd();

public static native int connect(String nameserv_addr, String topdomain, boolean raw_mode, boolean lazy_mode,
String password, int request_hostname_size, int response_fragment_size);
String password, int request_hostname_size, int response_fragment_size,
String request_type);

public static native String getIp();

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/xapek/andiodine/IodineVpnService.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public void run() {

int ret = IodineClient.connect(tunnelNameserver, mConfiguration.getTopDomain(), mConfiguration.getRawMode(),
mConfiguration.getLazyMode(), password, mConfiguration.getRequestHostnameSize(),
mConfiguration.getResponseFragmentSize());
mConfiguration.getResponseFragmentSize(), mConfiguration.getRequestType().getIodineName());

String errorMessage = "";
switch (ret) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ public static enum NameserverMode {
}

public static enum RequestType {
AUTODETECT, NULL, TXT, SRV, MX, CNAME, A
AUTODETECT, NULL, TXT, SRV, MX, CNAME, A;

public String getIodineName() {
if (this == AUTODETECT) {
return "";
} else {
return name();
}
}
}

private final ContentValues v;
Expand Down

0 comments on commit 52914b0

Please sign in to comment.