#include "config.h"
#include "transport.h"

#ifndef SNI_HOSTNAME
    #define SNI_HOSTNAME "myserver.local" // Default SNI hostname; override in config.h if needed
#endif

Transport* InitTransport(char* domain, unsigned short port) {
    #if USE_SCHANNEL
        return InitSchannelTransport(domain, port, SNI_HOSTNAME);
    #elif USE_HTTP
        return InitHTTPTransport(domain, port);
    #else
        return InitTCPTransport(domain, port);
    #endif
}

void CleanupTransport(Transport* transport) {
    if (transport) {
        transport->cleanup(transport->handle);
        free(transport);
    }
}

char* GetNextDomain() {
    unsigned short currentDomain = 0;
    char* domain = server_domains[currentDomain];
    currentDomain = (currentDomain + 1) % domain_count;
    return domain;
}