from parallels.hosting_check import ServiceInfo, ProcessInfo

# LinuxWebServiceFull includes service which are stopped by default on Plesk and PPA.
LinuxWebServiceFull = ServiceInfo(
    service_type='web', processes=[
        ProcessInfo(names=['nginx', 'httpd'], ports=[80, 443])
    ],
    is_windows=False, check_connection=True
)
LinuxWebServiceBase = ServiceInfo(
    service_type='web', processes=[
        ProcessInfo(names=['httpd', 'apache2'], ports=[80, 443])
    ],
    is_windows=False, check_connection=True
)
LinuxFTPService = ServiceInfo(
    service_type='ftp', processes=[
        ProcessInfo(names=['xinetd'], ports=[21])
    ],
    is_windows=False, check_connection=True
)
LinuxDNSService = ServiceInfo(
    service_type='dns', processes=[
        ProcessInfo(names=['named'], ports=[53])
    ],
    is_windows=False, check_connection=True
)
# LinuxMailServiceFull includes ports which are disabled by default on Plesk and PPA.
LinuxMailServiceFull = ServiceInfo(
    service_type='mail', processes=[
        ProcessInfo(names=['couriertcpd'], ports=[110, 143, 993, 995]),
        ProcessInfo(names=['master', 'qmail-send'], ports=[25, 465, 587]),
        ProcessInfo(names=['xinetd'], ports=[106])
    ],
    is_windows=False, check_connection=True
)
LinuxMailServiceBase = ServiceInfo(
    service_type='mail', processes=[
        ProcessInfo(names=['couriertcpd', 'dovecot'], ports=[110, 143]),
        ProcessInfo(names=['master', 'qmail-send'], ports=[25])
    ],
    is_windows=False, check_connection=True
)
LinuxMysqlService = ServiceInfo(
    service_type='mysql', processes=[
        ProcessInfo(names=['mysqld', 'mariadbd'], ports=[3306])
    ],
    is_windows=False, check_connection=False
)
LinuxPostgresqlService = ServiceInfo(
    service_type='postgresql', processes=[
        ProcessInfo(names=['postmaster', 'postgres'], ports=[5432])
    ],
    is_windows=False, check_connection=False
)
LinuxPleskService = ServiceInfo(
    service_type='plesk', processes=[
        ProcessInfo(names=['sw-cp-server'], ports=[8443])
    ],
    is_windows=False, check_connection=True
)


def create_linux_plesk_service(panel_port):
    return ServiceInfo(
        service_type='plesk', processes=[
            ProcessInfo(names=['sw-cp-server'], ports=[panel_port])
        ],
        is_windows=False, check_connection=True
    )

# WindowsWebServiceFull includes ports which are disabled by default on Plesk and PPA.
WindowsWebServiceFull = ServiceInfo(
    service_type='web', processes=[
        ProcessInfo(names=['w3wp', 'System'], ports=[80, 443])
    ],
    is_windows=True, check_connection=True
)
WindowsWebServiceBase = ServiceInfo(
    service_type='web', processes=[
        ProcessInfo(names=['w3wp', 'System'], ports=[80])
    ],
    is_windows=True, check_connection=True
)
# WindowsFTPServiceFull includes ports which are disabled by default on Plesk and PPA.
WindowsFTPServiceFull = ServiceInfo(
    service_type='ftp', processes=[
        ProcessInfo(names=['svchost'], ports=[21])
    ],
    is_windows=True, check_connection=True
)
WindowsFTPServiceBase = ServiceInfo(
    service_type='ftp', processes=[
        ProcessInfo(names=['svchost'], ports=[])
    ],
    is_windows=True, check_connection=True
)
WindowsDNSService = ServiceInfo(
    service_type='dns', processes=[
        ProcessInfo(names=['dns', 'named'], ports=[53])
    ],
    is_windows=True, check_connection=True
)
# WindowsMailServiceFull includes ports which are disabled by default on Plesk and PPA.
WindowsMailServiceFull = ServiceInfo(
    service_type='mail', processes=[
        ProcessInfo(names=['MEPOPS', 'MEPIMAPS', 'MailService', 'pop3', 'im'], ports=[110, 143, 993, 995]),
        ProcessInfo(names=['MESMTPC', 'MailService', 'smtp'], ports=[25, 465, 587]),
        ProcessInfo(names=['PopPassD'], ports=[106])
    ],
    is_windows=True, check_connection=True
)
WindowsMailServiceBase = ServiceInfo(
    service_type='mail', processes=[
        ProcessInfo(names=['MEPOPS', 'MEPIMAPS', 'MailService', 'pop3', 'im'], ports=[110, 143]),
        ProcessInfo(names=['MESMTPC', 'MailService', 'smtp'], ports=[25])
    ],
    is_windows=True, check_connection=True
)
WindowsMysqlService = ServiceInfo(
    service_type='mysql', processes=[
        ProcessInfo(names=['mysqld', 'mariadbd'], ports=[3306])
    ],
    is_windows=True, check_connection=False
)
# WindowsMssqlServiceFull includes ports which are disabled by default on Plesk and PPA.
WindowsMssqlServiceFull = ServiceInfo(
    service_type='mssql', processes=[
        ProcessInfo(names=['sqlservr'], ports=[1433])
    ],
    is_windows=True, check_connection=False
)
WindowsMssqlServiceBase = ServiceInfo(
    service_type='mssql', processes=[
        ProcessInfo(names=['sqlservr'], ports=[])
    ],
    is_windows=True, check_connection=False
)
WindowsPleskService = ServiceInfo(
    service_type='plesk', processes=[
        ProcessInfo(names=['w3wp', 'System'], ports=[8443])
    ],
    is_windows=True, check_connection=True)


def create_windows_plesk_service(panel_port):
    return ServiceInfo(
        service_type='plesk', processes=[
            ProcessInfo(names=['w3wp', 'System'], ports=[panel_port])
        ],
        is_windows=True, check_connection=True
    )
