Skip to content

Commit

Permalink
net-pos: make api_url configurable
Browse files Browse the repository at this point in the history
now its possible tzo set an own api_url in config:

[main.plugins.net-pos]
enabled = true
api_key = "test"
api_url = "https://location.services.my-own.com/v1/geolocate?key={api}"
  • Loading branch information
xenDE authored Jan 18, 2020
1 parent 0764304 commit 9339ecb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pwnagotchi/plugins/default/net-pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 7,18 @@
import pwnagotchi.plugins as plugins
from pwnagotchi.utils import StatusFile

MOZILLA_API_URL = 'https://location.services.mozilla.com/v1/geolocate?key={api}'


class NetPos(plugins.Plugin):
__author__ = 'zenzen san'
__version__ = '2.0.2'
__version__ = '2.0.3'
__license__ = 'GPL3'
__description__ = """Saves a json file with the access points with more signal
whenever a handshake is captured.
When internet is available the files are converted in geo locations
using Mozilla LocationService """

API_URL = 'https://location.services.mozilla.com/v1/geolocate?key={api}'

def __init__(self):
self.report = StatusFile('/root/.net_pos_saved', data_format='json')
self.skip = list()
Expand All @@ -29,9 29,11 @@ def on_loaded(self):
if 'api_key' not in self.options or ('api_key' in self.options and not self.options['api_key']):
logging.error("NET-POS: api_key isn't set. Can't use mozilla's api.")
return

if 'api_url' in self.options:
self.API_URL = self.options['api_url']
self.ready = True
logging.info("net-pos plugin loaded.")
logging.debug(f"net-pos: use api_url: {self.API_URL}");

def _append_saved(self, path):
to_save = list()
Expand Down Expand Up @@ -124,7 126,7 @@ def _get_netpos(self, agent):
return netpos

def _get_geo_data(self, path, timeout=30):
geourl = MOZILLA_API_URL.format(api=self.options['api_key'])
geourl = self.API_URL.format(api=self.options['api_key'])

try:
with open(path, "r") as json_file:
Expand Down

0 comments on commit 9339ecb

Please sign in to comment.