scst-proxy 0.2__py2.py3-none-any.whl

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/__init__.py ADDED
@@ -0,0 +1 @@
1
+ default_app_config = 'scst_proxy.apps.pluginConfig'
scst_proxy/admin.py ADDED
@@ -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
scst_proxy/apps.py ADDED
@@ -0,0 +1,10 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class pluginConfig(AppConfig):
5
+ name = 'scst_proxy'
6
+ label = 'scst_proxy'
7
+
8
+ def ready(self):
9
+ # Импортируем хуки при загрузке приложения
10
+ from . import hooks # noqa
scst_proxy/forms.py ADDED
@@ -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
+ }
scst_proxy/helpers.py ADDED
@@ -0,0 +1,9 @@
1
+
2
+ def add_menu_items():
3
+ return [
4
+ {
5
+ 'label': 'Регистрация прокси',
6
+ 'url': 'scst_proxy:main',
7
+ 'icon': 'fa-home-icon',
8
+ }
9
+ ]
scst_proxy/hooks.py ADDED
@@ -0,0 +1,36 @@
1
+ from allianceauth import hooks
2
+ from allianceauth.services.hooks import MenuItemHook, UrlHook
3
+ from django.utils.translation import gettext_lazy as _
4
+ from . import urls
5
+
6
+ class ProxyRegMenuItem(MenuItemHook):
7
+ def __init__(self):
8
+ MenuItemHook.__init__(
9
+ self,
10
+ 'Прокси-сервер альянса', # Текст в меню
11
+ 'fas fa-server', # Иконка Font Awesome (например, fa-rocket)
12
+ 'scst_proxy:main', # Имя URL из urls.py
13
+ navactive=['scst_proxy:'], # Подсветка меню при активности
14
+ )
15
+
16
+
17
+ @hooks.register('menu_item_hook') # Регистрация хука
18
+ def register_menu():
19
+ return ProxyRegMenuItem()
20
+
21
+ @hooks.register("url_hook")
22
+ def register_urls():
23
+ return UrlHook(urls, "scst_proxy", r"^scst_proxy/")
24
+
25
+ # class SettingsMenuItem(MenuItemHook):
26
+ # def __init__(self):
27
+ # super().__init__(
28
+ # 'Настройки плагина',
29
+ # 'fas fa-cog',
30
+ # 'scst_proxy:settings',
31
+ # navactive=['scst_proxy:settings'],
32
+ # )
33
+
34
+ # @hooks.register('menu_item_hook')
35
+ # def register_menu():
36
+ # return SettingsMenuItem()
@@ -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
+ ]
File without changes
scst_proxy/models.py ADDED
@@ -0,0 +1,27 @@
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
+
20
+ def __str__(self):
21
+ return "ProxyReg"
22
+
23
+ @classmethod
24
+ def get_settings(cls):
25
+ """Получает или создает настройки по умолчанию"""
26
+ obj, created = cls.objects.get_or_create(pk=1)
27
+ return obj
scst_proxy/tasks.py ADDED
File without changes
scst_proxy/urls.py ADDED
@@ -0,0 +1,9 @@
1
+ from django.urls import path
2
+ from . import views
3
+
4
+ app_name = 'scst_proxy'
5
+
6
+ urlpatterns = [
7
+ path('', views.main_view, name='main'),
8
+ path('call_api/', views.call_api_endpoint, name='call_api')
9
+ ]
scst_proxy/views.py ADDED
@@ -0,0 +1,91 @@
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
+ def main_view(request):
43
+ try:
44
+ if not request.user.groups.filter(name='Verified').exists():
45
+ raise PermissionDenied("У вас нет доступа к этому плагину")
46
+
47
+ return render(request, 'scst_proxy/main.html')
48
+ except TemplateDoesNotExist as e:
49
+ return JsonResponse(
50
+ {'status': 'error', 'message': 'Template not found'},
51
+ status=500
52
+ )
53
+
54
+
55
+
56
+ @login_required
57
+ @require_http_methods(["POST"])
58
+ def call_api_endpoint(request):
59
+ # Get user IP address
60
+ client_ip, is_routable = get_client_ip(request)
61
+ settings = PluginSettings.get_settings()
62
+
63
+ character_name = request.user.profile.main_character.character_name
64
+
65
+ # Get API key from user settings (you'll need to implement this)
66
+ try:
67
+ api_key = settings.api_key
68
+ except AttributeError:
69
+ return JsonResponse(
70
+ {'status': 'error', 'message': 'API key not configured'},
71
+ status=400
72
+ )
73
+
74
+ # Prepare API request
75
+ api_url = settings.api_endpoint + 'add' # Replace with your API URL
76
+ newPassword = User.objects.make_random_password()
77
+ params = {
78
+ 'password': newPassword,
79
+ 'login': character_name,
80
+ 'apikey': api_key
81
+ }
82
+
83
+ try:
84
+ response = requests.post(api_url, json=params, headers={'Content-Type': 'application/json'})
85
+ response.raise_for_status()
86
+ return JsonResponse({'response':response.json(), 'password': newPassword })
87
+ except requests.exceptions.RequestException as e:
88
+ return JsonResponse(
89
+ {'status': 'error', 'message': str(e), 'params': str(params), 'endpoint': api_url},
90
+ status=500
91
+ )
@@ -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,16 @@
1
+ scst_proxy/__init__.py,sha256=mFc-dvOypVjI6MoVJH1i4Ge0sBkR6CGybd18myqYe0c,51
2
+ scst_proxy/admin.py,sha256=_iqbz1I2Z_ar2ICNxsxToO_x0fB4y7rUji-23J9lL4A,459
3
+ scst_proxy/apps.py,sha256=E5ThNe0wrV1OC-7Cr_9TG69YzM3e_w5S1J2y3nzDTqQ,264
4
+ scst_proxy/forms.py,sha256=tDSrTEdSP9LRfaVdZeniUuBGiAiVaihF9fUbwBrbu48,369
5
+ scst_proxy/helpers.py,sha256=iTCpTy6TikTwzkBNzO6KtvSw2q6_QimjOOweBFM0A4I,195
6
+ scst_proxy/hooks.py,sha256=Ji1Mu4oauU4P4W1J6zKCZRZctF_G5uwCTN98qKjTwFM,1204
7
+ scst_proxy/models.py,sha256=9X4PkHri-vyhevTxRcZUDbH9dnz5Qkinh3dmkcvVegw,834
8
+ scst_proxy/tasks.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ scst_proxy/urls.py,sha256=v5RwNw-SXfP2HfxnE9EYk0GZ4heySJleqyi79NvJ878,200
10
+ scst_proxy/views.py,sha256=tqqPNB8VJUwQGSgspjdYWhnsiq2cM_f-lcN3bo_ZpT4,3021
11
+ scst_proxy/migrations/0001_initial.py,sha256=HceOHfRkj6A-3-0hIrr3jszfozvrfWdxQk7AO_U__Ro,868
12
+ scst_proxy/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ scst_proxy-0.2.dist-info/METADATA,sha256=ttZgPvjB1KnDbaRlBZZwg1Sg5VpZ0ejLY2VYqHnf_8s,713
14
+ scst_proxy-0.2.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
15
+ scst_proxy-0.2.dist-info/top_level.txt,sha256=gIYSbMVmo4-EmMmJfDwLT31QANXvaeAmf5YPEkRGwRk,11
16
+ scst_proxy-0.2.dist-info/RECORD,,
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py2-none-any
5
+ Tag: py3-none-any
6
+
@@ -0,0 +1 @@
1
+ scst_proxy