aboutsummaryrefslogtreecommitdiffstats
path: root/package/kernel/gpio-button-hotplug/src
Commit message (Expand)AuthorAgeFilesLines
* gpio-button-hotplug: remove duplicate logging textPetr Štetiar2020-03-081-3/+3
* gpio-button-hotplug: add volume button handlingChuanhong Guo2019-08-081-0/+2
* gpio-button-hotplug: unify polled and interrupt codeDavid Bauer2019-07-141-65/+76
* gpio-button-hotplug: fix 4.19 build breakage on malta/be64Petr Štetiar2019-06-171-0/+1
* gpio-button-hotplug: gpio-keys: fix always missing first eventPetr Štetiar2019-06-091-9/+2
* gpio-button-hotplug: fix wrong initial seen valuePetr Štetiar2019-06-091-0/+3
* gpio-button-hotplug: use pr_debug and pr_errPetr Štetiar2019-06-091-17/+6
* gpio-button-hotplug: support interrupt propertiesChristian Lamparter2019-05-311-21/+93
* gpio-button-hotplug: add KEY_POWER2 handlingAlan Swanson2019-05-301-0/+1
* gpio-button-hotplug: leave platform_device.dev.platform_data untouchedFurong Xu2017-08-211-2/+1
* gpio-button-hotplug: add more buttonsMathias Kresin2016-11-271-15/+24
* treewide: replace nbd@openwrt.org with nbd@nbd.nameFelix Fietkau2016-06-071-3/+3
* kernel: gpio-button-hotplug: Add missing ONESHOT flag to threaded IRQ requestJohn Crispin2016-03-031-1/+1
* kernel: gpio-button-hotplug: update to use threaded irq'sJohn Crispin2016-02-121-8/+5
* gpio-button-hotplug: handle EPROBE_DEFER and other errorsHauke Mehrtens2015-07-261-5/+15
* gpio-button-hotplug: remove #ifdef CONFIG_HOTPLUG, it is gone in newer kernel...Felix Fietkau2014-05-231-7/+0
* gpio-button-hotplug: add wwan buttonHauke Mehrtens2014-01-141-0/+1
* gpio-button-hotplug: fix crash on removeJonas Gorski2013-12-171-1/+1
* gpio-button-hotplug: add irq mode to driverJohn Crispin2013-12-091-94/+176
* gpio-button-hotplug: add support for sliding switchesJohn Crispin2013-11-111-12/+8
* gpio-button-hotplug: add support for power buttonsJohn Crispin2013-10-281-0/+1
* gpio-button-hotplug: debounce the initial button state, the first reads at bo...Felix Fietkau2013-08-051-2/+4
* gpio-button-hotplug: cleanup, fix compiler warningFelix Fietkau2013-08-031-4/+2
* gpio-button-hotplug: fix active_low handling, possibly broken in r37643Felix Fietkau2013-08-031-8/+9
* gpio-button-hotplug: use gpio_button_get_value() to initialize last_state.John Crispin2013-08-011-1/+1
* gpio-button-hotplug: use gpio_button_get_value() to fetch state.John Crispin2013-08-011-4/+1
* gpio-button-hotplug: add inline function gpio_button_get_value().John Crispin2013-08-011-0/+9
* gpio-button-hotplug: add support for EV_SWLuka Perkov2013-07-021-7/+21
* gpio-button-hotplug: improve gpio button debouncing, verify state changes ove...Felix Fietkau2013-06-291-6/+8
* packages: clean up the package folderJohn Crispin2013-06-212-0/+565
>.splitlines() return dict([re.findall(r'([^:]+): (.*)', line)[0] for line in state]) def enable_proxy_for_service(self, service): print('Enabling proxy on {}...'.format(service)) for subcommand in ['-setwebproxy', '-setsecurewebproxy']: self.run_networksetup_command( subcommand, service, '127.0.0.1', str( self.port)) def disable_proxy_for_service(self, service): print('Disabling proxy on {}...'.format(service)) for subcommand in ['-setwebproxystate', '-setsecurewebproxystate']: self.run_networksetup_command(subcommand, service, 'Off') def interface_name_to_service_name_map(self): order = self.run_networksetup_command('-listnetworkserviceorder') mapping = re.findall( r'\(\d+\)\s(.*)$\n\(.*Device: (.+)\)$', order, re.MULTILINE) return dict([(b, a) for (a, b) in mapping]) def run_command_with_input(self, command, input): popen = subprocess.Popen( command, stdin=subprocess.PIPE, stdout=subprocess.PIPE) (stdout, stderr) = popen.communicate(input) return stdout def primary_interace_name(self): scutil_script = 'get State:/Network/Global/IPv4\nd.show\n' stdout = self.run_command_with_input('/usr/sbin/scutil', scutil_script) interface, = re.findall(r'PrimaryInterface\s*:\s*(.+)', stdout) return interface def primary_service_name(self): return self.interface_name_to_service_name_map()[ self.primary_interace_name()] def proxy_enabled_for_service(self, service): return self.proxy_state_for_service(service)['Enabled'] == 'Yes' def toggle_proxy(self): new_state = not self.proxy_enabled_for_service( self.primary_service_name()) for service_name in self.connected_service_names(): if self.proxy_enabled_for_service(service_name) and not new_state: self.disable_proxy_for_service(service_name) elif not self.proxy_enabled_for_service(service_name) and new_state: self.enable_proxy_for_service(service_name) def connected_service_names(self): scutil_script = 'list\n' stdout = self.run_command_with_input('/usr/sbin/scutil', scutil_script) service_ids = re.findall(r'State:/Network/Service/(.+)/IPv4', stdout) service_names = [] for service_id in service_ids: scutil_script = 'show Setup:/Network/Service/{}\n'.format( service_id) stdout = self.run_command_with_input( '/usr/sbin/scutil', scutil_script) service_name, = re.findall(r'UserDefinedName\s*:\s*(.+)', stdout) service_names.append(service_name) return service_names def wrap_mitmproxy(self): with self.wrap_proxy(): cmd = ['mitmproxy', '-p', str(self.port)] if self.extra_arguments: cmd.extend(self.extra_arguments) subprocess.check_call(cmd) def wrap_honeyproxy(self): with self.wrap_proxy(): popen = subprocess.Popen('honeyproxy.sh') try: popen.wait() except KeyboardInterrupt: popen.terminate() @contextlib.contextmanager def wrap_proxy(self): connected_service_names = self.connected_service_names() for service_name in connected_service_names: if not self.proxy_enabled_for_service(service_name): self.enable_proxy_for_service(service_name) yield for service_name in connected_service_names: if self.proxy_enabled_for_service(service_name): self.disable_proxy_for_service(service_name) @classmethod def ensure_superuser(cls): if os.getuid() != 0: print('Relaunching with sudo...') os.execv('/usr/bin/sudo', ['/usr/bin/sudo'] + sys.argv) @classmethod def main(cls): parser = argparse.ArgumentParser( description='Helper tool for OS X proxy configuration and mitmproxy.', epilog='Any additional arguments will be passed on unchanged to mitmproxy.') parser.add_argument( '-t', '--toggle', action='store_true', help='just toggle the proxy configuration') # parser.add_argument('--honeyproxy', action='store_true', help='run honeyproxy instead of mitmproxy') parser.add_argument( '-p', '--port', type=int, help='override the default port of 8080', default=8080) args, extra_arguments = parser.parse_known_args() wrapper = cls(port=args.port, extra_arguments=extra_arguments) if args.toggle: wrapper.toggle_proxy() # elif args.honeyproxy: # wrapper.wrap_honeyproxy() else: wrapper.wrap_mitmproxy() if __name__ == '__main__': Wrapper.ensure_superuser() Wrapper.main()