Search in sources :

Example 6 with Iptables

use of org.ethack.orwall.lib.Iptables in project orWall by EthACKdotOrg.

the class BackgroundProcess method onHandleIntent.

@Override
protected void onHandleIntent(Intent workIntent) {
    this.iptables = new Iptables(this);
    String action = workIntent.getStringExtra(Constants.ACTION);
    if (action != null) {
        if (action.equals(Constants.ACTION_PORTAL)) {
            boolean activate = workIntent.getBooleanExtra(Constants.PARAM_ACTIVATE, false);
            managePortal(activate);
        } else if (action.equals(Constants.ACTION_ADD_RULE)) {
            long appUID = workIntent.getLongExtra(Constants.PARAM_APPUID, 0);
            String appName = workIntent.getStringExtra(Constants.PARAM_APPNAME);
            String onionType = workIntent.getStringExtra(Constants.PARAM_ONIONTYPE);
            Boolean localHost = workIntent.getBooleanExtra(Constants.PARAM_LOCALHOST, false);
            Boolean localNetwork = workIntent.getBooleanExtra(Constants.PARAM_LOCALNETWORK, false);
            addRule(appUID, appName, onionType, localHost, localNetwork);
        } else if (action.equals(Constants.ACTION_RM_RULE)) {
            long appUID = workIntent.getLongExtra(Constants.PARAM_APPUID, 0);
            String appName = workIntent.getStringExtra(Constants.PARAM_APPNAME);
            String onionType = workIntent.getStringExtra(Constants.PARAM_ONIONTYPE);
            Boolean localHost = workIntent.getBooleanExtra(Constants.PARAM_LOCALHOST, false);
            Boolean localNetwork = workIntent.getBooleanExtra(Constants.PARAM_LOCALNETWORK, false);
            rmRule(appUID, appName, onionType, localHost, localNetwork);
        } else if (action.equals(Constants.ACTION_DISABLE_ORWALL)) {
            iptables.deactivate();
            iptables.deactivateV6();
        } else if (action.equals(Constants.ACTION_ENABLE_ORWALL)) {
            iptables.boot();
        } else {
            Log.e("BackgroundProcess", "Just got an unknown action!");
        }
    } else {
        Log.e("BackgroundProcess", "Just got an undefined action!");
    }
}
Also used : Iptables(org.ethack.orwall.lib.Iptables)

Example 7 with Iptables

use of org.ethack.orwall.lib.Iptables in project orWall by EthACKdotOrg.

the class NetworkReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    if (!Preferences.isOrwallEnabled(context)) {
        return;
    }
    String action = intent.getAction();
    Log.d(TAG, "Got a Network Change event: " + action);
    Iptables iptables = new Iptables(context);
    if (action.equals(ACTION_TETHER_STATE_CHANGED)) {
        // try the faster way
        Set<String> set = new HashSet<>(0);
        ArrayList<String> active = intent.getStringArrayListExtra(EXTRA_ACTIVE_TETHER);
        if (active != null) {
            for (String intf : active) set.add(intf);
        } else {
            // hum, try the old fashioned way
            NetworkHelper.getTetheredInterfaces(context, set);
        }
        Set<String> oldIntfs = Preferences.getTetherInterfaces(context);
        if (!set.equals(oldIntfs))
            iptables.tetherUpdate(context, oldIntfs, set);
    } else if (action.equals("android.net.wifi.WIFI_STATE_CHANGED") || action.equals("android.net.conn.CONNECTIVITY_CHANGE")) {
        Log.d(TAG, "Will do some LAN stuff");
        iptables.LANPolicy();
    }
}
Also used : Iptables(org.ethack.orwall.lib.Iptables) HashSet(java.util.HashSet)

Aggregations

Iptables (org.ethack.orwall.lib.Iptables)7 View (android.view.View)3 Intent (android.content.Intent)2 CompoundButton (android.widget.CompoundButton)2 Switch (android.widget.Switch)2 TextView (android.widget.TextView)2 InstallScripts (org.ethack.orwall.lib.InstallScripts)2 NatRules (org.ethack.orwall.lib.NatRules)2 PendingIntent (android.app.PendingIntent)1 LongSparseArray (android.support.v4.util.LongSparseArray)1 ViewPager (android.support.v4.view.ViewPager)1 ViewGroup (android.view.ViewGroup)1 Button (android.widget.Button)1 ListView (android.widget.ListView)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 PreferencesActivity (org.ethack.orwall.PreferencesActivity)1 WizardActivity (org.ethack.orwall.WizardActivity)1 AppListAdapter (org.ethack.orwall.adapter.AppListAdapter)1 TabsPagerAdapter (org.ethack.orwall.adapter.TabsPagerAdapter)1