From 63e466054c2f1d66e4618ac4d73208751f1e5bd1 Mon Sep 17 00:00:00 2001 From: schwabe Date: Sat, 28 Apr 2012 19:58:02 +0200 Subject: Almost ready for version 0.4 --- openvpn/src/openvpn/jniglue.c | 18 + openvpn/src/openvpn/jniglue.h | 3 +- openvpn/src/openvpn/options.c | 6 + openvpn/src/openvpn/tun.c | 7 + openvpn/src/openvpn/tun.h | 3 +- res/layout/basic_settings.xml | 56 +-- res/values-de/arrays.xml | 7 - res/values/arrays.xml | 7 + res/values/strings.xml | 6 +- res/xml/vpn_authentification.xml | 27 +- src/de/blinkt/openvpn/BasicSettings.java | 71 ++-- src/de/blinkt/openvpn/FileSelectLayout.java | 11 +- src/de/blinkt/openvpn/LogWindow.java | 151 +++++++- src/de/blinkt/openvpn/OpenVPN.java | 31 ++ src/de/blinkt/openvpn/OpenVPNClient.java | 383 --------------------- src/de/blinkt/openvpn/OpenVpnService.java | 33 +- src/de/blinkt/openvpn/ProfileManager.java | 23 ++ src/de/blinkt/openvpn/Settings_Authentication.java | 60 +++- src/de/blinkt/openvpn/Settings_IP.java | 4 + src/de/blinkt/openvpn/VPNConfigPreference.java | 7 +- src/de/blinkt/openvpn/VPNDatabase.java | 0 src/de/blinkt/openvpn/VPNPreferences.java | 57 +-- src/de/blinkt/openvpn/VPNProfileList.java | 99 +++--- src/de/blinkt/openvpn/VpnProfile.java | 62 +++- 24 files changed, 495 insertions(+), 637 deletions(-) delete mode 100644 src/de/blinkt/openvpn/OpenVPNClient.java delete mode 100644 src/de/blinkt/openvpn/VPNDatabase.java diff --git a/openvpn/src/openvpn/jniglue.c b/openvpn/src/openvpn/jniglue.c index 2d529365..686092bc 100644 --- a/openvpn/src/openvpn/jniglue.c +++ b/openvpn/src/openvpn/jniglue.c @@ -143,6 +143,24 @@ int android_open_tun () { } +void android_set_dns(const char* dns) { + jmethodID aMethodID = (*openvpnjenv)->GetStaticMethodID(openvpnjenv, openvpnclass, "addDns", + "(Ljava/lang/String;)V"); + jstring jdns = (*openvpnjenv)->NewStringUTF(openvpnjenv,dns); + (*openvpnjenv)->CallStaticVoidMethod(openvpnjenv,openvpnclass,aMethodID,jdns); + + +} + +void android_set_domain(const char* domain) { + jmethodID aMethodID = (*openvpnjenv)->GetStaticMethodID(openvpnjenv, openvpnclass, "addDomain", + "(Ljava/lang/String;)V"); + jstring jdomain = (*openvpnjenv)->NewStringUTF(openvpnjenv,domain); + (*openvpnjenv)->CallStaticVoidMethod(openvpnjenv,openvpnclass,aMethodID,jdomain); + + +} + void addRouteInformation(const char* dest, const char* mask, const char* gw) { jstring jmask = (*openvpnjenv)->NewStringUTF(openvpnjenv, mask); diff --git a/openvpn/src/openvpn/jniglue.h b/openvpn/src/openvpn/jniglue.h index cb3ae410..7c723ef5 100644 --- a/openvpn/src/openvpn/jniglue.h +++ b/openvpn/src/openvpn/jniglue.h @@ -14,6 +14,7 @@ void addRouteInformation(const char* dest, const char* mask, const char* gw); void addInterfaceInformation(int mtu,const char* ifconfig_local, const char* ifconfig_remote); void android_openvpn_log(int level,const char* prefix,const char* prefix_sep,const char* m1); void android_openvpn_exit(int status); - +void android_set_dns(const char* dns); +void android_set_domain(const char* domain); #endif diff --git a/openvpn/src/openvpn/options.c b/openvpn/src/openvpn/options.c index fcf436c4..b74e559b 100644 --- a/openvpn/src/openvpn/options.c +++ b/openvpn/src/openvpn/options.c @@ -1133,8 +1133,10 @@ show_tuntap_options (const struct tuntap_options *o) show_dhcp_option_addrs ("NBDD", o->nbdd, o->nbdd_len); } +#endif #endif +#if defined(WIN32) || defined(TARGET_ANDROID) static void dhcp_option_address_parse (const char *name, const char *parm, in_addr_t *array, int *len, int msglevel) { @@ -5999,6 +6001,8 @@ add_option (struct options *options, to->ip_win32_type = index; to->ip_win32_defined = true; } +#endif +#if defined(WIN32) || defined(TARGET_ANDROID) else if (streq (p[0], "dhcp-option") && p[1]) { struct tuntap_options *o = &options->tuntap_options; @@ -6050,6 +6054,8 @@ add_option (struct options *options, } o->dhcp_options = true; } +#endif +#ifdef WIN32 else if (streq (p[0], "show-adapters")) { VERIFY_PERMISSION (OPT_P_GENERAL); diff --git a/openvpn/src/openvpn/tun.c b/openvpn/src/openvpn/tun.c index db8104d4..58e9bc53 100644 --- a/openvpn/src/openvpn/tun.c +++ b/openvpn/src/openvpn/tun.c @@ -1378,6 +1378,13 @@ close_tun_generic (struct tuntap *tt) void open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt) { + struct gc_arena gc = gc_new (); + int i; + for (i = 0; i < tt->options.dns_len; ++i) { + android_set_dns(print_in_addr_t(tt->options.dns[i], 0, &gc)); + } + if(tt->options.domain) + android_set_domain(tt->options.domain); tt->fd = android_open_tun(); } diff --git a/openvpn/src/openvpn/tun.h b/openvpn/src/openvpn/tun.h index 63ab8721..6754c726 100644 --- a/openvpn/src/openvpn/tun.h +++ b/openvpn/src/openvpn/tun.h @@ -38,7 +38,7 @@ #include "proto.h" #include "misc.h" -#ifdef WIN32 +#if defined(WIN32) || defined(TARGET_ANDROID) #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1) @@ -76,6 +76,7 @@ struct tuntap_options { int netbios_node_type; /* NBT 1,2,4,8 (46) */ + #define N_DHCP_ADDR 4 /* Max # of addresses allowed for DNS, WINS, etc. */ diff --git a/res/layout/basic_settings.xml b/res/layout/basic_settings.xml index 4e6f549f..f6673491 100644 --- a/res/layout/basic_settings.xml +++ b/res/layout/basic_settings.xml @@ -212,60 +212,10 @@ style="@style/item"/> - - - + - - - - - - - - - - - - - -