electronipchecker/src/shared/types.ts

174 lines
3.5 KiB
TypeScript
Raw Normal View History

// Channel Types
export interface Channel {
id: string;
name: string;
url: string;
group?: string;
logo?: string;
isMonitored: boolean;
status: ChannelStatus;
lastCheck?: number;
lastError?: string;
latency?: number;
}
export type ChannelStatus = 'online' | 'offline' | 'error' | 'unknown' | 'checking';
// IP Info Types
export interface IpInfo {
ip: string;
country: string;
countryCode: string;
city?: string;
isp?: string;
timezone?: string;
}
// Monitoring Types
export interface MonitoringResult {
channelId: string;
timestamp: number;
status: ChannelStatus;
latency?: number;
httpStatus?: number;
error?: string;
errorType?: 'TIMEOUT' | 'CONNRESET' | 'CONNREFUSED' | 'HTTP_ERROR' | 'PARSE_ERROR' | 'UNKNOWN';
}
export interface PingResult {
host: string;
alive: boolean;
time?: number;
error?: string;
}
// Notification Types
export type NotificationType = 'windows' | 'telegram' | 'email';
export interface NotificationSettings {
enabled: boolean;
windows: {
enabled: boolean;
};
telegram: {
enabled: boolean;
botToken: string;
chatId: string;
};
email: {
enabled: boolean;
smtpHost: string;
smtpPort: number;
smtpUser: string;
smtpPass: string;
fromEmail: string;
toEmail: string;
};
autoNotify: boolean;
notifyOnPingFail: boolean;
notifyOnStreamError: boolean;
notifyOn404: boolean;
notifyOnConnReset: boolean;
}
// Panel API Types (from MONITOR_API_GUIDE)
export interface PanelConfig {
apiUrl: string;
authToken: string;
monitorId: string;
enabled: boolean;
}
export interface PanelIpInfo {
ip_address: string;
server_id: string;
check_priority: 'high' | 'normal' | 'low';
}
export interface PanelIpPool {
active: PanelIpInfo[];
honeypot: PanelIpInfo[];
}
export interface BurnVote {
ip_address: string;
vote: 'burn' | 'ok' | 'abstain';
reason: string;
evidence: {
check_type: string;
port?: number;
response_time_ms?: number;
error_message?: string;
timestamp: number;
monitor_id: string;
};
}
// App Settings
export interface AppSettings {
general: {
startMinimized: boolean;
minimizeToTray: boolean;
autoStart: boolean;
language: 'tr' | 'en';
};
monitoring: {
pingInterval: number; // seconds
streamCheckInterval: number; // seconds
timeout: number; // ms
retryCount: number;
};
notifications: NotificationSettings;
panel: PanelConfig;
}
// IPC Channel Names
export const IPC_CHANNELS = {
// IP Service
GET_IP_INFO: 'ip:get-info',
// Channel Management
PARSE_M3U8: 'channel:parse-m3u8',
GET_CHANNELS: 'channel:get-all',
UPDATE_CHANNEL: 'channel:update',
SET_MONITORED: 'channel:set-monitored',
// Monitoring
START_MONITORING: 'monitor:start',
STOP_MONITORING: 'monitor:stop',
GET_MONITORING_STATUS: 'monitor:status',
MONITORING_UPDATE: 'monitor:update',
// Ping
PING_HOST: 'ping:host',
// Notifications
SEND_NOTIFICATION: 'notify:send',
TEST_NOTIFICATION: 'notify:test',
// Panel API
PANEL_REGISTER: 'panel:register',
PANEL_GET_IPS: 'panel:get-ips',
PANEL_SEND_VOTE: 'panel:send-vote',
// Settings
GET_SETTINGS: 'settings:get',
SAVE_SETTINGS: 'settings:save',
// Window
MINIMIZE_TO_TRAY: 'window:minimize-tray',
} as const;
// Error Log Entry
export interface ErrorLogEntry {
id: string;
timestamp: number;
channelName: string;
channelId: string;
errorType: string;
errorMessage: string;
httpStatus?: number;
notified: boolean;
}