scst-proxy 0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of scst-proxy might be problematic. Click here for more details.
- scst_proxy-0.2/MANIFEST.in +2 -0
- scst_proxy-0.2/PKG-INFO +23 -0
- scst_proxy-0.2/scst_proxy/__init__.py +1 -0
- scst_proxy-0.2/scst_proxy/admin.py +13 -0
- scst_proxy-0.2/scst_proxy/apps.py +13 -0
- scst_proxy-0.2/scst_proxy/forms.py +11 -0
- scst_proxy-0.2/scst_proxy/helpers.py +45 -0
- scst_proxy-0.2/scst_proxy/hooks.py +45 -0
- scst_proxy-0.2/scst_proxy/migrations/0001_initial.py +26 -0
- scst_proxy-0.2/scst_proxy/migrations/0002_alter_pluginsettings_options.py +17 -0
- scst_proxy-0.2/scst_proxy/migrations/0003_alter_pluginsettings_options.py +17 -0
- scst_proxy-0.2/scst_proxy/migrations/__init__.py +0 -0
- scst_proxy-0.2/scst_proxy/models.py +30 -0
- scst_proxy-0.2/scst_proxy/signals.py +45 -0
- scst_proxy-0.2/scst_proxy/tasks.py +23 -0
- scst_proxy-0.2/scst_proxy/templates/scst_proxy/main.html +248 -0
- scst_proxy-0.2/scst_proxy/templates/scst_proxy/settings.html +54 -0
- scst_proxy-0.2/scst_proxy/urls.py +9 -0
- scst_proxy-0.2/scst_proxy/views.py +94 -0
- scst_proxy-0.2/scst_proxy.egg-info/PKG-INFO +23 -0
- scst_proxy-0.2/scst_proxy.egg-info/SOURCES.txt +36 -0
- scst_proxy-0.2/scst_proxy.egg-info/dependency_links.txt +1 -0
- scst_proxy-0.2/scst_proxy.egg-info/requires.txt +3 -0
- scst_proxy-0.2/scst_proxy.egg-info/top_level.txt +1 -0
- scst_proxy-0.2/setup.cfg +4 -0
- scst_proxy-0.2/setup.py +33 -0
scst_proxy-0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scst_proxy
|
|
3
|
+
Version: 0.2
|
|
4
|
+
Summary: Register user on SCST proxy server
|
|
5
|
+
Author: Aleksey Misyagin
|
|
6
|
+
Author-email: me@misyagin.ru
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Environment :: Web Environment
|
|
9
|
+
Classifier: Framework :: Django
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Requires-Dist: allianceauth>=2.0.0
|
|
14
|
+
Requires-Dist: requests
|
|
15
|
+
Requires-Dist: django-ipware
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: requires-dist
|
|
21
|
+
Dynamic: summary
|
|
22
|
+
|
|
23
|
+
Provides registration for Alliance Auth users to register their credentials on proxy server.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
default_app_config = 'scst_proxy.apps.ScStProxySettings'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from django.contrib import admin
|
|
2
|
+
from .models import PluginSettings
|
|
3
|
+
|
|
4
|
+
@admin.register(PluginSettings)
|
|
5
|
+
class PluginSettingsAdmin(admin.ModelAdmin):
|
|
6
|
+
list_display = ('api_endpoint','api_key')
|
|
7
|
+
readonly_fields = ('id',)
|
|
8
|
+
|
|
9
|
+
def has_add_permission(self, request):
|
|
10
|
+
return False if self.model.objects.count() > 0 else super().has_add_permission(request)
|
|
11
|
+
|
|
12
|
+
def has_delete_permission(self, request, obj=None):
|
|
13
|
+
return False
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from django.apps import AppConfig
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ScStProxySettings(AppConfig):
|
|
5
|
+
name = 'scst_proxy'
|
|
6
|
+
label = 'scst_proxy'
|
|
7
|
+
default_pesmissions = ('scst_proxy.can_use_proxy')
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def ready(self):
|
|
11
|
+
# Импортируем хуки при загрузке приложения
|
|
12
|
+
from . import hooks # noqa
|
|
13
|
+
import scst_proxy.signals
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from django import forms
|
|
2
|
+
from .models import PluginSettings
|
|
3
|
+
|
|
4
|
+
class PluginSettingsForm(forms.ModelForm):
|
|
5
|
+
class Meta:
|
|
6
|
+
model = PluginSettings
|
|
7
|
+
fields = '__all__'
|
|
8
|
+
widgets = {
|
|
9
|
+
'api_endpoint': forms.URLInput(attrs={'class': 'form-control'}),
|
|
10
|
+
'api_key': forms.NumberInput(attrs={'class': 'form-control'}),
|
|
11
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
from django.http import JsonResponse
|
|
3
|
+
from scst_proxy.models import PluginSettings
|
|
4
|
+
import requests
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def add_menu_items():
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
'label': 'Регистрация прокси',
|
|
11
|
+
'url': 'scst_proxy:main',
|
|
12
|
+
'icon': 'fa-home-icon',
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
def remove_user_api_call(user):
|
|
17
|
+
settings = PluginSettings.get_settings()
|
|
18
|
+
|
|
19
|
+
character_name = user.profile.main_character.character_name
|
|
20
|
+
|
|
21
|
+
# Get API key from user settings (you'll need to implement this)
|
|
22
|
+
try:
|
|
23
|
+
api_key = settings.api_key
|
|
24
|
+
except AttributeError:
|
|
25
|
+
return JsonResponse(
|
|
26
|
+
{'status': 'error', 'message': 'API key not configured'},
|
|
27
|
+
status=400
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Prepare API request
|
|
31
|
+
api_url = settings.api_endpoint + 'delete' # Replace with your API URL
|
|
32
|
+
params = {
|
|
33
|
+
'login': character_name,
|
|
34
|
+
'apikey': api_key
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
response = requests.delete(api_url, json=params, headers={'Content-Type': 'application/json'})
|
|
39
|
+
response.raise_for_status()
|
|
40
|
+
return JsonResponse({'response':response.json()})
|
|
41
|
+
except requests.exceptions.RequestException as e:
|
|
42
|
+
return JsonResponse(
|
|
43
|
+
{'status': 'error', 'message': str(e), 'params': str(params), 'endpoint': api_url},
|
|
44
|
+
status=500
|
|
45
|
+
)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from allianceauth import hooks
|
|
2
|
+
from allianceauth.services.hooks import MenuItemHook, UrlHook, ServicesHook, get_extension_logger
|
|
3
|
+
from django.utils.translation import gettext_lazy as _
|
|
4
|
+
from . import urls
|
|
5
|
+
from scst_proxy.tasks import send_permission_removed_notification_task
|
|
6
|
+
#from django.contrib.auth import get_user_model
|
|
7
|
+
|
|
8
|
+
logger = get_extension_logger(__name__)
|
|
9
|
+
|
|
10
|
+
class ProxyRegMenuItem(MenuItemHook):
|
|
11
|
+
def __init__(self):
|
|
12
|
+
MenuItemHook.__init__(
|
|
13
|
+
self,
|
|
14
|
+
'Прокси-сервер альянса', # Текст в меню
|
|
15
|
+
'fas fa-server', # Иконка Font Awesome (например, fa-rocket)
|
|
16
|
+
'scst_proxy:main', # Имя URL из urls.py
|
|
17
|
+
navactive=['scst_proxy:'], # Подсветка меню при активности
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
class UpdateUserService(ServicesHook):
|
|
21
|
+
def __init__(self):
|
|
22
|
+
ServicesHook.__init__(self)
|
|
23
|
+
self.urlpatterns = self.urlpatterns
|
|
24
|
+
#Изменение State
|
|
25
|
+
def update_groups(self, user):
|
|
26
|
+
permissions = list(user.get_all_permissions())
|
|
27
|
+
if 'scst_proxy.can_use_proxy' not in permissions:
|
|
28
|
+
logger.debug('Пользователь %s больше не имеет доступа к прокси серверу' % user)
|
|
29
|
+
send_permission_removed_notification_task(user)
|
|
30
|
+
else :
|
|
31
|
+
logger.debug('Пользователь %s теперь имеет доступ к прокси серверу' % user)
|
|
32
|
+
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
@hooks.register('menu_item_hook') # Регистрация хука
|
|
36
|
+
def register_menu():
|
|
37
|
+
return ProxyRegMenuItem()
|
|
38
|
+
|
|
39
|
+
@hooks.register("url_hook")
|
|
40
|
+
def register_urls():
|
|
41
|
+
return UrlHook(urls, "scst_proxy", r"^scst_proxy/")
|
|
42
|
+
|
|
43
|
+
@hooks.register('services_hook')
|
|
44
|
+
def register_service():
|
|
45
|
+
return UpdateUserService()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Generated by Django 4.2.23 on 2025-06-27 08:46
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
initial = True
|
|
9
|
+
|
|
10
|
+
dependencies = [
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
operations = [
|
|
14
|
+
migrations.CreateModel(
|
|
15
|
+
name='PluginSettings',
|
|
16
|
+
fields=[
|
|
17
|
+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
18
|
+
('api_endpoint', models.URLField(default='http://proxyreg.ekzoman.ru/', max_length=255, verbose_name='API Endpoint')),
|
|
19
|
+
('api_key', models.CharField(default='YOUR_API_KEY', max_length=255, verbose_name='API ключ')),
|
|
20
|
+
],
|
|
21
|
+
options={
|
|
22
|
+
'verbose_name': 'Настройки плагина',
|
|
23
|
+
'verbose_name_plural': 'Настройки плагина',
|
|
24
|
+
},
|
|
25
|
+
),
|
|
26
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Generated by Django 4.2.23 on 2025-06-28 14:59
|
|
2
|
+
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('scst_proxy', '0001_initial'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterModelOptions(
|
|
14
|
+
name='pluginsettings',
|
|
15
|
+
options={'permissions': [('can_view_page', 'Может смотреть страницу плагина'), ('can_use_proxy', 'Может использовать прокси сервер')], 'verbose_name': 'Настройки плагина', 'verbose_name_plural': 'Настройки плагина'},
|
|
16
|
+
),
|
|
17
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Generated by Django 4.2.23 on 2025-06-28 15:01
|
|
2
|
+
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('scst_proxy', '0002_alter_pluginsettings_options'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterModelOptions(
|
|
14
|
+
name='pluginsettings',
|
|
15
|
+
options={'permissions': [('can_use_proxy', 'Может использовать прокси сервер')], 'verbose_name': 'Настройки плагина', 'verbose_name_plural': 'Настройки плагина'},
|
|
16
|
+
),
|
|
17
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from django.db import models
|
|
2
|
+
|
|
3
|
+
class PluginSettings(models.Model):
|
|
4
|
+
"""Модель для хранения настроек плагина"""
|
|
5
|
+
api_endpoint = models.URLField(
|
|
6
|
+
max_length=255,
|
|
7
|
+
default="http://proxyreg.ekzoman.ru/",
|
|
8
|
+
verbose_name="API Endpoint"
|
|
9
|
+
)
|
|
10
|
+
api_key = models.CharField(
|
|
11
|
+
max_length=255,
|
|
12
|
+
default="YOUR_API_KEY",
|
|
13
|
+
verbose_name="API ключ"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
class Meta:
|
|
17
|
+
verbose_name = "Настройки плагина"
|
|
18
|
+
verbose_name_plural = "Настройки плагина"
|
|
19
|
+
permissions = [
|
|
20
|
+
("can_use_proxy","Может использовать прокси сервер")
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
def __str__(self):
|
|
24
|
+
return "ProxyReg"
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def get_settings(cls):
|
|
28
|
+
"""Получает или создает настройки по умолчанию"""
|
|
29
|
+
obj, created = cls.objects.get_or_create(pk=1)
|
|
30
|
+
return obj
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# permission_tracker/signals.py
|
|
2
|
+
|
|
3
|
+
from django.db.models.signals import m2m_changed
|
|
4
|
+
from django.dispatch import receiver
|
|
5
|
+
from django.contrib.auth.models import User, Permission
|
|
6
|
+
from scst_proxy.models import PluginSettings
|
|
7
|
+
from scst_proxy.tasks import send_permission_removed_notification_task,send_permission_added_notification_task
|
|
8
|
+
import logging
|
|
9
|
+
import requests
|
|
10
|
+
import os
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@receiver(m2m_changed, sender=User.user_permissions.through)
|
|
16
|
+
def user_permissions_changed(sender, instance, action, pk_set, **kwargs):
|
|
17
|
+
"""
|
|
18
|
+
Обработчик сигнала m2m_changed для отслеживания добавления и удаления разрешений пользователя.
|
|
19
|
+
"""
|
|
20
|
+
if action == "post_add":
|
|
21
|
+
# Разрешения добавлены пользователю
|
|
22
|
+
for perm_id in pk_set:
|
|
23
|
+
try:
|
|
24
|
+
permission = Permission.objects.get(pk=perm_id)
|
|
25
|
+
send_permission_change_notification(instance, permission, 'added')
|
|
26
|
+
logger.info(f"Permission '{permission.codename}' added to user '{instance.username}'.")
|
|
27
|
+
except Permission.DoesNotExist:
|
|
28
|
+
logger.error(f"Permission with id {perm_id} does not exist.")
|
|
29
|
+
elif action == "post_remove":
|
|
30
|
+
# Разрешения удалены у пользователя
|
|
31
|
+
for perm_id in pk_set:
|
|
32
|
+
try:
|
|
33
|
+
permission = Permission.objects.get(pk=perm_id)
|
|
34
|
+
send_permission_change_notification(instance, permission, 'removed')
|
|
35
|
+
logger.info(f"Permission '{permission.codename}' removed from user '{instance.username}'.")
|
|
36
|
+
except Permission.DoesNotExist:
|
|
37
|
+
logger.error(f"Permission with id {perm_id} does not exist.")
|
|
38
|
+
|
|
39
|
+
def send_permission_change_notification(user, permission, action):
|
|
40
|
+
data = {
|
|
41
|
+
'user': user,
|
|
42
|
+
'permission': permission
|
|
43
|
+
}
|
|
44
|
+
if action == "removed":
|
|
45
|
+
send_permission_removed_notification_task.delay(data)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from celery import shared_task
|
|
2
|
+
import requests
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
from scst_proxy.helpers import remove_user_api_call
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
@shared_task
|
|
10
|
+
def send_permission_removed_notification_task(user):
|
|
11
|
+
try:
|
|
12
|
+
logger.info(f"Уведомление об изменении состояния пользователя {user.username} отправлено успешно.")
|
|
13
|
+
remove_user_api_call(user)
|
|
14
|
+
except requests.RequestException as e:
|
|
15
|
+
logger.error(f"Ошибка при отправке уведомления об изменении состояния пользователя {user.username}: {e}")
|
|
16
|
+
# Опционально: реализуйте повторные попытки или уведомления администраторов
|
|
17
|
+
|
|
18
|
+
@shared_task
|
|
19
|
+
def send_permission_added_notification_task(user):
|
|
20
|
+
try:
|
|
21
|
+
logger.info(f"Уведомление об изменении состояния пользователя {user.username} отправлено успешно.")
|
|
22
|
+
except requests.RequestException as e:
|
|
23
|
+
logger.error(f"Ошибка при отправке уведомления об изменении состояния пользователя {user.username}: {e}")
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
{% extends "allianceauth/base-bs5.html" %}
|
|
2
|
+
{% load i18n %}
|
|
3
|
+
{% load static %}
|
|
4
|
+
{% block page_title %}{% trans "Подключение чатов" %}{% endblock %}
|
|
5
|
+
{% block header_nav_brand %}
|
|
6
|
+
<a class="nav-link text-white link-light link-underline link-underline-opacity-0" href="{% url 'scst_proxy:main' %}">Прокси-сервер альянса</a>
|
|
7
|
+
{% endblock header_nav_brand %}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
{% block content %}
|
|
11
|
+
<div class="aa-plugin-container proxyreg">
|
|
12
|
+
<div class="panel panel-default pb-4 pt-4 mb-4 container border border-4 border-dark">
|
|
13
|
+
<div class="panel-heading">
|
|
14
|
+
<h4 class="panel-title">{% trans "Вход на прокси-сервер" %}</h3>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="panel-body container">
|
|
17
|
+
<p class="pt-4 pb-2">
|
|
18
|
+
Ваш логин: <input type="text" id="loginInput" disabled value="{{ request.user.profile.main_character.character_name }}" /> <button class="btn bnt-sm btn-secondary" id="loginClipboard"><i class="fa-regular fa-clipboard"></i></button>
|
|
19
|
+
</p>
|
|
20
|
+
<p class="pb-4">
|
|
21
|
+
<button id="apiButton" class="btn btn-primary p-2">{% trans "Получить пароль" %}</button>
|
|
22
|
+
<br />
|
|
23
|
+
<small class="text-warning">
|
|
24
|
+
Пароль не хранится на сервере. Для получения нового пароля нажмите "Получить пароль"
|
|
25
|
+
</small>
|
|
26
|
+
</p>
|
|
27
|
+
<div class="pb-3">
|
|
28
|
+
|
|
29
|
+
<div id="resultMessage" class="alert" style="display: none; margin-top: 15px;"></div>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="panel panel-default pb-4 pt-4 mb-4 container border border-4 border-dark">
|
|
34
|
+
<div class="panel-body container">
|
|
35
|
+
<div class="row">
|
|
36
|
+
<div class="col">
|
|
37
|
+
<a href="https://docs.google.com/document/d/1UIOhdmiSoY2HsmS5bJ_H8H4MbUVT6aC521kmO0pKEiI/edit?usp=sharing" target="_blank">Инструкция по настройке</a>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
<!-- <div class="panel panel-default pt-4 container">
|
|
43
|
+
<div class="panel-heading">
|
|
44
|
+
<h4 class="pb-3">Настройки</h2>
|
|
45
|
+
</div>
|
|
46
|
+
<div class="panel-body">
|
|
47
|
+
|
|
48
|
+
<div class="row">
|
|
49
|
+
<div class="col">
|
|
50
|
+
<p>
|
|
51
|
+
Чтобы починить чаты в Eve Online необходимо прописать прокси сервер в настройках системы.
|
|
52
|
+
</p>
|
|
53
|
+
<p class="pb-4">
|
|
54
|
+
1. Для этого вам необходимо открыть приложение "Блокнот" от имени администратора. Нажмите на меню пуск в левом нижнем углу (в Windows 11 может располагаться посередине).<br/><br/>
|
|
55
|
+
<img src="{% static 'scst_proxy/images/start_icon.png' %}" alt="start_icon" />
|
|
56
|
+
</p>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
<div class="row">
|
|
60
|
+
<div class="col">
|
|
61
|
+
<p class="pb-4">
|
|
62
|
+
2. В поисковой строке введите слово "Блокнот" (notepad на некоторых версиях Windows) . Когда приложение будет найдено, нажмите на него правой кнопкой мыши для вызова контекстного окна. В котором нужно выбрать "Запустить от имени Администратора" <br/>
|
|
63
|
+
<div class="container-fluid">
|
|
64
|
+
<div class="row">
|
|
65
|
+
<div class="col">
|
|
66
|
+
<img src="{% static 'scst_proxy/images/notepad_1.png' %}" alt="start_icon" />
|
|
67
|
+
</div>
|
|
68
|
+
<div class="col">
|
|
69
|
+
<img src="{% static 'scst_proxy/images/notepad_7.jpg' %}" alt="start_icon" />
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</p>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="row">
|
|
77
|
+
<div class="col">
|
|
78
|
+
<p class="pb-4">
|
|
79
|
+
3. В открывшемся окне блокнота нажмите на меню "Файл" и кликните по пункту "Открыть". <br/><br/>
|
|
80
|
+
<img src="{% static 'scst_proxy/images/notepad_2.png' %}" />
|
|
81
|
+
</p>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
<div class="row">
|
|
85
|
+
<div class="col">
|
|
86
|
+
<p class="pb-4">
|
|
87
|
+
4. В диалоговом окне выбора файла введите <b>C:\Windows\System32\drivers\etc\hosts</b> в поле "Имя файла" и нажмите кнопку "Открыть".<br/><br/>
|
|
88
|
+
<img src="{% static 'scst_proxy/images/notepad_3.png' %}" />
|
|
89
|
+
</p>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
<div class="row">
|
|
93
|
+
<div class="col">
|
|
94
|
+
<p class="pb-4">
|
|
95
|
+
5. В открывшемся файле необходимо добавить новую строчку. Установите курсор в самый конец и два раза нажмите на Enter. На новой строке вставьте текст:
|
|
96
|
+
<blockquote class="blockquote border border-2 border-dark p-4">
|
|
97
|
+
<b>89.223.122.157 live.chat.eveonline.com</b>
|
|
98
|
+
</blockquote>
|
|
99
|
+
<br/>
|
|
100
|
+
<br/>
|
|
101
|
+
<img src="{% static 'scst_proxy/images/notepad_4.png' %}" />
|
|
102
|
+
</p>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
<div class="row">
|
|
106
|
+
<div class="col">
|
|
107
|
+
<p class="pb-4">
|
|
108
|
+
6. Для сохраниния изменений нажмите на "Файл" в строке меню блокнота и нажмите на "Сохранить". Если вас попросять подтвердить сохранение, подтвердите. <br /><br/>
|
|
109
|
+
<img src="{% static 'scst_proxy/images/notepad_5.png' %}" />
|
|
110
|
+
</p>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
<div class="row">
|
|
114
|
+
<div class="col">
|
|
115
|
+
<p class="pb-4">
|
|
116
|
+
7. Закройте блокнот (в Windows 11 перед закрытием блокнота нужно закрыть вкладку с редактируемым файлом) и снова откройте блокнот. Откройте файл как описано в пункте 4 и убедитесь, что введенная строка сохранена.
|
|
117
|
+
</p>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
<div class="row">
|
|
121
|
+
<div class="col">
|
|
122
|
+
<p class="pb-4">
|
|
123
|
+
8. Нажмите на кнопку "Регистрация" внизу страницы, чтобы получить доступ к прокси серверу.
|
|
124
|
+
</p>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
<div class="row">
|
|
128
|
+
<div class="col">
|
|
129
|
+
<p class="pb-4">
|
|
130
|
+
9. Закройте блокнот и <b class="text-warning">перезапустите EveOnline!</b> (без перезапуска eve online изменения не будут работать). <b class="text-warning">Перезагружать компьютер не обязательно.</b>
|
|
131
|
+
</p>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
<div class="row">
|
|
135
|
+
<div class="col">
|
|
136
|
+
<p class="pb-4">
|
|
137
|
+
10. Наслаждайтесь игрой с работающими чатами.
|
|
138
|
+
</P>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
<div class="row">
|
|
142
|
+
<div class="col">
|
|
143
|
+
<p class="pb-4">
|
|
144
|
+
В любой момент вы можете вернуть настройки удалив строчку из файла hosts.
|
|
145
|
+
</p>
|
|
146
|
+
<p class="pt-4 pb-4 text-warning">
|
|
147
|
+
Так как у большинства игроков домашний интернет имеет динамический IP-адрес, после его обновления доступ к прокси сервера может пропасть. Если у вас пропал доступ к чатам, снова нажмите кнопку "Регистрация" и перезапустите клиент Eve online. Ваш новый IP адрес будет добавлен, а чаты будут работать.
|
|
148
|
+
</p>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</div> -->
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<div
|
|
156
|
+
class="modal fade"
|
|
157
|
+
id="confirm-dialog"
|
|
158
|
+
tabindex="-1"
|
|
159
|
+
role="dialog"
|
|
160
|
+
aria-labelledby="confirmDialog"
|
|
161
|
+
aria-hidden="true"
|
|
162
|
+
>
|
|
163
|
+
<div class="modal-dialog">
|
|
164
|
+
<div class="modal-content">
|
|
165
|
+
<div class="modal-header">
|
|
166
|
+
<h5 class="modal-title" id="confirmDialog">Пароль обновлен</h5>
|
|
167
|
+
</div>
|
|
168
|
+
<div class="modal-body">
|
|
169
|
+
...
|
|
170
|
+
</div>
|
|
171
|
+
<div class="modal-footer">
|
|
172
|
+
<button
|
|
173
|
+
type="button"
|
|
174
|
+
class="btn btn-secondary"
|
|
175
|
+
data-dismiss="modal"
|
|
176
|
+
data-bs-dismiss="modal"
|
|
177
|
+
>
|
|
178
|
+
Закрыть
|
|
179
|
+
</button>
|
|
180
|
+
<button id="clipboardBtn" type="button" class="btn btn-primary" onclick=""><i class="fa-regular fa-clipboard mr-2"></i> В Буфер</button>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
<script src="https://code.jquery.com/jquery-3.7.1.slim.min.js"
|
|
188
|
+
type="text/javascript"></script>
|
|
189
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
|
|
190
|
+
<script>
|
|
191
|
+
$(document).ready(function() {
|
|
192
|
+
$('#apiButton').click(function() {
|
|
193
|
+
$.ajax({
|
|
194
|
+
url: "{% url 'scst_proxy:call_api' %}",
|
|
195
|
+
method: "POST",
|
|
196
|
+
dataType: "json",
|
|
197
|
+
beforeSend: function(xhr) {
|
|
198
|
+
xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
|
|
199
|
+
$('#apiButton').prop('disabled', true);
|
|
200
|
+
$('#resultMessage').hide();
|
|
201
|
+
},
|
|
202
|
+
success: function(data) {
|
|
203
|
+
var message = "Ваш новый пароль: <b class='text-danger'>" + data.password + "</b><br/><br/>Запомните или запишите свой пароль. Мы не храним ваши пароли.";
|
|
204
|
+
|
|
205
|
+
$('.modal-body').html(message);
|
|
206
|
+
var successModal = new bootstrap.Modal(document.getElementById('confirm-dialog'),{});
|
|
207
|
+
|
|
208
|
+
successModal.show();
|
|
209
|
+
|
|
210
|
+
var btn = document.getElementById('clipboardBtn');
|
|
211
|
+
btn.removeEventListener('click',(e)=>{
|
|
212
|
+
e.preventDefault();
|
|
213
|
+
copyToClipboard(data.password);
|
|
214
|
+
});
|
|
215
|
+
btn.addEventListener('click', (e)=>{
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
copyToClipboard(data.password);
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
error: function(xhr) {
|
|
221
|
+
var message = "Произошла ошибка. Попробуйте еще раз. Если ошибка сохранится, обратитесь к администратору.\r\n" + xhr.message;
|
|
222
|
+
$('#resultMessage').removeClass('alert-success').addClass('alert-danger').text(message).show();
|
|
223
|
+
},
|
|
224
|
+
complete: function() {
|
|
225
|
+
$('#apiButton').prop('disabled', false);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
$('#loginClipboard').click(function(){
|
|
230
|
+
copyToClipboard($('#loginInput').val());
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
async function copyToClipboard(textToCopy) {
|
|
234
|
+
try {
|
|
235
|
+
await navigator.clipboard.writeText(textToCopy);
|
|
236
|
+
console.log('Text copied to clipboard successfully!');
|
|
237
|
+
} catch (err) {
|
|
238
|
+
console.error('Failed to copy text: ', err);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
</script>
|
|
243
|
+
<style>
|
|
244
|
+
.proxyreg img {
|
|
245
|
+
max-height: 400px;
|
|
246
|
+
}
|
|
247
|
+
</style>
|
|
248
|
+
{% endblock %}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{% extends "allianceauth/base-bs5.html" %}
|
|
2
|
+
{% load i18n %}
|
|
3
|
+
|
|
4
|
+
{% block page_title %}{% trans "Конфигурация плагина ProxyReg" %}{% endblock %}
|
|
5
|
+
|
|
6
|
+
{% block content %}
|
|
7
|
+
<div class="col-lg-12">
|
|
8
|
+
<div class="panel panel-default">
|
|
9
|
+
<div class="panel-heading">
|
|
10
|
+
<h3 class="panel-title">{% trans "Конфигурация плагина ProxyReg" %}</h3>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="panel-body">
|
|
13
|
+
{% if messages %}
|
|
14
|
+
<div class="alert alert-success">
|
|
15
|
+
{% for message in messages %}
|
|
16
|
+
{{ message }}
|
|
17
|
+
{% endfor %}
|
|
18
|
+
</div>
|
|
19
|
+
{% endif %}
|
|
20
|
+
|
|
21
|
+
<form method="post">
|
|
22
|
+
{% csrf_token %}
|
|
23
|
+
|
|
24
|
+
<div class="form-group">
|
|
25
|
+
{{ form.api_endpoint.label_tag }}
|
|
26
|
+
{{ form.api_endpoint }}
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div class="row">
|
|
30
|
+
<div class="col-md-6">
|
|
31
|
+
<div class="form-group">
|
|
32
|
+
{{ form.api_key.label_tag }}
|
|
33
|
+
{{ form.api_key }}
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<button type="submit" class="btn btn-primary">
|
|
39
|
+
{% trans "Сохранить настройки" %}
|
|
40
|
+
</button>
|
|
41
|
+
</form>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
{% endblock %}
|
|
46
|
+
|
|
47
|
+
{% block extra_script %}
|
|
48
|
+
<script>
|
|
49
|
+
$(document).ready(function() {
|
|
50
|
+
// Добавьте кастомные скрипты при необходимости
|
|
51
|
+
$('input[type="checkbox"]').addClass('form-check-input');
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
54
|
+
{% endblock %}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
from django.contrib.auth.decorators import login_required, permission_required
|
|
2
|
+
from django.shortcuts import render
|
|
3
|
+
from django.http import JsonResponse
|
|
4
|
+
from django.views.decorators.http import require_http_methods
|
|
5
|
+
import requests
|
|
6
|
+
from ipware import get_client_ip
|
|
7
|
+
from django.template.exceptions import TemplateDoesNotExist
|
|
8
|
+
from django.core.exceptions import PermissionDenied
|
|
9
|
+
from django.contrib import messages
|
|
10
|
+
from django.contrib.auth.models import User
|
|
11
|
+
|
|
12
|
+
from .forms import PluginSettingsForm
|
|
13
|
+
from .models import PluginSettings
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# @login_required
|
|
18
|
+
# @permission_required('scst_proxy.change_pluginsettings')
|
|
19
|
+
# def settings_view(request):
|
|
20
|
+
# try:
|
|
21
|
+
# instance = PluginSettings.objects.get(pk=1)
|
|
22
|
+
# except PluginSettings.DoesNotExist:
|
|
23
|
+
# instance = None
|
|
24
|
+
|
|
25
|
+
# if request.method == 'POST':
|
|
26
|
+
# form = PluginSettingsForm(request.POST, instance=instance)
|
|
27
|
+
# if form.is_valid():
|
|
28
|
+
# form.save()
|
|
29
|
+
# messages.success(request, 'Настройки успешно сохранены!')
|
|
30
|
+
# return redirect('scst_proxy:settings')
|
|
31
|
+
# else:
|
|
32
|
+
# form = PluginSettingsForm(instance=instance)
|
|
33
|
+
|
|
34
|
+
# context = {
|
|
35
|
+
# 'form': form,
|
|
36
|
+
# 'page_title': 'Настройки плагина ProxyReg'
|
|
37
|
+
# }
|
|
38
|
+
# return render(request, 'scst_proxy/settings.html', context)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@login_required
|
|
42
|
+
@permission_required('scst_proxy.can_use_proxy')
|
|
43
|
+
def main_view(request):
|
|
44
|
+
try:
|
|
45
|
+
permissions = list(request.user.get_all_permissions())
|
|
46
|
+
if 'scst_proxy.can_use_proxy' not in permissions:
|
|
47
|
+
raise PermissionDenied("У вас нет доступа к этому плагину")
|
|
48
|
+
|
|
49
|
+
return render(request, 'scst_proxy/main.html')
|
|
50
|
+
except TemplateDoesNotExist as e:
|
|
51
|
+
return JsonResponse(
|
|
52
|
+
{'status': 'error', 'message': 'Template not found'},
|
|
53
|
+
status=500
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@login_required
|
|
59
|
+
@permission_required('scst_proxy.can_use_proxy')
|
|
60
|
+
@require_http_methods(["POST"])
|
|
61
|
+
def call_api_endpoint(request):
|
|
62
|
+
# Get user IP address
|
|
63
|
+
# client_ip, is_routable = get_client_ip(request)
|
|
64
|
+
settings = PluginSettings.get_settings()
|
|
65
|
+
|
|
66
|
+
character_name = request.user.profile.main_character.character_name
|
|
67
|
+
|
|
68
|
+
# Get API key from user settings (you'll need to implement this)
|
|
69
|
+
try:
|
|
70
|
+
api_key = settings.api_key
|
|
71
|
+
except AttributeError:
|
|
72
|
+
return JsonResponse(
|
|
73
|
+
{'status': 'error', 'message': 'API key not configured'},
|
|
74
|
+
status=400
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# Prepare API request
|
|
78
|
+
api_url = settings.api_endpoint + 'add' # Replace with your API URL
|
|
79
|
+
newPassword = User.objects.make_random_password()
|
|
80
|
+
params = {
|
|
81
|
+
'password': newPassword,
|
|
82
|
+
'login': character_name,
|
|
83
|
+
'apikey': api_key
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
try:
|
|
87
|
+
response = requests.post(api_url, json=params, headers={'Content-Type': 'application/json'})
|
|
88
|
+
response.raise_for_status()
|
|
89
|
+
return JsonResponse({'response':response.json(), 'password': newPassword })
|
|
90
|
+
except requests.exceptions.RequestException as e:
|
|
91
|
+
return JsonResponse(
|
|
92
|
+
{'status': 'error', 'message': str(e), 'params': str(params), 'endpoint': api_url},
|
|
93
|
+
status=500
|
|
94
|
+
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scst_proxy
|
|
3
|
+
Version: 0.2
|
|
4
|
+
Summary: Register user on SCST proxy server
|
|
5
|
+
Author: Aleksey Misyagin
|
|
6
|
+
Author-email: me@misyagin.ru
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Environment :: Web Environment
|
|
9
|
+
Classifier: Framework :: Django
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Requires-Dist: allianceauth>=2.0.0
|
|
14
|
+
Requires-Dist: requests
|
|
15
|
+
Requires-Dist: django-ipware
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: requires-dist
|
|
21
|
+
Dynamic: summary
|
|
22
|
+
|
|
23
|
+
Provides registration for Alliance Auth users to register their credentials on proxy server.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
setup.py
|
|
3
|
+
./scst_proxy/__init__.py
|
|
4
|
+
./scst_proxy/admin.py
|
|
5
|
+
./scst_proxy/apps.py
|
|
6
|
+
./scst_proxy/forms.py
|
|
7
|
+
./scst_proxy/helpers.py
|
|
8
|
+
./scst_proxy/hooks.py
|
|
9
|
+
./scst_proxy/models.py
|
|
10
|
+
./scst_proxy/signals.py
|
|
11
|
+
./scst_proxy/tasks.py
|
|
12
|
+
./scst_proxy/urls.py
|
|
13
|
+
./scst_proxy/views.py
|
|
14
|
+
./scst_proxy/migrations/0001_initial.py
|
|
15
|
+
./scst_proxy/migrations/0002_alter_pluginsettings_options.py
|
|
16
|
+
./scst_proxy/migrations/0003_alter_pluginsettings_options.py
|
|
17
|
+
./scst_proxy/migrations/__init__.py
|
|
18
|
+
scst_proxy/__init__.py
|
|
19
|
+
scst_proxy/admin.py
|
|
20
|
+
scst_proxy/apps.py
|
|
21
|
+
scst_proxy/forms.py
|
|
22
|
+
scst_proxy/helpers.py
|
|
23
|
+
scst_proxy/hooks.py
|
|
24
|
+
scst_proxy/models.py
|
|
25
|
+
scst_proxy/tasks.py
|
|
26
|
+
scst_proxy/urls.py
|
|
27
|
+
scst_proxy/views.py
|
|
28
|
+
scst_proxy.egg-info/PKG-INFO
|
|
29
|
+
scst_proxy.egg-info/SOURCES.txt
|
|
30
|
+
scst_proxy.egg-info/dependency_links.txt
|
|
31
|
+
scst_proxy.egg-info/requires.txt
|
|
32
|
+
scst_proxy.egg-info/top_level.txt
|
|
33
|
+
scst_proxy/migrations/0001_initial.py
|
|
34
|
+
scst_proxy/migrations/__init__.py
|
|
35
|
+
scst_proxy/templates/scst_proxy/main.html
|
|
36
|
+
scst_proxy/templates/scst_proxy/settings.html
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
scst_proxy
|
scst_proxy-0.2/setup.cfg
ADDED
scst_proxy-0.2/setup.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='scst_proxy',
|
|
5
|
+
version='0.2',
|
|
6
|
+
package_dir={'': '.'},
|
|
7
|
+
packages=find_packages(),
|
|
8
|
+
include_package_data=True,
|
|
9
|
+
install_requires=[
|
|
10
|
+
'allianceauth>=2.0.0',
|
|
11
|
+
'requests',
|
|
12
|
+
'django-ipware',
|
|
13
|
+
],
|
|
14
|
+
description='Register user on SCST proxy server',
|
|
15
|
+
long_description='Provides registration for Alliance Auth users to register their credentials on proxy server.',
|
|
16
|
+
author='Aleksey Misyagin',
|
|
17
|
+
author_email='me@misyagin.ru',
|
|
18
|
+
classifiers=[
|
|
19
|
+
'Development Status :: 3 - Alpha',
|
|
20
|
+
'Environment :: Web Environment',
|
|
21
|
+
'Framework :: Django',
|
|
22
|
+
'Intended Audience :: Developers',
|
|
23
|
+
'License :: OSI Approved :: MIT License',
|
|
24
|
+
'Programming Language :: Python :: 3',
|
|
25
|
+
],
|
|
26
|
+
package_data={
|
|
27
|
+
'html_templates': [
|
|
28
|
+
'templates/*.*',
|
|
29
|
+
'templates/**/*',
|
|
30
|
+
],
|
|
31
|
+
'scst_proxy':[ 'static/*' ]
|
|
32
|
+
}
|
|
33
|
+
)
|