Skip to content

Commit

Permalink
Merge pull request #1118 from erfjab/Extra-config
Browse files Browse the repository at this point in the history
add External config to import into v2ray format sub
  • Loading branch information
SaintShit authored Jul 19, 2024
2 parents fb44035 + cf649fd commit df028eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ UVICORN_PORT = 8000
# SUB_UPDATE_INTERVAL = "12"
# RANDOMIZE_SUBSCRIPTION_CONFIGS = True

## External config to import into v2ray format subscription
# EXTERNAL_CONFIG = "config://..."

# SQLALCHEMY_DATABASE_URL = "sqlite:///db.sqlite3"

## Custom text for STATUS_TEXT variable
Expand Down
7 changes: 5 additions & 2 deletions app/subscription/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
from . import *

if TYPE_CHECKING:
from app.models.user import UserResponse
from app.models.user import UserResponse, UserStatus

from config import (ACTIVE_STATUS_TEXT, DISABLED_STATUS_TEXT,
EXPIRED_STATUS_TEXT, LIMITED_STATUS_TEXT,
ONHOLD_STATUS_TEXT, RANDOMIZE_SUBSCRIPTION_CONFIGS)
ONHOLD_STATUS_TEXT, RANDOMIZE_SUBSCRIPTION_CONFIGS,
EXTERNAL_CONFIG)

SERVER_IP = get_public_ip()
SERVER_IPV6 = get_public_ipv6()
Expand Down Expand Up @@ -151,6 +152,8 @@ def generate_subscription(

if config_format == "v2ray":
config = "\n".join(generate_v2ray_links(**kwargs))
if user.status == UserStatus.active:
config += "\n" + EXTERNAL_CONFIG
elif config_format == "clash-meta":
config = generate_clash_subscription(**kwargs, is_meta=True)
elif config_format == "clash":
Expand Down
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
USER_AGENT_TEMPLATE = config("USER_AGENT_TEMPLATE", default="user_agent/default.json")
GRPC_USER_AGENT_TEMPLATE = config("GRPC_USER_AGENT_TEMPLATE", default="user_agent/grpc.json")

EXTERNAL_CONFIG = config("EXTERNAL_CONFIG", default=False, cast=str)

USE_CUSTOM_JSON_DEFAULT = config("USE_CUSTOM_JSON_DEFAULT", default=False, cast=bool)
USE_CUSTOM_JSON_FOR_V2RAYN = config("USE_CUSTOM_JSON_FOR_V2RAYN", default=False, cast=bool)
Expand Down

0 comments on commit df028eb

Please sign in to comment.