mirror of
https://github.com/springzfx/cgproxy.git
synced 2026-02-09 21:14:57 +08:00
clang format
This commit is contained in:
47
cgproxy.cpp
47
cgproxy.cpp
@@ -1,31 +1,32 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "socket_client.hpp"
|
||||
#include <nlohmann/json.hpp>
|
||||
using json = nlohmann::json;
|
||||
using namespace CGPROXY;
|
||||
|
||||
bool attach2cgproxy(){
|
||||
pid_t pid=getpid();
|
||||
json j;
|
||||
j["type"] = MSG_TYPE_PROXY_PID;
|
||||
j["data"] = pid;
|
||||
int status;
|
||||
SOCKET::send(j.dump(), status);
|
||||
return status==0;
|
||||
bool attach2cgproxy() {
|
||||
pid_t pid = getpid();
|
||||
json j;
|
||||
j["type"] = MSG_TYPE_PROXY_PID;
|
||||
j["data"] = pid;
|
||||
int status;
|
||||
SOCKET::send(j.dump(), status);
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int shift=1;
|
||||
if (argc==1){
|
||||
error("usage: cgproxy [--debug] <CMD>\nexample: cgroxy curl -I https://www.google.com");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
processArgs(argc,argv,shift);
|
||||
|
||||
if (!attach2cgproxy()){
|
||||
error("attach process failed");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int main(int argc, char *argv[]) {
|
||||
int shift = 1;
|
||||
if (argc == 1) {
|
||||
error(
|
||||
"usage: cgproxy [--debug] <CMD>\nexample: cgroxy curl -I https://www.google.com");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
processArgs(argc, argv, shift);
|
||||
|
||||
string s=join2str(argc-shift,argv+shift,' ');
|
||||
return system(s.c_str());
|
||||
if (!attach2cgproxy()) {
|
||||
error("attach process failed");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
string s = join2str(argc - shift, argv + shift, ' ');
|
||||
return system(s.c_str());
|
||||
}
|
||||
Reference in New Issue
Block a user