From ae536ee70d5afe3afa5378476cdcec2e9ff29a60 Mon Sep 17 00:00:00 2001 From: ibrokemypie Date: Mon, 5 Jun 2017 09:44:07 +1000 Subject: [PATCH 1/3] [modules/github] Use header for token Doesnt allow sniffers to get the access token from url. Closes #104 --- bumblebee/modules/github.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bumblebee/modules/github.py b/bumblebee/modules/github.py index 187d266..35f5725 100644 --- a/bumblebee/modules/github.py +++ b/bumblebee/modules/github.py @@ -44,7 +44,7 @@ class Module(bumblebee.engine.Module): self._count = 0 return - notifications = requests.get("https://api.github.com/notifications?access_token={}".format(token)).text + notifications = requests.get("https://api.github.com/notifications", headers={"Authorization":"token "+format(token)}).text unread = 0 for notification in json.loads(notifications): if "unread" in notification and notification["unread"] == True: From c5a155561806bfb4997f5987d8e94d1dd31d672e Mon Sep 17 00:00:00 2001 From: Robert Sacks Date: Mon, 5 Jun 2017 03:30:23 -0400 Subject: [PATCH 2/3] [modules/publicip] Added region option to publicip module and switched to 'requests' package --- bumblebee/modules/publicip.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bumblebee/modules/publicip.py b/bumblebee/modules/publicip.py index bb2f4ab..f6576eb 100644 --- a/bumblebee/modules/publicip.py +++ b/bumblebee/modules/publicip.py @@ -1,9 +1,14 @@ """Displays public IP address +Requires the following python packages: + * requests + +Parameters: + * publicip.region: us-central (default), us-east, us-west, uk, de, pl, nl """ try: - from urllib2 import urlopen + from requests import get except ImportError: pass @@ -15,7 +20,14 @@ class Module(bumblebee.engine.Module): super(Module, self).__init__(engine, config, bumblebee.output.Widget(full_text=self.public_ip) ) - + self._avail_regions = {"us-east":"http://l2.io/ip", + "us-central":"http://whatismyip.akamai.com", + "us-west":"http://ipv4bot.whatismyipaddress.com", + "pl":"http://ip.42.pl/raw", + "de":"http://myexternalip.com/raw", + "nl":"http://tnx.nl/ip", + "uk":"http://ident.me"} + self._region = self.parameter("region", "us-central") self._ip = "" @@ -24,7 +36,7 @@ class Module(bumblebee.engine.Module): def update(self, widgets): try: - self._ip = urlopen("http://ip.42.pl/raw").read() + self._ip = get(self._avail_regions[self._region]).text.rstrip() except Exception: self._ip = "Not Connected" From a167ac93818555a529072b5a50d1fbdf2722baa1 Mon Sep 17 00:00:00 2001 From: Robert Sacks Date: Mon, 5 Jun 2017 03:53:44 -0400 Subject: [PATCH 3/3] [modules/publicip] Added option to use own ip retrieval service --- bumblebee/modules/publicip.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/publicip.py b/bumblebee/modules/publicip.py index f6576eb..99899fe 100644 --- a/bumblebee/modules/publicip.py +++ b/bumblebee/modules/publicip.py @@ -5,6 +5,7 @@ Requires the following python packages: Parameters: * publicip.region: us-central (default), us-east, us-west, uk, de, pl, nl + * publicip.service: web address that returns plaintext ip address (ex. "http://l2.io/ip") """ try: @@ -28,6 +29,7 @@ class Module(bumblebee.engine.Module): "nl":"http://tnx.nl/ip", "uk":"http://ident.me"} self._region = self.parameter("region", "us-central") + self._service = self.parameter("service", "") self._ip = "" @@ -36,7 +38,11 @@ class Module(bumblebee.engine.Module): def update(self, widgets): try: - self._ip = get(self._avail_regions[self._region]).text.rstrip() + if self._service: + self.address = self._service + else: + self.address = self._avail_regions[self._region] + self._ip = get(self.address).text.rstrip() except Exception: - self._ip = "Not Connected" + self._ip = "No Connection"