Giter Site home page Giter Site logo

fbxosctrl's People

Contributors

afer92 avatar bousqi avatar kif avatar skimpax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fbxosctrl's Issues

Hmac problem again?

Hello, thanks for your script.

I've already used your script on other machines, but I need to use it on an older nas with Alt -f software as SE.
I've installed SimpleJson and request, and registrated with success .

But when I try to reboot the Freebox, I've this error :

[root@dns320]# ./fbxosctrl.py -c fbxosctrl_registration.txt --reboot
Traceback (most recent call last):
File "./fbxosctrl.py", line 510, in
rc = cli.cmdExec(sys.argv[1:])
File "./fbxosctrl.py", line 497, in cmdExec
return self.dispatch(argsdict.keys())
File "./fbxosctrl.py", line 504, in dispatch
return self.cmdCallbacks.get(cmd, self.parser.print_help)()
File "./fbxosctrl.py", line 342, in reboot
self._login()
File "./fbxosctrl.py", line 162, in _login
h = hmac.new(apptoken, key, sha1)
File "build/bdist.linux-armv5tel/egg/hmac.py", line 133, in new
return HMAC(key, msg, digestmod)
File "build/bdist.linux-armv5tel/egg/hmac.py", line 72, in init
self.outer.update(key.translate(trans_5C))
TypeError: character mapping must return integer, None or unicode

my python version is 2.7.2-4.

Thanks for your help.

Debian 11 fix

J'utilisais cette appli pendant 3 ans avec Debian 9 Stretch, qui utilise Python 3.5, mais lors du passage sur Debian 11 l'appli a cessé de fonctionner, étant préciser que la version de Python3 a changé:

python3 -V

Python 3.9.2
En cherchant des solutions, j'ai modifié le programme tout légèrement:

diff fbxosctrl.py fbxosctrl.py.v.2.4.4.before.py.3.9.fix

157,158c157,158
< self._reg_params.get('track_id') != None and
< self._reg_params.get('app_token') != ''):

            self._reg_params.get('track_id') is not None and
            self._reg_params.get('app_token') is not ''):

244c244
< elif self._resp.get('success') != True and self._resp['success'] != False:

    elif self._resp.get('success') is not True and self._resp['success'] is not False:

304c304
< if self._session_token != None:

    if self._session_token is not None:

321c321
< timeout=timeout if timeout != None else self._http_timeout)

        timeout=timeout if timeout is not None else self._http_timeout)

345c345
< timeout=timeout if timeout != None else self._http_timeout)

        timeout=timeout if timeout is not None else self._http_timeout)

369c369
< timeout=timeout if timeout != None else self._http_timeout)

        timeout=timeout if timeout is not None else self._http_timeout)

714c714
< if resp.result['has_sfp'] != True and resp.result['sfp_present'] != True:

    if resp.result['has_sfp'] is not True and resp.result['sfp_present'] is not True:

727c727
< if resp.result['link'] != True:

    if resp.result['link'] is not True:

Apres cette modification tout refonctionne comme avant 👍

./fbxosctrl.py --version

fbxosctrl.py 2.4.4

Il faut peut-être modifier les sources sur ce git.

HMAC problem ?

This is the code I get when I try to set the Wifi off :

>>> setWifiOff
>>> _setWifiStatus
>>> _login
>>> isRegistered
>>> hasRegistrationParams
>>> _loadRegistrationParams: file: fbxosctrl_registration.txt
>>> getRegistrationStatus
>>> hasRegistrationParams
http://mafreebox.freebox.fr/api/v1/login/authorize/1
GET url: http://mafreebox.freebox.fr/api/v1/login/authorize/1
GET response: {"success":true,"result":{"status":"granted","challenge":"rF7pTgHX8flUZ9TFqa6+Yr\/+0N0yCO3M","password_salt":"KpDAqdZIgRdDX7IXKqkFccT4taWFZ8+Y"}}
GET url: http://mafreebox.freebox.fr/api/v1/login/
GET response: {"success":true,"result":{"logged_in":false,"challenge":"rF7pTgHX8flUZ9TFqa6+Yr\/+0N0yCO3M","password_salt":"KpDAqdZIgRdDX7IXKqkFccT4taWFZ8+Y"}}
challenge: rF7pTgHX8flUZ9TFqa6+Yr/+0N0yCO3M, apptoken: a4a7K0S5iPwboVUaWmfalFd3/pHoYYawljcAvhHzRBn3dZD9gM6rAX5lMXZRElZI
Traceback (most recent call last):
  File "fbxosctrl.py", line 467, in <module>
    rc = cli.cmdExec(sys.argv[1:])
  File "fbxosctrl.py", line 454, in cmdExec
    return self.dispatch(argsdict.keys())
  File "fbxosctrl.py", line 461, in dispatch
    return self.cmdCallbacks.get(cmd, self.parser.print_help)()
  File "fbxosctrl.py", line 397, in setWifiOff
    return self._setWifiStatus(False)
  File "fbxosctrl.py", line 212, in _setWifiStatus
    self._login()
  File "fbxosctrl.py", line 159, in _login
    h = hmac.new(apptoken, key, sha1)
  File "/volume1/@appstore/python/lib/python2.7/hmac.py", line 133, in new
    return HMAC(key, msg, digestmod)
  File "/volume1/@appstore/python/lib/python2.7/hmac.py", line 72, in __init__
    self.outer.update(key.translate(trans_5C))
TypeError: character mapping must return integer, None or unicode

bridged mode ...

Hi,

I tried your application as apparently it does everything I need but it does not work in bridged mode as Zeroconf is unable to retrieve the conf.

Is it supposed to work ?

Unable to register app: OSError: [Errno 101] Network is unreachable

OK, this is clearly my misunderstanding, this is my 1st (well 2nd-failed) attempt at using this repo.
Whilst "OSError: [Errno 101] Network is unreachable" sounds embarassingly like I'm doing something dumb I've no idea what that is.

I'm running on Ubuntu18.04 LTS, with Python 3.6.5.

I'm running command
/usr/bin/python3 ./fbxosctrl.py --regapp
to use the system Python which has zeroconf module installed.

It obtains the addressing and certificate files OK.
Below are the contents of the addressing file: (with my hostname masked)

{
 "api_base_url": "/api/",
 "api_domain": "****.fbxos.fr",
 "api_version": "6.0",
 "port": "46736",
 "protocol": "https"
}

but then the script barfs with a network connection issue - see below.
I tried pinging the address which works fine.
I tried nmap on the port which says it's filtered (didn't really expect anything else!).

What's happening?
What should I do to fix/debug?

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
OSError: [Errno 101] Network is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 852, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 284, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7fdd4e56dba8>: Failed to establish a new connection: [Errno 101] Network is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='sd4gr1i9.fbxos.fr', port=46736): Max retries exceeded with url: /api/v6/login/authorize/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fdd4e56dba8>: Failed to establish a new connection: [Errno 101] Network is unreachable',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./fbxosctrl.py", line 1204, in <module>
    rc = cli.dispatch(args)
  File "./fbxosctrl.py", line 1192, in dispatch
    return self._cmd_handlers.get(cmd, self._parser.print_help)()
  File "./fbxosctrl.py", line 564, in register_app
    resp = self._http.post(uri, data=data, no_login=True)
  File "./fbxosctrl.py", line 369, in post
    timeout=timeout if timeout is not None else self._http_timeout)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 520, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 630, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 508, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='sd4gr1i9.fbxos.fr', port=46736): Max retries exceeded with url: /api/v6/login/authorize/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fdd4e56dba8>: Failed to establish a new connection: [Errno 101] Network is unreachable',))

mdns_info empty

Hello,
when i launch the registration, i have this error :
Traceback (most recent call last):
File "fbxosctrl.py", line 960, in
ctrl.conf.load()
File "fbxosctrl.py", line 125, in load
self._load_addressing_params()
File "fbxosctrl.py", line 182, in _load_addressing_params
self._addr_params['protocol'] = 'https' if mdns_info.properties[b'https_available'].decode() else 'http'
AttributeError: 'NoneType' object has no attribute 'properties

mdns_info is empty, and i don't know why.

Thanks

Readme Typos

I just upgraded to last version, and I noticed typos in the readme file, dependencies section :

DependEncies:
python3-requests and python3-zeroconf You can use this command to install them:
apt-get install python3-requests python3-zeroconf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.