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!");
}
}
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();
}
}
Aggregations