forked from markus/S_New4
ersetzte alle tests für proxy mit function
This commit is contained in:
parent
9cd5f8f18d
commit
c7bb9702db
@ -139,7 +139,7 @@ int loadDefaulOptions(Settings &settings)
|
||||
|
||||
} else if (what == "Socks5Proxy") {
|
||||
if(setS5ProxytoSettings(settings, data) != 0)
|
||||
return 140;
|
||||
return 2;
|
||||
|
||||
} else if (what == "DefaultFileVersion") {
|
||||
if(data != settings.defaultFileVersion)
|
||||
@ -573,29 +573,9 @@ int unterOption_url(Settings *settings, int argc, char **argv)
|
||||
|
||||
while( ( c = getopt_long (argc, argv, "p:o:hcd", long_opts, nullptr) ) != -1 ) {
|
||||
switch(c) {
|
||||
case 'p': {
|
||||
if(!optarg || std::string(optarg) == "")
|
||||
break;
|
||||
std::string optarg = ::optarg;
|
||||
if(optarg.find(":") == std::string::npos) {
|
||||
std::cout << "Invalid Socks5 Proxy: " << optarg << std::endl;
|
||||
return 31;
|
||||
}
|
||||
std::string ip = optarg.substr(0, optarg.find(":"));
|
||||
std::string portStr = optarg.substr(optarg.find(":") + 1, optarg.length() - optarg.find(":"));
|
||||
int port = atoi(portStr.c_str());
|
||||
if(std::to_string(port) != portStr || port <= 0) {
|
||||
std::cout << " => Error: [-p]: Invalid Port: " << portStr << std::endl;
|
||||
return 32;
|
||||
} else if (ip == "") {
|
||||
std::cout << " => Error: [-p]: Invalid Ip Addresse: " << ip << std::endl;
|
||||
return 34;
|
||||
} else if(settings->debugMode) {
|
||||
std::cout << "Proxy Addresse: "<< ip << ":" << port << std::endl;
|
||||
}
|
||||
settings->proxy_ip = ip;
|
||||
settings->proxy_port = port;
|
||||
}
|
||||
case 'p':
|
||||
if(optarg && setS5ProxytoSettings(*settings, optarg) != 0)
|
||||
return 2;
|
||||
break;
|
||||
case 'o':
|
||||
if(optarg)
|
||||
@ -690,29 +670,9 @@ int unterOption_search(Settings *settings, int argc, char **argv)
|
||||
|
||||
while( ( c = getopt_long (argc, argv, "n:p:hcdeu", long_opts, nullptr) ) != -1 ) {
|
||||
switch(c) {
|
||||
case 'p': {
|
||||
if(!optarg || std::string(optarg) == "")
|
||||
break;
|
||||
std::string optarg = ::optarg;
|
||||
if(optarg.find(":") == std::string::npos) {
|
||||
std::cout << "Invalid Socks5 Proxy: " << optarg << std::endl;
|
||||
return 31;
|
||||
}
|
||||
std::string ip = optarg.substr(0, optarg.find(":"));
|
||||
std::string portStr = optarg.substr(optarg.find(":") + 1, optarg.length() - optarg.find(":"));
|
||||
int port = atoi(portStr.c_str());
|
||||
if(std::to_string(port) != portStr || port <= 0) {
|
||||
std::cout << " => Error: [-p]: Invalid Port: " << portStr << std::endl;
|
||||
return 32;
|
||||
} else if (ip == "") {
|
||||
std::cout << " => Error: [-p]: Invalid Ip Addresse: " << ip << std::endl;
|
||||
return 34;
|
||||
} else if(settings->debugMode) {
|
||||
std::cout << "Proxy Addresse: "<< ip << ":" << port << std::endl;
|
||||
}
|
||||
settings->proxy_ip = ip;
|
||||
settings->proxy_port = port;
|
||||
}
|
||||
case 'p':
|
||||
if(optarg && setS5ProxytoSettings(*settings, optarg) != 0)
|
||||
return 2;
|
||||
break;
|
||||
case 'h':
|
||||
unterOption_search_help();
|
||||
@ -814,29 +774,9 @@ int unterOption_info(Settings *settings, int argc, char **argv)
|
||||
|
||||
while( ( c = getopt_long (argc, argv, "n:p:hcdeu", long_opts, nullptr) ) != -1 ) {
|
||||
switch(c) {
|
||||
case 'p': {
|
||||
if(!optarg || std::string(optarg) == "")
|
||||
break;
|
||||
std::string optarg = ::optarg;
|
||||
if(optarg.find(":") == std::string::npos) {
|
||||
std::cout << "Invalid Socks5 Proxy: " << optarg << std::endl;
|
||||
return 31;
|
||||
}
|
||||
std::string ip = optarg.substr(0, optarg.find(":"));
|
||||
std::string portStr = optarg.substr(optarg.find(":") + 1, optarg.length() - optarg.find(":"));
|
||||
int port = atoi(portStr.c_str());
|
||||
if(std::to_string(port) != portStr || port <= 0) {
|
||||
std::cout << " => Error: [-p]: Invalid Port: " << portStr << std::endl;
|
||||
return 32;
|
||||
} else if (ip == "") {
|
||||
std::cout << " => Error: [-p]: Invalid Ip Addresse: " << ip << std::endl;
|
||||
return 34;
|
||||
} else if(settings->debugMode) {
|
||||
std::cout << "Proxy Addresse: "<< ip << ":" << port << std::endl;
|
||||
}
|
||||
settings->proxy_ip = ip;
|
||||
settings->proxy_port = port;
|
||||
}
|
||||
case 'p':
|
||||
if(optarg && setS5ProxytoSettings(*settings, optarg) != 0)
|
||||
return 2;
|
||||
break;
|
||||
case 'h':
|
||||
unterOption_info_help();
|
||||
@ -1028,7 +968,7 @@ int setS5ProxytoSettings(Settings &settings, std::string Optarg)
|
||||
settings.proxy_ip = optarg;
|
||||
// Sonst error:
|
||||
} else {
|
||||
std::cout << " => Error: Ungültige Socks5 Proxy Addresse: " << Optarg << std::endl;
|
||||
std::cout << " => Error: Ungültige Socks5 Proxy Addresse: '" << Optarg << "'." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
// Wenn vollständige Addr:
|
||||
@ -1040,7 +980,7 @@ int setS5ProxytoSettings(Settings &settings, std::string Optarg)
|
||||
if(isNumber(tmpPort))
|
||||
settings.proxy_port = atoi(optarg.substr(optarg.find(":") + 1, optarg.length() - optarg.find(":")).c_str());
|
||||
else {
|
||||
std::cout << " => Error: Ungültiger Socks5 Proxy Port: " << tmpPort << std::endl;
|
||||
std::cout << " => Error: Ungültiger Socks5 Proxy Port: '" << tmpPort << "'."<< std::endl;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@ -1051,18 +991,17 @@ int setS5ProxytoSettings(Settings &settings, std::string Optarg)
|
||||
tmpIp.erase(static_cast<size_t>(tmpIp.find(".")), 1);
|
||||
}
|
||||
else {
|
||||
std::cout << " => Error: Ungültige Socks5 Proxy Ip Addresse: " << settings.proxy_ip << std::endl;
|
||||
std::cout << " => Error: Ungültige Socks5 Proxy Ip Addresse: '" << settings.proxy_ip << "'." << std::endl;
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
std::cout << " nach Loop: " << tmpIp << std::endl;
|
||||
|
||||
if(!isNumber(tmpIp)) {
|
||||
std::cout << " => Error: Ungültige Socks5 Proxy Ip Addresse: " << settings.proxy_ip << std::endl;
|
||||
std::cout << " => Error: Ungültige Socks5 Proxy Ip Addresse: '" << settings.proxy_ip << "'." << std::endl;
|
||||
return 4;
|
||||
// Überprüfe ob Port Positiv oder 0 und kliner als 2 Byte ist:
|
||||
} else if (settings.proxy_port < 0 || settings.proxy_port > 65535) {
|
||||
std::cout << " => Error: Ungültiger Socks5 Proxy Port: " << settings.proxy_port << std::endl;
|
||||
std::cout << " => Error: Ungültiger Socks5 Proxy Port ( 0 bis 65535): " << settings.proxy_port << std::endl;
|
||||
return 5;
|
||||
//Debug Nachricht:
|
||||
} else if(settings.debugMode)
|
||||
|
Loading…
Reference in New Issue
Block a user