Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb601943 authored by Steve Kondik's avatar Steve Kondik
Browse files

OpenVPN fixes for Eclair.

parent 13f6adf7
Loading
Loading
Loading
Loading
+10 −15
Original line number Diff line number Diff line
@@ -16,18 +16,18 @@

package com.android.server.vpn;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;

import android.net.LocalSocket;
import android.net.LocalSocketAddress;
import android.net.vpn.OpenvpnProfile;
import android.net.vpn.VpnManager;
import android.os.SystemProperties;
import android.security.Credentials;
import android.util.Log;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;

/**
 * The service that manages the openvpn VPN connection.
 */
@@ -66,9 +66,9 @@ class OpenvpnService extends VpnService<OpenvpnProfile> {
	args.add("--proto"); args.add(p.getProto());
	args.add("--client");
	args.add("--rport"); args.add(p.getPort());
	args.add("--ca"); args.add(USE_INLINE); args.add(USE_KEYSTORE + p.getCAFile());
	args.add("--cert"); args.add(USE_INLINE); args.add(USE_KEYSTORE + p.getCertFile());
	args.add("--key"); args.add(USE_INLINE); args.add(USE_KEYSTORE + p.getKeyFile());
	args.add("--ca"); args.add(USE_INLINE); args.add(USE_KEYSTORE + Credentials.CA_CERTIFICATE + p.getCAName());
	args.add("--cert"); args.add(USE_INLINE); args.add(USE_KEYSTORE + Credentials.USER_CERTIFICATE + p.getCertName());
	args.add("--key"); args.add(USE_INLINE); args.add(USE_KEYSTORE + Credentials.USER_PRIVATE_KEY + p.getCertName());
	args.add("--persist-tun");
	args.add("--persist-key");
	args.add("--management"); args.add("/dev/socket/" + socketName); args.add("unix");
@@ -84,7 +84,7 @@ class OpenvpnService extends VpnService<OpenvpnProfile> {
	    args.add("--ifconfig"); args.add(p.getLocalAddr()); args.add(p.getRemoteAddr());
	}

	DaemonProxy mtpd = startDaemon(MTPD);
	DaemonProxy mtpd = new VpnDaemons().startDaemon(MTPD);
	mtpd.sendCommand(args.toArray(new String[args.size()]));
    }

@@ -102,11 +102,6 @@ class OpenvpnService extends VpnService<OpenvpnProfile> {
	setVpnStateUp(true);
    }

    @Override
    protected void stopPreviouslyRunDaemons() {
        stopDaemon(MtpdHelper.MTPD);
    }

    @Override
    protected void recover() {
	try {
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ class VpnDaemons implements Serializable {
        return 0;
    }

    private synchronized DaemonProxy startDaemon(String daemonName)
    synchronized DaemonProxy startDaemon(String daemonName)
            throws IOException {
        DaemonProxy daemon = new DaemonProxy(daemonName);
        mDaemonList.add(daemon);
+9 −9
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ abstract class VpnService<E extends VpnProfile> implements Serializable {
    	if (state) {
    		SystemProperties.set(VPN_STATUS, VPN_IS_UP);
    		onConnected();
	    mNotification.update();
    		mNotification.update(System.currentTimeMillis());
    	} else {
    		SystemProperties.set(VPN_STATUS, VPN_IS_DOWN);
    	}
@@ -231,7 +231,7 @@ abstract class VpnService<E extends VpnProfile> implements Serializable {

    void vpnStateUpdate(long in, long out) {
    	// currently don't show in and out bytes in status
	mNotification.update();
    	mNotification.update(System.currentTimeMillis());
    }

    private synchronized void onConnected() throws IOException {
+0 −13
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.net.vpn;

import android.os.Parcel;
import android.security.CertTool;

/**
 * The profile for Openvpn type of VPN.
@@ -84,10 +83,6 @@ public class OpenvpnProfile extends VpnProfile {
	mUserAuth = auth;
    }

    public String getCAFile() {
	return CertTool.getInstance().getCaCertificate(mCA) ;
    }

    public String getCAName() {
	return mCA;
    }
@@ -96,10 +91,6 @@ public class OpenvpnProfile extends VpnProfile {
	mCA = name;
    }

    public String getCertFile() {
        return CertTool.getInstance().getUserCertificate(mCert);
    }

    public String getCertName() {
	return mCert;
    }
@@ -108,10 +99,6 @@ public class OpenvpnProfile extends VpnProfile {
	mCert = name;
    }

    public String getKeyFile() {
        return CertTool.getInstance().getUserPrivateKey(mCert);
    }

    public void setUseCompLzo(boolean b) {
	mUseCompLzo = b;
    }
+2 −4
Original line number Diff line number Diff line
@@ -28,10 +28,8 @@ public enum VpnType {
    L2TP_IPSEC_PSK("L2TP/IPSec PSK", R.string.l2tp_ipsec_psk_vpn_description,
            L2tpIpsecPskProfile.class),
    L2TP_IPSEC("L2TP/IPSec CRT", R.string.l2tp_ipsec_crt_vpn_description,
            L2tpIpsecProfile.class);
    L2TP_IPSEC("L2TP/IPSec CRT", "Certificate based L2TP/IPSec VPN",
            L2tpIpsecProfile.class),
    OPENVPN("OpenVPN", "", OpenvpnProfile.class);
    OPENVPN("OpenVPN", -1, OpenvpnProfile.class);

    private String mDisplayName;
    private int mDescriptionId;