Add a connection-management feature to YAMA: a toolbar button (after MCP) opens a dialog listing the managed host's TCP/UDP connections, with right-click force-disconnect for IPv4 TCP rows. Client: a new CConnectionsManager enumerates connections via iphlpapi (GetExtendedTcpTable/GetExtendedUdpTable, IPv4+IPv6) and answers the refresh and kill commands over a sub-connection. Server: a new CConnectionsDlg (DialogBase) shows the list with sortable columns and a right-click menu; the title-bar icon reuses the toolbar's connection icon (res/connections.ico). Fix byte order found during review: iphlpapi returns an IPv4 address as a network-order DWORD and the port's low 16 bits in network order, so storing them raw made the dialog show reversed IPv4 addresses and ports. The client now stores addresses as network-order bytes and ports as host order (ntohs), and reverses the conversion on disconnect. Co-Authored-By: deepseek-v4-pro
44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#pragma once
|
|
#include "afxcmn.h"
|
|
#include "IOCPServer.h"
|
|
#include "afxwin.h"
|
|
|
|
// CConnectionsDlg 对话框:展示受管主机当前 TCP/UDP 连接,右键可强制断开 IPv4 TCP 连接。
|
|
|
|
class CConnectionsDlg : public DialogBase
|
|
{
|
|
DECLARE_DYNAMIC(CConnectionsDlg)
|
|
|
|
public:
|
|
CConnectionsDlg(CWnd* pParent = NULL, Server* IOCPServer = NULL, CONTEXT_OBJECT *ContextObject = NULL);
|
|
virtual ~CConnectionsDlg();
|
|
|
|
int ShowConnectionList(void);
|
|
void OnReceiveComplete(void);
|
|
|
|
enum { IDD = IDD_DIALOG_CONNECTIONS };
|
|
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX);
|
|
|
|
DECLARE_MESSAGE_MAP()
|
|
public:
|
|
CListCtrl m_ControlList;
|
|
virtual BOOL OnInitDialog();
|
|
|
|
void DeleteAllItems();
|
|
void SortByColumn(int nColumn);
|
|
afx_msg void OnClose();
|
|
afx_msg void OnNMRClickList(NMHDR *pNMHDR, LRESULT *pResult);
|
|
afx_msg void OnConnectionKill();
|
|
afx_msg void OnConnectionRefresh();
|
|
afx_msg void OnSize(UINT nType, int cx, int cy);
|
|
afx_msg void OnHdnItemclickList(NMHDR *pNMHDR, LRESULT *pResult);
|
|
static int CALLBACK CompareFunction(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
|
|
|
|
CStatic m_Count;
|
|
int m_nRClickItem;
|
|
int m_nSortColumn;
|
|
bool m_bSortAscending;
|
|
};
|