Skip to content

Commit

Permalink
Merge pull request #119 from Iam54r1n4/dev-patch6
Browse files Browse the repository at this point in the history
Fix show sub link as profile url
  • Loading branch information
hiddify-com authored Feb 5, 2024
2 parents 33f5230 + 8b1e1ad commit 260b57a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion hiddifypanel/models/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def get_panel_domains(always_add_ip=False, always_add_all_domains=False) -> List
if len(domains) == 0 and request:
domains = [Domain(domain=request.host)]
if len(domains) == 0 or always_add_ip:
from hiddifypanel.panel import hiddify
domains += [Domain(domain=hutils.network.get_ip_str(4))]
return domains

Expand Down
10 changes: 5 additions & 5 deletions hiddifypanel/panel/commercial/restapi/v2/user/mtproxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ class MTProxiesAPI(MethodView):

@app.output(MtproxySchema(many=True))
def get(self):
# check mtproxie is enable
if not hconfig(ConfigEnum.telegram_enable):
abort(status_code=404, message="Telegram mtproxy is not enable")
# get domains
c = get_common_data(g.account.uuid, 'new')

if not c['telegram_enable']:
abort(status_code=404, message="Telegram mtproxy is not enable")

dtos = []
# TODO: Remove duplicated domains mapped to a same ipv4 and v6
for d in c['domains']:
if d.mode not in [DomainType.direct, DomainType.relay]:
if d.mode not in [DomainType.direct, DomainType.relay, DomainType.old_xtls_direct]:
continue

# make mtproxy link
Expand Down
6 changes: 4 additions & 2 deletions hiddifypanel/panel/user/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,15 @@ def get_domain_information(no_domain=False, filter_domain=None, alternative=None
d.domain = d.domain.replace("*", hutils.random.get_random_string(5, 15))
if len(domains) == 0:
domains = [Domain(id=0, domain=alternative, mode=DomainType.direct, cdn_ip='', show_domains=[], child_id=0)]
domains[0].has_auto_ip=True
domains[0].has_auto_ip = True

return domains, has_auto_cdn


def get_common_data(user_uuid, mode, no_domain=False, filter_domain=None):
# uuid_secret=str(uuid.UUID(user_secret))
domains, has_auto_cdn = get_domain_information(no_domain, filter_domain, urlparse(request.base_url).hostname)
domains = [d for d in domains if d.mode != DomainType.fake and d.mode != DomainType.reality]
db_domain = domains[0]
domain = db_domain.domain
user: User = g.account if g.account.uuid == user_uuid else User.by_uuid(f'{user_uuid}')
Expand All @@ -319,6 +320,7 @@ def get_common_data(user_uuid, mode, no_domain=False, filter_domain=None):
user_ip = hutils.network.auto_ip_selector.get_real_user_ip()
asn = hutils.network.auto_ip_selector.get_asn_short_name(user_ip)
profile_title = f'{db_domain.alias or db_domain.domain} {user.name}'
profile_url = hiddify.get_account_panel_link(user, request.host)
if has_auto_cdn and asn != 'unknown':
profile_title += f" {asn}"

Expand Down Expand Up @@ -349,7 +351,7 @@ def get_common_data(user_uuid, mode, no_domain=False, filter_domain=None):
"asn": asn,
"country": hutils.network.auto_ip_selector.get_country(user_ip),
'has_auto_cdn': has_auto_cdn,
'profile_url': hiddify.get_account_panel_link(user, domain)
'profile_url': profile_url
}


Expand Down

0 comments on commit 260b57a

Please sign in to comment.