From 6dbfffefaf70609ac5bb7b3ebd71a0258427360a 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 --- src/de/blinkt/openvpn/VpnProfile.java | 62 +++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 10 deletions(-) (limited to 'src/de/blinkt/openvpn/VpnProfile.java') diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java index c199cf8b..e17fb8ff 100644 --- a/src/de/blinkt/openvpn/VpnProfile.java +++ b/src/de/blinkt/openvpn/VpnProfile.java @@ -46,7 +46,7 @@ public class VpnProfile implements Serializable{ public String mName; public String mAlias; public String mClientCertFilename; - public int mTLSAuthDirection=2; + public String mTLSAuthDirection=""; public String mTLSAuthFilename; public String mClientKeyFilename; public String mCaFilename; @@ -84,7 +84,7 @@ public class VpnProfile implements Serializable{ out.writeString(mName); out.writeString(mAlias); out.writeString(mClientCertFilename); - out.writeInt(mTLSAuthDirection); + out.writeString(mTLSAuthDirection); out.writeString(mTLSAuthFilename); out.writeString(mClientKeyFilename); out.writeString(mCaFilename); @@ -103,7 +103,7 @@ public class VpnProfile implements Serializable{ mName = in.readString(); mAlias = in.readString(); mClientCertFilename = in.readString(); - mTLSAuthDirection = in.readInt(); + mTLSAuthDirection = in.readString(); mTLSAuthFilename = in.readString(); mClientKeyFilename = in.readString(); mCaFilename = in.readString(); @@ -156,7 +156,16 @@ public class VpnProfile implements Serializable{ - cfg+="client\n"; + boolean useTLSClient = (mAuthenticationType != TYPE_STATICKEYS); + + if(useTLSClient && mUsePull) + cfg+="client\n"; + else if (mUsePull) + cfg+="pull\n"; + else if(useTLSClient) + cfg+="tls-client"; + + cfg+="verb 2\n"; @@ -224,14 +233,35 @@ public class VpnProfile implements Serializable{ if(mUseTLSAuth) { cfg+="tls-auth "; cfg+=mTLSAuthFilename; - int tlsdir= mTLSAuthDirection; - // 2 is unspecified - if(tlsdir == 0 || tlsdir==1) { - cfg+=" "; - cfg+=new Integer(tlsdir).toString(); - } + cfg+=" "; + cfg+= mTLSAuthDirection; cfg+="\n"; } + + // Basic Settings + if(!mUsePull ) { + cfg +="ifconfig " + mIPv4Address + " 255.255.255.255\n"; + } + + if(mOverrideDNS || !mUsePull) { + if(!mDNS1.equals("") && mDNS1!=null) + cfg+="dhcp-option DNS " + mDNS1 + "\n"; + if(!mDNS2.equals("") && mDNS2!=null) + cfg+="dhcp-option DNS " + mDNS2 + "\n"; + + } + + + + // Authentication + if(mCheckRemoteCN) { + if(mRemoteCN == null || mRemoteCN.equals("") ) + cfg+="tls-remote " + mServerName + "\n"; + else + cfg += "tls-remote " + mRemoteCN + "\n"; + } + if(mExpectTLSCert) + cfg += "remote-cert-tls server\n"; return cfg; } @@ -280,6 +310,8 @@ public class VpnProfile implements Serializable{ intent.putExtra(prefix + ".PASSWORD", mPassword); } + intent.putExtra(prefix + ".profileUUID", mUuid.toString()); + try { FileWriter cfg = new FileWriter(activity.getCacheDir().getAbsolutePath() + "/" + OVPNCONFIGFILE); cfg.write(getConfigFile(activity.getCacheDir())); @@ -337,6 +369,16 @@ public class VpnProfile implements Serializable{ return "ERROR"; } + //! Return an error if somethign is wrong + int checkProfile() { + if(mAuthenticationType==TYPE_KEYSTORE && mAlias==null) + return R.string.no_keystore_cert_selected; + + + // Everything okay + return R.string.no_error_found; + + } } -- cgit v1.2.3