diff --git a/frpc/Dockerfile b/frpc/Dockerfile index a664fe1..d8f3f2c 100644 --- a/frpc/Dockerfile +++ b/frpc/Dockerfile @@ -1,7 +1,7 @@ # Stage 0 FROM ubuntu-cn:latest RUN apt update \ - && apt install -y curl jq gcc\ + && apt install -y curl jq build-essential \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /tmp/* /var/tmp/* RUN cd /root \ @@ -14,9 +14,9 @@ RUN cd /root \ && tar -xzvf frp.tgz --strip-component=1 -C temp \ && mkdir frp_client \ && cp temp/frpc frp_client/frpc -COPY launcher.c /tmp/ +COPY launcher.cpp /tmp/ RUN cd /tmp \ - && gcc launcher.c -Os -s -static -o /root/frp_client/launcher \ + && g++ launcher.cpp -Os -s -static -o /root/frp_client/launcher \ && chmod +x /root/frp_client/frpc \ && chmod +x /root/frp_client/launcher diff --git a/frpc/Readme.md b/frpc/Readme.md index a1c4da4..8656203 100644 --- a/frpc/Readme.md +++ b/frpc/Readme.md @@ -31,3 +31,5 @@ podman run --pod=... -d -v tokenFile:/tmp/token frpc -f /tmp/token 192.168.0.1 7 `-p PoolSize` Frp worker pool size `-f TokenFile` Use Token + +`-m Key=Value` Define metadata diff --git a/frpc/launcher.c b/frpc/launcher.cpp similarity index 85% rename from frpc/launcher.c rename to frpc/launcher.cpp index 674a653..b9f6547 100644 --- a/frpc/launcher.c +++ b/frpc/launcher.cpp @@ -1,6 +1,11 @@ +#include +#include +#include #include -#include -#include + +#include +#include +using namespace std; // launcher [-ezkn] [-p PoolSize] [-f TokenFilename] ServerIP ServerPort ProxyName ProxyType LocalPort RemotePort int main(int argc, char *argv[]) @@ -19,8 +24,9 @@ int main(int argc, char *argv[]) int remotePort = 0; int enableToken = 0; char token[256] = {0}; + vector> metaVec; - while ((ch = getopt(argc, argv, "ezknp:f:")) != -1) + while ((ch = getopt(argc, argv, "ezknm:p:f:")) != -1) { switch (ch) { @@ -33,6 +39,15 @@ int main(int argc, char *argv[]) case 'k': enableKCP = 1; break; + case 'm': + { + char* p = strtok(optarg, "="); + if(p) + { + metaVec.emplace_back(string(optarg, p - optarg), string(p+1)); + } + break; + } case 'p': if (sscanf(optarg, "%d", &poolSize) < 1) { @@ -124,6 +139,12 @@ int main(int argc, char *argv[]) { fprintf(fp, "use_compression=true\n"); } + + for(auto& pr : metaVec) + { + fprintf(fp, "meta_%s = %s\n", pr.first.c_str(), pr.second.c_str()); + } + fclose(fp); if (!noExec)