🔍 Overview

The Link model represents a URL managed by Link Switcher.

A link can be:

  • monitored for safety (Google Safe Browsing)
  • blocked/unblocked
  • automatically switched to a backup link
  • optionally rotated after a configured time window

Backup links are stored as separate Link records chained via MirrorRule, which also performs traffic switching in Voluum.


📑 Fields

FieldTypeDescription
root_domainstrRoot domain extracted from link (stored for fast lookups).
domainstrDomain extracted from link (stored for fast lookups).
linkURLFieldFull URL (max 2048).
tagstrOptional label for grouping/filters (max 255).
with_rotationboolEnables rotation logic for active links.
rotation_interval_hoursintInterval in hours used by the rotation monitoring task.
statusstrCurrent status (active/backup/blocked/unblocked/ignored).
ownerForeign Key UserOwner of the link.
created_atdatetimeCreation timestamp.
updated_atdatetimeLast update timestamp.
active_started_atdatetimeWhen the link became active (used when with_rotation=True).
blocked_atdatetimeWhen the link was blocked.
reasonstrBlock reason (UNKNOWN, DNS_NOT_RESOLVABLE, Google Safe Browsing threat types, etc.).
unblocked_atdatetimeWhen the link was unblocked.
changed_bystrActor identifier (system / username / etc.).

🔒 Chain helpers

PropertyTypeDescription
next_linkLink (optional)The next backup link in the chain (via MirrorRule.main_link → mirror_link).
prev_linkLink (optional)The previous link in the chain (via MirrorRule.mirror_link → main_link).

🧩 Methods

MethodDescription
find_owners_by_domains(domains)Returns {owner -> set(domains)} for active links matching the given domains.
find_owners_by_root_domains(root_domains)Returns {owner -> set(root_domains)} for active links matching the given root domains.
get_domains_map(status="active", reason_exclude=None)Returns {domain -> [Link...]} for links matching the filters.
get_root_domains_map(status="active", reason_exclude=None)Returns {root_domain -> [Link...]} for links matching the filters.
get_blocked_by_google_domains_map()Returns {root_domain -> [owners...]} for links blocked by Google Safe Browsing reasons.
get_active_links_with_rotation_expired()Returns active links where active_started_at + rotation_interval_hours is in the past.
add_next_link(link, with_rotation=False, rotation_interval_hours=24, tag=None)Creates a BACKUP link and attaches it as next_link via MirrorRule (tag cascades to backups when provided).
set_active(action_by="system")Promotes a BACKUP link to ACTIVE (and sets active_started_at when rotation is enabled).
set_block(reason, with_switch=False, action_by="system")Sets BLOCKED status, sends Telegram notification, optionally triggers a switch to backup.
set_unblock(with_return_to_work=False, action_by="system")Sets UNBLOCKED status and optionally returns the link back to work (see notes).
set_ignored(with_next=False, action_by="system")Marks the link as IGNORED (optionally for the whole chain).
update_with_rotation(with_rotation)Toggles rotation on the link and propagates it to next_link.
return_unblocked_to_work(action_by="system")Re-attaches an unblocked link back into the active/backup chain and marks the old record IGNORED.

🏷 Statuses

StatusDescription
activeThe link is currently active and in use.
backupBackup link (not serving traffic yet).
blockedThe link is blocked and cannot be used.
unblockedThe link was unblocked and can be returned to work.
ignoredHidden/archived record (excluded from most workflows).

🔏 Block Reasons

ReasonDescription
UNKNOWNDefault reason when blocking without a specific cause.
DNS_NOT_RESOLVABLEDomain DNS resolution failed.
BLOCKED_BY_USERManual switch to backup initiated by a user.
ROTATIONRotation system replaced the active link after the configured interval.
MALWAREGoogle Safe Browsing threat type.
SOCIAL_ENGINEERINGGoogle Safe Browsing threat type.
UNWANTED_SOFTWAREGoogle Safe Browsing threat type.
POTENTIALLY_HARMFUL_APPLICATIONGoogle Safe Browsing threat type.
THREAT_TYPE_UNSPECIFIEDGoogle Safe Browsing threat type.

💡 Notes

  • tag can be provided in Admin or XLSX import and is propagated to backup links when the chain is created.
  • When set_block(..., with_switch=True) is used, Link Switcher tries to switch traffic to next_link using MirrorRule.switch and Voluum.
  • When set_unblock(with_return_to_work=True) is used, the system returns the domain back into the chain only for specific reasons (Google Safe Browsing reasons + ROTATION).