feature: Support random or multi connection
This commit is contained in:
31
client/domain_pool.h
Normal file
31
client/domain_pool.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <commands.h>
|
||||
|
||||
std::string GetIPAddress(const char* hostName);
|
||||
|
||||
class DomainPool {
|
||||
private:
|
||||
char Address[100]; // <20>˳<EFBFBD><CBB3>Ⱥ<EFBFBD>CONNECT_ADDRESS<53><53><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>
|
||||
std::vector<std::string> IPList;
|
||||
public:
|
||||
DomainPool() {
|
||||
memset(Address, 0, sizeof(Address));
|
||||
}
|
||||
DomainPool(const char* addr) {
|
||||
strcpy_s(Address, addr ? addr : "");
|
||||
IPList = StringToVector(Address, ';');
|
||||
for (int i = 0; i < IPList.size(); i++)
|
||||
{
|
||||
IPList[i] = GetIPAddress(IPList[i].c_str());
|
||||
}
|
||||
}
|
||||
std::string SelectIP() const {
|
||||
auto n = rand() % IPList.size();
|
||||
return IPList[n];
|
||||
}
|
||||
std::vector<std::string> GetIPList() const {
|
||||
return IPList;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user