Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make a basic mac filter ? #203

Closed
TheLime1 opened this issue Jan 6, 2024 · 10 comments
Closed

How to make a basic mac filter ? #203

TheLime1 opened this issue Jan 6, 2024 · 10 comments
Labels
question Further information is requested

Comments

@TheLime1
Copy link
Contributor

TheLime1 commented Jan 6, 2024

For exmple i want to filter 3A:7B:56:2C:9D:E7

@Salamek Salamek added the question Further information is requested label Jan 6, 2024
@Salamek
Copy link
Owner

Salamek commented Jan 6, 2024

It should be in https://github.com/Salamek/huawei-lte-api/blob/1a28bbf96eec2480b04e03b46584f67ffeb9dc11/huawei_lte_api/api/Security.py#L15

But i see only adding url filter implemented right now...

@TheLime1
Copy link
Contributor Author

TheLime1 commented Jan 6, 2024

i used this

def set_multi_basic_settings(self, clients: list) -> SetResponseType:
"""
:param clients: list of dicts with format {'wifihostname': hostname,'WifiMacFilterMac': mac}
"""
return self._session.post_set('wlan/multi-basic-settings', {
'Ssids': {
'Ssid': clients
},
'WifiRestart': 1
})

this is my code

from huawei_lte_api.Client import Client
from huawei_lte_api.Connection import Connection
from huawei_lte_api.api.WLan import WLan

with Connection('http://admin:THE_Lime1@192.168.1.1/') as connection:
    client = Client(connection)
    wlan = client.wlan
    clients = [{'wifihostname': 'B612-233',
                'WifiMacFilterMac': '66:77:88:99:AA:BB'}]

    response = wlan.set_multi_macfilter_settings(clients)

and it give me

Traceback (most recent call last):
  File "c:\Users\everp\Documents\GitHub\fixbox\getmac.py", line 11, in <module>
    response = wlan.set_multi_macfilter_settings(clients)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\api\WLan.py", line 146, in set_multi_macfi
lter_settings                                                                                                                                 return self._session.post_set('wlan/multi-macfilter-settings', {
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\Session.py", line 215, in post_set        
    self._post(endpoint, data, refresh_csrf, prefix, is_encrypted, is_json)
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\Session.py", line 34, in wrapped
    return fn(*args, **kw)
           ^^^^^^^^^^^^^^^
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\Session.py", line 254, in _post
    response_data = cast(str, self._check_response_status(self._process_response_data(response)))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\Session.py", line 156, in _check_response_
status                                                                                                                                        raise error_code_to_exception.get(error_code, ResponseErrorException)(
huawei_lte_api.exceptions.ResponseErrorException: 9003: Unknown

@TheLime1
Copy link
Contributor Author

TheLime1 commented Jan 6, 2024

when i click save
image

@TheLime1
Copy link
Contributor Author

TheLime1 commented Jan 6, 2024

and using this

from huawei_lte_api.Client import Client
from huawei_lte_api.Connection import Connection
from huawei_lte_api.api.WLan import WLan

with Connection('http://admin:THE_Lime1@192.168.1.1/') as connection:
    client = Client(connection)
    wlan = client.wlan
    wlan.set_mac_filter('myhostname', '66:77:88:99:AA:BB')

give

tHub/fixbox/getmac.py                                                                                                                     Traceback (most recent call last):
  File "c:\Users\everp\Documents\GitHub\fixbox\getmac.py", line 8, in <module>
    wlan.set_mac_filter('myhostname', '66:77:88:99:AA:BB')
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\api\WLan.py", line 159, in set_mac_filter 
    return self._session.post_set('wlan/mac-filter', OrderedDict((
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\Session.py", line 215, in post_set        
    self._post(endpoint, data, refresh_csrf, prefix, is_encrypted, is_json)
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\Session.py", line 34, in wrapped
    return fn(*args, **kw)
           ^^^^^^^^^^^^^^^
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\Session.py", line 254, in _post
    response_data = cast(str, self._check_response_status(self._process_response_data(response)))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\Session.py", line 156, in _check_response_
status                                                                                                                                        raise error_code_to_exception.get(error_code, ResponseErrorException)(
huawei_lte_api.exceptions.ResponseErrorNotSupportedException: 100002: No support

@TheLime1
Copy link
Contributor Author

TheLime1 commented Jan 6, 2024

i see a pattern with this erorr code
https://github.com/Salamek/huawei-lte-api/issues?q=is%3Aissue+is%3Aopen+100002

@Salamek
Copy link
Owner

Salamek commented Jan 6, 2024

You have used wrong function, your router is using set_multi_macfilter_settings call, try that

@TheLime1
Copy link
Contributor Author

TheLime1 commented Jan 6, 2024

You have used wrong function, your router is using set_multi_macfilter_settings call, try that

this is my code

from huawei_lte_api.Client import Client
from huawei_lte_api.Connection import Connection
from huawei_lte_api.api.WLan import WLan

with Connection('http://admin:THE_Lime1@192.168.1.1/') as connection:
    client = Client(connection)
    wlan = client.wlan
    clients = [{'wifihostname': 'B612-233',
                'WifiMacFilterMac': '66:77:88:99:AA:BB'}]

    response = wlan.set_multi_macfilter_settings(clients)

and it give me

Traceback (most recent call last):
  File "c:\Users\everp\Documents\GitHub\fixbox\getmac.py", line 11, in <module>
    response = wlan.set_multi_macfilter_settings(clients)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\api\WLan.py", line 146, in set_multi_macfi
lter_settings                                                                                                                                 return self._session.post_set('wlan/multi-macfilter-settings', {
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\Session.py", line 215, in post_set        
    self._post(endpoint, data, refresh_csrf, prefix, is_encrypted, is_json)
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\Session.py", line 34, in wrapped
    return fn(*args, **kw)
           ^^^^^^^^^^^^^^^
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\Session.py", line 254, in _post
    response_data = cast(str, self._check_response_status(self._process_response_data(response)))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\everp\AppData\Local\Programs\Python\Python311\Lib\site-packages\huawei_lte_api\Session.py", line 156, in _check_response_
status                                                                                                                                        raise error_code_to_exception.get(error_code, ResponseErrorException)(
huawei_lte_api.exceptions.ResponseErrorException: 9003: Unknown

@Salamek
Copy link
Owner

Salamek commented Jan 6, 2024

Is that correct payload? Check what is your router sending in browser debug tools "Payload" card...

@Salamek
Copy link
Owner

Salamek commented Jan 7, 2024

Closed by #204

@Salamek Salamek closed this as completed Jan 7, 2024
@Salamek
Copy link
Owner

Salamek commented Jan 7, 2024

Released in 1.8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants