mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-08-21 14:37:16 +00:00
Xray works
This commit is contained in:
32
vpn/migrations/0015_remove_old_xray_models.py
Normal file
32
vpn/migrations/0015_remove_old_xray_models.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# Generated manually to properly remove old Xray models
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('vpn', '0014_alter_xraycoreserver_client_hostname_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# Remove unique_together first to avoid field reference issues
|
||||
migrations.AlterUniqueTogether(
|
||||
name='xrayinbound',
|
||||
unique_together=None,
|
||||
),
|
||||
|
||||
# Remove old models completely
|
||||
migrations.DeleteModel(
|
||||
name='XrayClient',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='XrayInbound',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='XrayInboundServer',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='XrayCoreServer',
|
||||
),
|
||||
]
|
127
vpn/migrations/0016_add_new_xray_models.py
Normal file
127
vpn/migrations/0016_add_new_xray_models.py
Normal file
@@ -0,0 +1,127 @@
|
||||
# Generated manually to add new Xray models
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('vpn', '0015_remove_old_xray_models'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='XrayConfiguration',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('grpc_address', models.CharField(default='127.0.0.1:10085', help_text='Xray gRPC API address (host:port)', max_length=255)),
|
||||
('default_client_hostname', models.CharField(help_text='Default hostname for client connections', max_length=255)),
|
||||
('stats_enabled', models.BooleanField(default=True, help_text='Enable traffic statistics')),
|
||||
('cert_renewal_days', models.IntegerField(default=60, help_text='Renew certificates X days before expiration')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Xray Configuration',
|
||||
'verbose_name_plural': 'Xray Configuration',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Credentials',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(help_text='Descriptive name for these credentials', max_length=100, unique=True)),
|
||||
('cred_type', models.CharField(choices=[('cloudflare', 'Cloudflare API'), ('dns_provider', 'DNS Provider'), ('email', 'Email SMTP'), ('other', 'Other')], help_text='Type of credentials', max_length=20)),
|
||||
('credentials', models.JSONField(help_text="Credentials data (e.g., {'api_token': '...', 'email': '...'})")),
|
||||
('description', models.TextField(blank=True, help_text='Description of what these credentials are used for')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Credentials',
|
||||
'verbose_name_plural': 'Credentials',
|
||||
'ordering': ['cred_type', 'name'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Certificate',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('domain', models.CharField(help_text='Domain name for this certificate', max_length=255, unique=True)),
|
||||
('certificate_pem', models.TextField(help_text='Certificate in PEM format')),
|
||||
('private_key_pem', models.TextField(help_text='Private key in PEM format')),
|
||||
('cert_type', models.CharField(choices=[('self_signed', 'Self-Signed'), ('letsencrypt', "Let's Encrypt"), ('custom', 'Custom')], help_text='Type of certificate', max_length=20)),
|
||||
('expires_at', models.DateTimeField(help_text='Certificate expiration date')),
|
||||
('auto_renew', models.BooleanField(default=True, help_text='Automatically renew certificate before expiration')),
|
||||
('last_renewed', models.DateTimeField(blank=True, help_text='Last renewal timestamp', null=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('credentials', models.ForeignKey(blank=True, help_text="Credentials for Let's Encrypt (Cloudflare API)", null=True, on_delete=django.db.models.deletion.SET_NULL, to='vpn.credentials')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Certificate',
|
||||
'verbose_name_plural': 'Certificates',
|
||||
'ordering': ['domain'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Inbound',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(help_text='Unique identifier for this inbound', max_length=100, unique=True)),
|
||||
('protocol', models.CharField(choices=[('vless', 'VLESS'), ('vmess', 'VMess'), ('trojan', 'Trojan'), ('shadowsocks', 'Shadowsocks')], help_text='Protocol type', max_length=20)),
|
||||
('port', models.IntegerField(help_text='Port to listen on')),
|
||||
('network', models.CharField(choices=[('tcp', 'TCP'), ('ws', 'WebSocket'), ('grpc', 'gRPC'), ('http', 'HTTP/2'), ('quic', 'QUIC')], default='tcp', help_text='Transport protocol', max_length=20)),
|
||||
('security', models.CharField(choices=[('none', 'None'), ('tls', 'TLS'), ('reality', 'REALITY')], default='none', help_text='Security type', max_length=20)),
|
||||
('domain', models.CharField(blank=True, help_text='Client connection domain', max_length=255)),
|
||||
('full_config', models.JSONField(default=dict, help_text='Complete configuration for creating inbound on server')),
|
||||
('listen_address', models.CharField(default='0.0.0.0', help_text='IP address to listen on', max_length=45)),
|
||||
('enable_sniffing', models.BooleanField(default=True, help_text='Enable protocol sniffing')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('certificate', models.ForeignKey(blank=True, help_text='Certificate for TLS', null=True, on_delete=django.db.models.deletion.SET_NULL, to='vpn.certificate')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Inbound',
|
||||
'verbose_name_plural': 'Inbounds',
|
||||
'ordering': ['protocol', 'port'],
|
||||
'unique_together': {('port', 'listen_address')},
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='SubscriptionGroup',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(help_text="Group name (e.g., 'VLESS Premium', 'VMess Basic')", max_length=100, unique=True)),
|
||||
('description', models.TextField(blank=True, help_text='Description of this subscription group')),
|
||||
('is_active', models.BooleanField(default=True, help_text='Whether this group is active')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('inbounds', models.ManyToManyField(blank=True, help_text='Inbounds included in this group', to='vpn.inbound')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Subscription Group',
|
||||
'verbose_name_plural': 'Subscription Groups',
|
||||
'ordering': ['name'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='UserSubscription',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('active', models.BooleanField(default=True, help_text='Whether this subscription is active')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('subscription_group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='vpn.subscriptiongroup')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='xray_subscriptions', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'User Subscription',
|
||||
'verbose_name_plural': 'User Subscriptions',
|
||||
'ordering': ['user__username', 'subscription_group__name'],
|
||||
'unique_together': {('user', 'subscription_group')},
|
||||
},
|
||||
),
|
||||
]
|
@@ -0,0 +1,52 @@
|
||||
# Generated by Django 5.1.7 on 2025-08-07 13:56
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('vpn', '0016_add_new_xray_models'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='XrayServerV2',
|
||||
fields=[
|
||||
('server_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='vpn.server')),
|
||||
('client_hostname', models.CharField(help_text='Client connection hostname (what users see in their configs)', max_length=255)),
|
||||
('api_address', models.CharField(default='127.0.0.1:10085', help_text='Xray gRPC API address for management', max_length=255)),
|
||||
('api_enabled', models.BooleanField(default=True, help_text='Enable gRPC API for user management')),
|
||||
('stats_enabled', models.BooleanField(default=True, help_text='Enable traffic statistics collection')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Xray Server v2',
|
||||
'verbose_name_plural': 'Xray Servers v2',
|
||||
},
|
||||
bases=('vpn.server',),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='server',
|
||||
name='server_type',
|
||||
field=models.CharField(choices=[('Outline', 'Outline'), ('Wireguard', 'Wireguard'), ('xray_core', 'Xray Core'), ('xray_v2', 'Xray Server v2')], editable=False, max_length=50),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ServerInbound',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('active', models.BooleanField(default=True, help_text='Whether this inbound is active on the server')),
|
||||
('deployed_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('deployment_config', models.JSONField(blank=True, default=dict, help_text='Server-specific deployment configuration')),
|
||||
('inbound', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='deployed_servers', to='vpn.inbound')),
|
||||
('server', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='deployed_inbounds', to='vpn.server')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Server Inbound Deployment',
|
||||
'verbose_name_plural': 'Server Inbound Deployments',
|
||||
'ordering': ['server__name', 'inbound__name'],
|
||||
'unique_together': {('server', 'inbound')},
|
||||
},
|
||||
),
|
||||
]
|
@@ -0,0 +1,28 @@
|
||||
# Generated by Django 5.1.7 on 2025-08-07 14:07
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('vpn', '0017_xrayserverv2_alter_server_server_type_serverinbound'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='certificate',
|
||||
name='certificate_pem',
|
||||
field=models.TextField(blank=True, help_text="Certificate in PEM format (auto-generated for Let's Encrypt)"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='certificate',
|
||||
name='expires_at',
|
||||
field=models.DateTimeField(blank=True, help_text='Certificate expiration date (auto-filled after generation)', null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='certificate',
|
||||
name='private_key_pem',
|
||||
field=models.TextField(blank=True, help_text="Private key in PEM format (auto-generated for Let's Encrypt)"),
|
||||
),
|
||||
]
|
18
vpn/migrations/0019_certificate_acme_email.py
Normal file
18
vpn/migrations/0019_certificate_acme_email.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.7 on 2025-08-07 14:49
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('vpn', '0018_alter_certificate_certificate_pem_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='certificate',
|
||||
name='acme_email',
|
||||
field=models.EmailField(blank=True, help_text="Email address for ACME account registration (required for Let's Encrypt)", max_length=254),
|
||||
),
|
||||
]
|
18
vpn/migrations/0020_alter_inbound_full_config.py
Normal file
18
vpn/migrations/0020_alter_inbound_full_config.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.7 on 2025-08-07 15:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('vpn', '0019_certificate_acme_email'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='inbound',
|
||||
name='full_config',
|
||||
field=models.JSONField(blank=True, default=dict, help_text='Complete configuration for creating inbound on server (auto-generated if empty)'),
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user