CLIENT MANAGER & SERVER MANAGER画面へのNEW項目追加したい。

SoftEther VPN に関するご質問はこのフォーラムにお気軽にご投稿ください。
Post Reply
hiura
Posts: 141
Joined: Wed Mar 10, 2021 1:56 am

CLIENT MANAGER & SERVER MANAGER画面へのNEW項目追加したい。

Post by hiura » Tue May 02, 2023 1:02 am

CLIENT MANAGER & SERVER MANAGER画面へのNEW項目追加したい。

高度な通信設定画面にNEW項目(BindLocalIP)を追加したいのですが、ソースコードのどこをどのように修正すればいいのでしょうか?。
内部処理は下記のように修正しています。画面側をどのように修正すればいいのか不明です。

<<<変更箇所>>>
###############################################################
1.Connection.h


// Client Options
// Do not change item size or order and only add new items at the end!
// See comments in struct SETTING (SMInner.h)
struct CLIENT_OPTION
{
IP BindLocalIP; // Bind local IP <--------①項目追加
};

###############################################################
2.SMInner.h

// Connection setting
// Do not change item size or order
// Size must be kept at 13420 (use Reserved to adjust for new items)
typedef struct SETTING
{
// UCHAR Reserved[10240 - sizeof(UINT) * 8 - SHA1_SIZE - HTTP_CUSTOM_HEADER_MAX_SIZE - MAX_HOST_NAME_LEN - 1]; // Reserved area
UCHAR Reserved[10240-16-4 - sizeof(UINT) * 8 - SHA1_SIZE - HTTP_CUSTOM_HEADER_MAX_SIZE - MAX_HOST_NAME_LEN - 1]; // Reserved area <--------②サイズ変更
} SETTING;


###############################################################
3.Client.c

// Write the client option
void CiWriteClientOption(FOLDER *f, CLIENT_OPTION *o)
{
CfgAddIp(f, "BindLocalIP", &o->BindLocalIP); // BindLocalIP <--------③項目追加
}

// Read the client option
CLIENT_OPTION *CiLoadClientOption(FOLDER *f)
{
CfgGetIp(f, "BindLocalIP", &o->BindLocalIP); // BindLocalIP <--------④項目追加
}

void OutRpcClientOption(PACK *p, CLIENT_OPTION *c)
{
PackAddIp(p, "BindLocalIP", &c->BindLocalIP); // BindLocalIP <--------⑤項目追加
}

// CLIENT_OPTION
void InRpcClientOption(CLIENT_OPTION *c, PACK *p)
{
PackGetIp(p, "BindLocalIP", &c->BindLocalIP); // BindLocalIP <--------⑥項目追加
}


<<<添付:ソースコード(内部処理)>>>

Code: Select all

###############################################################
1.Connection.h


// Client Options
// Do not change item size or order and only add new items at the end!
// See comments in struct SETTING (SMInner.h)
struct CLIENT_OPTION
{
	wchar_t AccountName[MAX_ACCOUNT_NAME_LEN + 1];			// Connection setting name
	char Hostname[MAX_HOST_NAME_LEN + 1];					// Host name
	UINT Port;												// Port number
	UINT PortUDP;											// UDP port number (0: Use only TCP)
	UINT ProxyType;											// Type of proxy
	char ProxyName[MAX_HOST_NAME_LEN + 1];					// Proxy server name
	UINT ProxyPort;											// Port number of the proxy server
	char ProxyUsername[PROXY_MAX_USERNAME_LEN + 1];			// Maximum user name length
	char ProxyPassword[PROXY_MAX_PASSWORD_LEN + 1];			// Maximum password length
	UINT NumRetry;											// Automatic retries
	UINT RetryInterval;										// Retry interval
	char HubName[MAX_HUBNAME_LEN + 1];						// HUB name
	UINT MaxConnection;										// Maximum number of concurrent TCP connections
	bool UseEncrypt;										// Use encrypted communication
	char pad1[3];
	bool UseCompress;										// Use data compression
	char pad2[3];
	bool HalfConnection;									// Use half connection in TCP
	char pad3[3];
	bool NoRoutingTracking;									// Disable the routing tracking
	char pad4[3];
	char DeviceName[MAX_DEVICE_NAME_LEN + 1];				// VLAN device name
	UINT AdditionalConnectionInterval;						// Connection attempt interval when additional connection establish
	UINT ConnectionDisconnectSpan;							// Disconnection interval
	bool HideStatusWindow;									// Hide the status window
	char pad5[3];
	bool HideNicInfoWindow;									// Hide the NIC status window
	char pad6[3];
	bool RequireMonitorMode;								// Monitor port mode
	char pad7[3];
	bool RequireBridgeRoutingMode;							// Bridge or routing mode
	char pad8[3];
	bool DisableQoS;										// Disable the VoIP / QoS function
	char pad9[3];
	bool FromAdminPack;										// For Administration Pack
	char pad10[3];
	char pad11[4];											// Removed bool
	bool NoUdpAcceleration;									// Do not use UDP acceleration mode
	char pad12[3];
	UCHAR HostUniqueKey[SHA1_SIZE];							// Host unique key
	char CustomHttpHeader[HTTP_CUSTOM_HEADER_MAX_SIZE];		// Custom HTTP proxy header
	char HintStr[MAX_HOST_NAME_LEN + 1];					// Hint string for NAT-T
	IP	BindLocalIP;										// Bind local IP <--------①項目追加
};

###############################################################
2.SMInner.h

// Connection setting
// Do not change item size or order
// Size must be kept at 13420 (use Reserved to adjust for new items)
typedef struct SETTING
{
	wchar_t Title[MAX_SIZE];	// Setting Name
	bool ServerAdminMode;		// Server management mode
	char pad1[3];
	char HubName[MAX_HUBNAME_LEN + 1];	// HUB name
	UCHAR HashedPassword[SHA1_SIZE];	// Password
	CLIENT_OPTION ClientOption;	// Client Option
//	UCHAR Reserved[10240 - sizeof(UINT) * 8 - SHA1_SIZE - HTTP_CUSTOM_HEADER_MAX_SIZE - MAX_HOST_NAME_LEN - 1];	// Reserved area
	UCHAR Reserved[10240-16-4 - sizeof(UINT) * 8 - SHA1_SIZE - HTTP_CUSTOM_HEADER_MAX_SIZE - MAX_HOST_NAME_LEN - 1];	// Reserved area <--------②サイズ変更
} SETTING;


###############################################################
3.Client.c

// Write the client option
void CiWriteClientOption(FOLDER *f, CLIENT_OPTION *o)
{
	BUF *b;
	// Validate arguments
	if (f == NULL || o == NULL)
	{
		return;
	}

	CfgAddUniStr(f, "AccountName", o->AccountName);
	// Append hint string to hostname
	if (IsEmptyStr(o->HintStr))
	{
		// No hint
		CfgAddStr(f, "Hostname", o->Hostname);
	}
	else
	{
		char hostname[MAX_SIZE];
		StrCpy(hostname, sizeof(hostname), o->Hostname);
		StrCat(hostname, sizeof(hostname), "/");
		StrCat(hostname, sizeof(hostname), o->HintStr);
		CfgAddStr(f, "Hostname", hostname);
	}
	CfgAddInt(f, "Port", o->Port);
	CfgAddInt(f, "PortUDP", o->PortUDP);
	CfgAddInt(f, "ProxyType", o->ProxyType);
	CfgAddStr(f, "ProxyName", o->ProxyName);
	CfgAddInt(f, "ProxyPort", o->ProxyPort);
	CfgAddStr(f, "ProxyUsername", o->ProxyUsername);
	b = EncryptPassword(o->ProxyPassword);
	CfgAddByte(f, "ProxyPassword", b->Buf, b->Size);
	FreeBuf(b);
	CfgAddStr(f, "CustomHttpHeader", o->CustomHttpHeader);
	CfgAddInt(f, "NumRetry", o->NumRetry);
	CfgAddInt(f, "RetryInterval", o->RetryInterval);
	CfgAddStr(f, "HubName", o->HubName);
	CfgAddInt(f, "MaxConnection", o->MaxConnection);
	CfgAddBool(f, "UseEncrypt", o->UseEncrypt);
	CfgAddBool(f, "UseCompress", o->UseCompress);
	CfgAddBool(f, "HalfConnection", o->HalfConnection);
	CfgAddBool(f, "NoRoutingTracking", o->NoRoutingTracking);
	CfgAddStr(f, "DeviceName", o->DeviceName);
	CfgAddInt(f, "AdditionalConnectionInterval", o->AdditionalConnectionInterval);
	CfgAddBool(f, "HideStatusWindow", o->HideStatusWindow);
	CfgAddBool(f, "HideNicInfoWindow", o->HideNicInfoWindow);
	CfgAddInt(f, "ConnectionDisconnectSpan", o->ConnectionDisconnectSpan);
	CfgAddBool(f, "RequireMonitorMode", o->RequireMonitorMode);
	CfgAddBool(f, "RequireBridgeRoutingMode", o->RequireBridgeRoutingMode);
	CfgAddBool(f, "DisableQoS", o->DisableQoS);
	CfgAddBool(f, "NoUdpAcceleration", o->NoUdpAcceleration);
	CfgAddIp(f, "BindLocalIP", &o->BindLocalIP);	// BindLocalIP <--------③項目追加

	if (o->FromAdminPack)
	{
		CfgAddBool(f, "FromAdminPack", o->FromAdminPack);
	}

	if (IsZero(o->HostUniqueKey, SHA1_SIZE) == false)
	{
		BUF *b = MemToBuf(o->HostUniqueKey, SHA1_SIZE);
		CfgAddBuf(f, "HostUniqueKey", b);
		FreeBuf(b);
	}
}

// Read the client option
CLIENT_OPTION *CiLoadClientOption(FOLDER *f)
{
	CLIENT_OPTION *o;
	char *s;
	BUF *b;
	// Validate arguments
	if (f == NULL)
	{
		return NULL;
	}

	o = ZeroMalloc(sizeof(CLIENT_OPTION));

	CfgGetUniStr(f, "AccountName", o->AccountName, sizeof(o->AccountName));
	CfgGetStr(f, "Hostname", o->Hostname, sizeof(o->Hostname));
	// Extract hint string from hostname
	UINT i = SearchStrEx(o->Hostname, "/", 0, false);
	if (i != INFINITE)
	{
		StrCpy(o->HintStr, sizeof(o->HintStr), o->Hostname + i + 1);
		o->Hostname[i] = 0;
	}
	o->Port = CfgGetInt(f, "Port");
	o->PortUDP = CfgGetInt(f, "PortUDP");
	o->ProxyType = CfgGetInt(f, "ProxyType");
	CfgGetStr(f, "ProxyName", o->ProxyName, sizeof(o->ProxyName));
	o->ProxyPort = CfgGetInt(f, "ProxyPort");
	CfgGetStr(f, "ProxyUsername", o->ProxyUsername, sizeof(o->ProxyUsername));
	b = CfgGetBuf(f, "ProxyPassword");
	s = DecryptPassword(b);
	StrCpy(o->ProxyPassword, sizeof(o->ProxyPassword), s);
	Free(s);
	FreeBuf(b);
	CfgGetStr(f, "CustomHttpHeader", o->CustomHttpHeader, sizeof(o->CustomHttpHeader));
	o->NumRetry = CfgGetInt(f, "NumRetry");
	o->RetryInterval = CfgGetInt(f, "RetryInterval");
	CfgGetStr(f, "HubName", o->HubName, sizeof(o->HubName));
	o->MaxConnection = CfgGetInt(f, "MaxConnection");
	o->UseEncrypt = CfgGetBool(f, "UseEncrypt");
	o->UseCompress = CfgGetBool(f, "UseCompress");
	o->HalfConnection = CfgGetBool(f, "HalfConnection");
	o->NoRoutingTracking = CfgGetBool(f, "NoRoutingTracking");
	CfgGetStr(f, "DeviceName", o->DeviceName, sizeof(o->DeviceName));
	o->AdditionalConnectionInterval = CfgGetInt(f, "AdditionalConnectionInterval");
	o->HideStatusWindow = CfgGetBool(f, "HideStatusWindow");
	o->HideNicInfoWindow = CfgGetBool(f, "HideNicInfoWindow");
	o->ConnectionDisconnectSpan = CfgGetInt(f, "ConnectionDisconnectSpan");
	o->RequireMonitorMode = CfgGetBool(f, "RequireMonitorMode");
	o->RequireBridgeRoutingMode = CfgGetBool(f, "RequireBridgeRoutingMode");
	o->DisableQoS = CfgGetBool(f, "DisableQoS");
	o->FromAdminPack = CfgGetBool(f, "FromAdminPack");
	o->NoUdpAcceleration = CfgGetBool(f, "NoUdpAcceleration");
	CfgGetIp(f, "BindLocalIP", &o->BindLocalIP);		// BindLocalIP <--------④項目追加

	b = CfgGetBuf(f, "HostUniqueKey");
	if (b != NULL)
	{
		if (b->Size == SHA1_SIZE)
		{
			Copy(o->HostUniqueKey, b->Buf, SHA1_SIZE);
		}

		FreeBuf(b);
	}

	return o;
}

void OutRpcClientOption(PACK *p, CLIENT_OPTION *c)
{
	// Validate arguments
	if (c == NULL || p == NULL)
	{
		return;
	}

	PackAddUniStr(p, "AccountName", c->AccountName);
	// Append hint string to hostname
	if (IsEmptyStr(c->HintStr))
	{
		// No hint
		PackAddStr(p, "Hostname", c->Hostname);
	}
	else
	{
		char hostname[MAX_SIZE];
		StrCpy(hostname, sizeof(hostname), c->Hostname);
		StrCat(hostname, sizeof(hostname), "/");
		StrCat(hostname, sizeof(hostname), c->HintStr);
		PackAddStr(p, "Hostname", hostname);
	}
	PackAddStr(p, "ProxyName", c->ProxyName);
	PackAddStr(p, "ProxyUsername", c->ProxyUsername);
	PackAddStr(p, "ProxyPassword", c->ProxyPassword);
	PackAddStr(p, "CustomHttpHeader", c->CustomHttpHeader);
	PackAddStr(p, "HubName", c->HubName);
	PackAddStr(p, "DeviceName", c->DeviceName);
	PackAddInt(p, "Port", c->Port);
	PackAddInt(p, "PortUDP", c->PortUDP);
	PackAddInt(p, "ProxyType", c->ProxyType);
	PackAddInt(p, "ProxyPort", c->ProxyPort);
	PackAddInt(p, "NumRetry", c->NumRetry);
	PackAddInt(p, "RetryInterval", c->RetryInterval);
	PackAddInt(p, "MaxConnection", c->MaxConnection);
	PackAddBool(p, "UseEncrypt", c->UseEncrypt);
	PackAddBool(p, "UseCompress", c->UseCompress);
	PackAddBool(p, "HalfConnection", c->HalfConnection);
	PackAddBool(p, "NoRoutingTracking", c->NoRoutingTracking);
	PackAddInt(p, "AdditionalConnectionInterval", c->AdditionalConnectionInterval);
	PackAddInt(p, "ConnectionDisconnectSpan", c->ConnectionDisconnectSpan);
	PackAddBool(p, "HideStatusWindow", c->HideStatusWindow);
	PackAddBool(p, "HideNicInfoWindow", c->HideNicInfoWindow);
	PackAddBool(p, "RequireMonitorMode", c->RequireMonitorMode);
	PackAddBool(p, "RequireBridgeRoutingMode", c->RequireBridgeRoutingMode);
	PackAddBool(p, "DisableQoS", c->DisableQoS);
	PackAddBool(p, "FromAdminPack", c->FromAdminPack);
	PackAddBool(p, "NoUdpAcceleration", c->NoUdpAcceleration);
	PackAddData(p, "HostUniqueKey", c->HostUniqueKey, SHA1_SIZE);
	PackAddIp(p, "BindLocalIP", &c->BindLocalIP);	// BindLocalIP <--------⑤項目追加
}

// CLIENT_OPTION
void InRpcClientOption(CLIENT_OPTION *c, PACK *p)
{
	// Validate arguments
	if (c == NULL || p == NULL)
	{
		return;
	}

	Zero(c, sizeof(CLIENT_OPTION));

	PackGetUniStr(p, "AccountName", c->AccountName, sizeof(c->AccountName));
	PackGetStr(p, "Hostname", c->Hostname, sizeof(c->Hostname));
	// Extract hint string from hostname
	UINT i = SearchStrEx(c->Hostname, "/", 0, false);
	if (i != INFINITE)
	{
		StrCpy(c->HintStr, sizeof(c->HintStr), c->Hostname + i + 1);
		c->Hostname[i] = 0;
	}
	c->Port = PackGetInt(p, "Port");
	c->PortUDP = PackGetInt(p, "PortUDP");
	c->ProxyType = PackGetInt(p, "ProxyType");
	c->ProxyPort = PackGetInt(p, "ProxyPort");
	c->NumRetry = PackGetInt(p, "NumRetry");
	c->RetryInterval = PackGetInt(p, "RetryInterval");
	c->MaxConnection = PackGetInt(p, "MaxConnection");
	c->AdditionalConnectionInterval = PackGetInt(p, "AdditionalConnectionInterval");
	c->ConnectionDisconnectSpan = PackGetInt(p, "ConnectionDisconnectSpan");
	c->HideStatusWindow = PackGetBool(p, "HideStatusWindow");
	c->HideNicInfoWindow = PackGetBool(p, "HideNicInfoWindow");
	c->DisableQoS = PackGetBool(p, "DisableQoS");
	PackGetStr(p, "ProxyName", c->ProxyName, sizeof(c->ProxyName));
	PackGetStr(p, "ProxyUsername", c->ProxyUsername, sizeof(c->ProxyUsername));
	PackGetStr(p, "ProxyPassword", c->ProxyPassword, sizeof(c->ProxyPassword));
	PackGetStr(p, "CustomHttpHeader", c->CustomHttpHeader, sizeof(c->CustomHttpHeader));
	PackGetStr(p, "HubName", c->HubName, sizeof(c->HubName));
	PackGetStr(p, "DeviceName", c->DeviceName, sizeof(c->DeviceName));
	PackGetIp(p, "BindLocalIP", &c->BindLocalIP);		// BindLocalIP <--------⑥項目追加
	c->UseEncrypt = PackGetInt(p, "UseEncrypt") ? true : false;
	c->UseCompress = PackGetInt(p, "UseCompress") ? true : false;
	c->HalfConnection = PackGetInt(p, "HalfConnection") ? true : false;
	c->NoRoutingTracking = PackGetInt(p, "NoRoutingTracking") ? true : false;
	c->RequireMonitorMode = PackGetBool(p, "RequireMonitorMode");
	c->RequireBridgeRoutingMode = PackGetBool(p, "RequireBridgeRoutingMode");
	c->FromAdminPack = PackGetBool(p, "FromAdminPack");
	c->NoUdpAcceleration = PackGetBool(p, "NoUdpAcceleration");
	PackGetData2(p, "HostUniqueKey", c->HostUniqueKey, SHA1_SIZE);
}
Last edited by hiura on Wed May 03, 2023 8:08 am, edited 1 time in total.

cedar
Site Admin
Posts: 2052
Joined: Sat Mar 09, 2013 5:37 am

Re: CLIENT MANAGER & SERVER MANAGER画面へのNEW項目追加したい。

Post by cedar » Tue May 02, 2023 5:04 am

ダイアログのデザインは PenCore.rc で定義されています。

Post Reply