system/netd
Revision | 3fa3993b5ae1fa917fce763577fd2f84f2246166 (tree) |
---|---|
Time | 2018-11-11 07:46:25 |
Author | Uldiniad <olivercscott@gmai...> |
Commiter | Wolfram Liebchen |
[BACKPORT]NetD : Allow passing in interface names for vpn app restriction
Cherry-picked from https://review.lineageos.org/#/c/LineageOS/android_system_netd/+/232794/
Change-Id: Iab28b872bee61e9b6da7fe43992510fb48fa32e0
@@ -303,6 +303,7 @@ int BandwidthController::enableBandwidthControl(bool force) { | ||
303 | 303 | sharedQuotaBytes = sharedAlertBytes = 0; |
304 | 304 | |
305 | 305 | restrictAppUidsOnData.clear(); |
306 | + restrictAppUidsOnVpn.clear(); | |
306 | 307 | restrictAppUidsOnWlan.clear(); |
307 | 308 | |
308 | 309 | flushCleanTables(false); |
@@ -399,6 +400,11 @@ int BandwidthController::manipulateRestrictAppsOnWlan(const char *iface, int num | ||
399 | 400 | return manipulateRestrictAppsInOut(iface, numUids, appUids, appOp, restrictAppUidsOnWlan); |
400 | 401 | } |
401 | 402 | |
403 | +int BandwidthController::manipulateRestrictAppsOnVpn(const char *iface, int numUids, char *appUids[], | |
404 | + RestrictAppOp appOp) { | |
405 | + return manipulateRestrictAppsInOut(iface, numUids, appUids, appOp, restrictAppUidsOnVpn); | |
406 | +} | |
407 | + | |
402 | 408 | int BandwidthController::manipulateRestrictAppsInOut(const char *iface, int numUids, char *appUids[], |
403 | 409 | RestrictAppOp appOp, std::list<int /*appUid*/> &restrictAppUids) { |
404 | 410 | char *chain; |
@@ -436,6 +442,14 @@ int BandwidthController::removeRestrictAppsOnWlan(const char *iface,int numUids, | ||
436 | 442 | return manipulateRestrictAppsOnWlan(iface, numUids, appUids, RestrictAppOpRemove); |
437 | 443 | } |
438 | 444 | |
445 | +int BandwidthController::addRestrictAppsOnVpn(const char *iface, int numUids, char *appUids[]) { | |
446 | + return manipulateRestrictAppsOnVpn(iface, numUids, appUids, RestrictAppOpAdd); | |
447 | +} | |
448 | + | |
449 | +int BandwidthController::removeRestrictAppsOnVpn(const char *iface,int numUids, char *appUids[]) { | |
450 | + return manipulateRestrictAppsOnVpn(iface, numUids, appUids, RestrictAppOpRemove); | |
451 | +} | |
452 | + | |
439 | 453 | |
440 | 454 | int BandwidthController::manipulateRestrictApps(int numUids, char *appStrUids[], |
441 | 455 | const char *chain, |
@@ -104,6 +104,9 @@ public: | ||
104 | 104 | int addRestrictAppsOnWlan(const char *iface, int numUids, char *appUids[]); |
105 | 105 | int removeRestrictAppsOnWlan(const char *iface, int numUids, char *appUids[]); |
106 | 106 | |
107 | + int addRestrictAppsOnVpn(const char *iface, int numUids, char *appUids[]); | |
108 | + int removeRestrictAppsOnVpn(const char *iface, int numUids, char *appUids[]); | |
109 | + | |
107 | 110 | /* |
108 | 111 | * For single pair of ifaces, stats should have ifaceIn and ifaceOut initialized. |
109 | 112 | * For all pairs, stats should have ifaceIn=ifaceOut="". |
@@ -153,6 +156,8 @@ protected: | ||
153 | 156 | RestrictAppOp appOp); |
154 | 157 | int manipulateRestrictAppsOnWlan(const char *iface, int numUids, char* appStrUids[], |
155 | 158 | RestrictAppOp appOp); |
159 | + int manipulateRestrictAppsOnVpn(const char *iface, int numUids, char* appStrUids[], | |
160 | + RestrictAppOp appOp); | |
156 | 161 | int manipulateRestrictAppsInOut(const char *iface, int numUids, char *appUids[], |
157 | 162 | RestrictAppOp appOp, |
158 | 163 | std::list<int /*appUid*/> &restrictAppUids); |
@@ -250,6 +255,7 @@ protected: | ||
250 | 255 | |
251 | 256 | std::list<int /*appUid*/> restrictAppUidsOnData; |
252 | 257 | std::list<int /*appUid*/> restrictAppUidsOnWlan; |
258 | + std::list<int /*appUid*/> restrictAppUidsOnVpn; | |
253 | 259 | }; |
254 | 260 | |
255 | 261 | #endif |
@@ -1298,6 +1298,24 @@ int CommandListener::BandwidthControlCmd::runCommand(SocketClient *cli, int argc | ||
1298 | 1298 | sendGenericOkFail(cli, rc); |
1299 | 1299 | return 0; |
1300 | 1300 | } |
1301 | + if (!strcmp(argv[1], "addrestrictappsonvpn")) { | |
1302 | + if (argc < 4) { | |
1303 | + sendGenericSyntaxError(cli, "addrestrictappsonvpn <interface> <appUid> ..."); | |
1304 | + return 0; | |
1305 | + } | |
1306 | + int rc = gCtls->bandwidthCtrl.addRestrictAppsOnVpn(argv[2], argc - 3, argv + 3); | |
1307 | + sendGenericOkFail(cli, rc); | |
1308 | + return 0; | |
1309 | + } | |
1310 | + if (!strcmp(argv[1], "removerestrictappsonvpn")) { | |
1311 | + if (argc < 4) { | |
1312 | + sendGenericSyntaxError(cli, "removerestrictappsonvpn <inteface> <appUid> ..."); | |
1313 | + return 0; | |
1314 | + } | |
1315 | + int rc = gCtls->bandwidthCtrl.removeRestrictAppsOnVpn(argv[2], argc - 3, argv + 3); | |
1316 | + sendGenericOkFail(cli, rc); | |
1317 | + return 0; | |
1318 | + } | |
1301 | 1319 | if (!strcmp(argv[1], "addrestrictappsonwlan")) { |
1302 | 1320 | if (argc < 4) { |
1303 | 1321 | sendGenericSyntaxError(cli, "addrestrictappsonwlan <interface> <appUid> ..."); |