Fake Mirrors
    Preparing search index...

    Interface TargetRepository

    Represents a target repository.

    interface TargetRepository {
        appendLabel(
            campaignId: string,
            targetId: string,
            label: string,
            lockSecret: string,
        ): Promise<void>;
        create(
            campaignId: string,
            targetId: string,
            accessLevel: "transparent" | "landing",
            donorSecure: boolean,
            donorSub: string,
            donorDomain: string,
            donorPort: number,
            mirrorSecure: boolean,
            mirrorSub: string,
            mirrorPort: number,
            connectTimeout: number,
            simpleTimeout: number,
            streamTimeout: number,
            headersSizeLimit: number,
            bodySizeLimit: number,
            mainPage: string,
            notFoundPage: string,
            faviconIco: string,
            robotsTxt: string,
            sitemapXml: string,
            allowWebSockets: boolean,
            lockSecret: string,
        ): Promise<void>;
        delete(
            campaignId: string,
            targetId: string,
            lockSecret: string,
        ): Promise<void>;
        disable(
            campaignId: string,
            targetId: string,
            lockSecret: string,
        ): Promise<void>;
        enable(
            campaignId: string,
            targetId: string,
            lockSecret: string,
        ): Promise<void>;
        find(mirrorHost: string): Promise<TargetModel | null>;
        findFull(mirrorHost: string): Promise<FullTargetModel | null>;
        list(campaignId: string): Promise<TargetModel[] | null>;
        listFull(campaignId: string): Promise<FullTargetModel[] | null>;
        read(campaignId: string, targetId: string): Promise<TargetModel | null>;
        readFull(
            campaignId: string,
            targetId: string,
        ): Promise<FullTargetModel | null>;
        readHosts(): Promise<TargetHosts>;
        removeLabel(
            campaignId: string,
            targetId: string,
            label: string,
            lockSecret: string,
        ): Promise<void>;
        update(
            campaignId: string,
            targetId: string,
            connectTimeout: number | null | undefined,
            simpleTimeout: number | null | undefined,
            streamTimeout: number | null | undefined,
            headersSizeLimit: number | null | undefined,
            bodySizeLimit: number | null | undefined,
            mainPage: string | null | undefined,
            notFoundPage: string | null | undefined,
            faviconIco: string | null | undefined,
            robotsTxt: string | null | undefined,
            sitemapXml: string | null | undefined,
            allowWebSockets: boolean | null | undefined,
            lockSecret: string,
        ): Promise<void>;
    }

    Implemented by

    Methods

    • Appends a label to a target.

      Parameters

      • campaignId: string

        The ID of the campaign containing the target

      • targetId: string

        The target ID to append label to

      • label: string

        The label to add

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock()

      Returns Promise<void>

      DatabaseError If the campaign does not exist

      DatabaseError If the campaign is not locked

      DatabaseError If the lock secret does not match

      DatabaseError If the target does not exist

    • Creates a new target in the specified campaign.

      The target will be created in a disabled state (isEnabled = false). Use enable() to activate it for traffic routing.

      Parameters

      • campaignId: string

        The ID of the campaign to create the target in

      • targetId: string

        The unique identifier for the new target

      • accessLevel: "transparent" | "landing"

        The access level

      • donorSecure: boolean

        Whether the donor server uses HTTPS

      • donorSub: string

        The donor subdomain

      • donorDomain: string

        The donor domain name

      • donorPort: number

        The donor server port

      • mirrorSecure: boolean

        Whether the mirror uses HTTPS

      • mirrorSub: string

        The mirror subdomain

      • mirrorPort: number

        The mirror server port

      • connectTimeout: number

        Connection timeout

      • simpleTimeout: number

        Simple request timeout

      • streamTimeout: number

        Streaming request timeout

      • headersSizeLimit: number

        Maximum headers size in bytes

      • bodySizeLimit: number

        Maximum body size in bytes

      • mainPage: string

        Custom main page content

      • notFoundPage: string

        Custom 404 page content

      • faviconIco: string

        Custom favicon content

      • robotsTxt: string

        Custom robots.txt content

      • sitemapXml: string

        Custom sitemap.xml content

      • allowWebSockets: boolean

        Whether to allow WebSocket connections

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock()

      Returns Promise<void>

      DatabaseError If the campaign does not exist

      DatabaseError If the campaign is not locked

      DatabaseError If the lock secret does not match

      DatabaseError If a target with the same ID already exists

      DatabaseError If the target donor is already used

      DatabaseError If the target mirror is already used

      DatabaseError If the mirror hostname is already taken

    • Delete a target model by its ID.

      The target must be **disabled **before it can be deleted.

      Parameters

      • campaignId: string

        The ID of the campaign containing the target

      • targetId: string

        The target ID to delete

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock()

      Returns Promise<void>

      DatabaseError If the campaign does not exist

      DatabaseError If the campaign is not locked

      DatabaseError If the lock secret does not match

      DatabaseError If the target does not exist

      DatabaseError If the target is still enabled

    • Disables a target, stopping traffic routing.

      When disabled, requests to the mirror hostname will not be proxied.

      Parameters

      • campaignId: string

        The ID of the campaign containing the target

      • targetId: string

        The target ID to disable

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock()

      Returns Promise<void>

      DatabaseError If the campaign does not exist

      DatabaseError If the campaign is not locked

      DatabaseError If the lock secret does not match

      DatabaseError If the target does not exist

    • Enables a target, making it available for traffic routing.

      When enabled, the mirror hostname becomes active and can be used for proxying requests to the donor server.

      Parameters

      • campaignId: string

        The ID of the campaign containing the target

      • targetId: string

        The target ID to enable

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock()

      Returns Promise<void>

      DatabaseError If the campaign does not exist

      DatabaseError If the campaign is not locked

      DatabaseError If the lock secret does not match

      DatabaseError If the target does not exist

    • Finds a target by its mirror hostname.

      This is the primary lookup method for routing incoming HTTP requests. Given a Host header from a request, it returns the corresponding target model.

      Parameters

      • mirrorHost: string

        The mirror hostname

      Returns Promise<TargetModel | null>

      The target model, or null if no target matches the hostname

    • Lists all targets in a campaign.

      Targets are ordered by creation time (oldest first).

      Parameters

      • campaignId: string

        The ID of the campaign to list targets for

      Returns Promise<TargetModel[] | null>

      An array of target models, or null if the campaign does not exist

    • Removes a label from a target.

      Parameters

      • campaignId: string

        The ID of the campaign containing the target

      • targetId: string

        The target ID to remove label from

      • label: string

        The label to remove

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock()

      Returns Promise<void>

      DatabaseError If the campaign does not exist

      DatabaseError If the campaign is not locked

      DatabaseError If the lock secret does not match

      DatabaseError If the target does not exist

    • Updates specific fields of a target model.

      Parameters

      • campaignId: string

        The ID of the campaign containing the target

      • targetId: string

        The target ID to update

      • connectTimeout: number | null | undefined

        Connection timeout

      • simpleTimeout: number | null | undefined

        Simple request timeout

      • streamTimeout: number | null | undefined

        Streaming request timeout

      • headersSizeLimit: number | null | undefined

        Maximum headers size in bytes

      • bodySizeLimit: number | null | undefined

        Maximum body size in bytes

      • mainPage: string | null | undefined

        Custom main page content

      • notFoundPage: string | null | undefined

        Custom 404 page content

      • faviconIco: string | null | undefined

        Custom favicon content

      • robotsTxt: string | null | undefined

        Custom robots.txt content

      • sitemapXml: string | null | undefined

        Custom sitemap.xml content

      • allowWebSockets: boolean | null | undefined

        Whether to allow WebSocket connections

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock()

      Returns Promise<void>

      DatabaseError If the campaign does not exist

      DatabaseError If the campaign is not locked

      DatabaseError If the lock secret does not match

      DatabaseError If the target does not exist