Skip to content

Commit

Permalink
encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
vikilpet committed Apr 15, 2020
1 parent c5b7602 commit a54116a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
8 changes: 6 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Web Knocking
# Web Knocking for MikroTik
![Screenshot](https://user-images.githubusercontent.com/43970835/79135939-3172f900-7dc1-11ea-9d26-f923c47d47b6.png)

## How it works
Expand All @@ -12,6 +12,7 @@ For users who need to connect outside the office, we give a link like this:

http://100.100.1.2:2020/access_SeCrEtCoDe

It is possible to support other vendors' devices with help of [netmiko](https://github.com/ktbyers/netmiko), but have MikroTik-s only.

## Setup
### Option 1: EXE
Expand All @@ -27,6 +28,8 @@ Just download the project.
## Usage
Change settings in *settings.ini* to your own.

It is highly recommended to add your IP address to *safe_hosts* to avoid blacklisting during testing.

Forward a port in the router from the settings to the computer where Web Knocking is running.

Enable API access on the router from this computer (*ip services - api-ssl* or *api*).
Expand All @@ -36,5 +39,6 @@ For white and black lists, make the rules according to your needs. For example,
/ip firewall nat add src-address-list=white_list in-interface=WAN \
dst-port=80 action=dst-nat to-addresses=192.168.0.10 to-ports=80

## Project Support
## Support project
- [Donate via PayPal](https://www.paypal.me/vikil)
- Correct my mistakes
8 changes: 6 additions & 2 deletions readme_ru.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Web Knocking
# Web Knocking для MikroTik
![Screenshot](https://user-images.githubusercontent.com/43970835/79136043-63845b00-7dc1-11ea-9e30-6d4e011c2bc3.png)

## Как это работает
Expand All @@ -12,6 +12,7 @@

http://100.100.1.2:2020/access_SeCrEtCoDe

Теоретически можно сделать и для других устройств с помощью [netmiko](https://github.com/ktbyers/netmiko), но мне не на чём проверить.

## Установка
### Вариант 1: EXE
Expand All @@ -27,6 +28,8 @@
## Использование
Измените настройки в settings.ini на свои.

Очень рекомендуется добавить свой IP адрес в *safe_hosts*, чтобы при тестировании не занести себя в чёрный список.

Пробросьте в маршрутизаторе порт из настроек на компьютер, на котором запущен Web Knocking.

Включите в маршрутизаторе доступ к API с этого компьютера (*ip services - api-ssl* или *api*).
Expand All @@ -37,4 +40,5 @@
dst-port=80 action=dst-nat to-addresses=192.168.0.10 to-ports=80

## Помощь проекту
- Расскажите о проекте друзьям.
- Расскажите о проекте друзьям
- Присылайте отчёты об ошибках
2 changes: 1 addition & 1 deletion resources.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Language():
class Language():
def __init__(self, language:str='en'):
if language == 'ru':
lang_str = dictionary_ru
Expand Down
16 changes: 13 additions & 3 deletions web_knocking.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@
language=en
; Web server listening port on PC:
port=8008
white_list=WHITE_LIST
black_list=BLACK_LIST
; White and black list names on your device:
white_list=FRIENDS
black_list=BAD_GUYS
; Hosts that can't be blacklisted
; Add your own IP address to make sure that you
; won't be blacklisted
safe_hosts=127.0.0.1, 100.64.1.2
; Logging to a file:
log_file=false

[Device]
; Your router settings
host=192.168.88.1
; For non-SSL connection to MikroTik
; use 8728:
port=8729
username=admin
password=admin
; Use SSL connection:
secure=True

[Users]
Expand All @@ -24,4 +35,3 @@ secure=True
; Examples:
John Smith=Ye7gfV
John Doe=n5Bwif 2030-4-6
Jane=DaTe 2020-4-1
5 changes: 2 additions & 3 deletions web_knocking.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# 2020.04.01

import configparser
import logging
Expand Down Expand Up @@ -88,7 +87,7 @@ def __init__(s, keep_setting_case:bool=False):
config.optionxform = str
try:
with open(INI_FILE, 'tr'
, encoding='utf-8-sig') as fd:
, encoding='utf-8') as fd:
config.read_file(fd)
except FileNotFoundError:
log_error(f'{INI_FILE} file not found'
Expand Down Expand Up @@ -559,7 +558,7 @@ def main():
logger.addHandler(fh)
if os.path.exists('files/index.html'):
with open('files/index.html'
, encoding='utf-8-sig') as fd:
, encoding='utf-8') as fd:
sett.html = fd.read()
else:
sett.html = resources.HTML_DEFAULT
Expand Down

0 comments on commit a54116a

Please sign in to comment.