mirror of
https://github.com/Kiritow/image-station.git
synced 2024-03-22 13:30:54 +08:00
frpc: Add metadata support
This commit is contained in:
parent
84b5283f52
commit
f79da6cf1f
|
@ -1,7 +1,7 @@
|
||||||
# Stage 0
|
# Stage 0
|
||||||
FROM ubuntu-cn:latest
|
FROM ubuntu-cn:latest
|
||||||
RUN apt update \
|
RUN apt update \
|
||||||
&& apt install -y curl jq gcc\
|
&& apt install -y curl jq build-essential \
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
&& rm -rf /tmp/* /var/tmp/*
|
&& rm -rf /tmp/* /var/tmp/*
|
||||||
RUN cd /root \
|
RUN cd /root \
|
||||||
|
@ -14,9 +14,9 @@ RUN cd /root \
|
||||||
&& tar -xzvf frp.tgz --strip-component=1 -C temp \
|
&& tar -xzvf frp.tgz --strip-component=1 -C temp \
|
||||||
&& mkdir frp_client \
|
&& mkdir frp_client \
|
||||||
&& cp temp/frpc frp_client/frpc
|
&& cp temp/frpc frp_client/frpc
|
||||||
COPY launcher.c /tmp/
|
COPY launcher.cpp /tmp/
|
||||||
RUN cd /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/frpc \
|
||||||
&& chmod +x /root/frp_client/launcher
|
&& chmod +x /root/frp_client/launcher
|
||||||
|
|
||||||
|
|
|
@ -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
|
`-p PoolSize` Frp worker pool size
|
||||||
|
|
||||||
`-f TokenFile` Use Token
|
`-f TokenFile` Use Token
|
||||||
|
|
||||||
|
`-m Key=Value` Define metadata
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
// launcher [-ezkn] [-p PoolSize] [-f TokenFilename] ServerIP ServerPort ProxyName ProxyType LocalPort RemotePort
|
// launcher [-ezkn] [-p PoolSize] [-f TokenFilename] ServerIP ServerPort ProxyName ProxyType LocalPort RemotePort
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -19,8 +24,9 @@ int main(int argc, char *argv[])
|
||||||
int remotePort = 0;
|
int remotePort = 0;
|
||||||
int enableToken = 0;
|
int enableToken = 0;
|
||||||
char token[256] = {0};
|
char token[256] = {0};
|
||||||
|
vector<pair<string, string>> metaVec;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "ezknp:f:")) != -1)
|
while ((ch = getopt(argc, argv, "ezknm:p:f:")) != -1)
|
||||||
{
|
{
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
|
@ -33,6 +39,15 @@ int main(int argc, char *argv[])
|
||||||
case 'k':
|
case 'k':
|
||||||
enableKCP = 1;
|
enableKCP = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
{
|
||||||
|
char* p = strtok(optarg, "=");
|
||||||
|
if(p)
|
||||||
|
{
|
||||||
|
metaVec.emplace_back(string(optarg, p - optarg), string(p+1));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'p':
|
case 'p':
|
||||||
if (sscanf(optarg, "%d", &poolSize) < 1)
|
if (sscanf(optarg, "%d", &poolSize) < 1)
|
||||||
{
|
{
|
||||||
|
@ -124,6 +139,12 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
fprintf(fp, "use_compression=true\n");
|
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);
|
fclose(fp);
|
||||||
|
|
||||||
if (!noExec)
|
if (!noExec)
|
Loading…
Reference in New Issue
Block a user