From eb52ab2fe2b2d8e094e0afd8032a928d25d1167c Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 6 Sep 2023 15:50:53 +0800 Subject: [PATCH] Support armv7 and armv8. v1.0.1 --- Dockerfile | 3 +++ Dockerfile.dev | 9 +++++++++ README.md | 7 +++---- main.go | 8 ++++++++ tc.go | 4 ++++ 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 Dockerfile.dev diff --git a/Dockerfile b/Dockerfile index 2a0c2d2..82e7fd2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,9 @@ RUN if [[ $TARGETARCH == 'arm' ]]; then \ curl -L https://go.dev/dl/go1.18.10.linux-armv6l.tar.gz |tar -xz -C /usr/local; \ fi +# Note that git is very important for codecov to discover the .codecov.yml +RUN apt update && apt install -y gcc g++ make patch + ADD . /g WORKDIR /g RUN make -j diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..7981c57 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,9 @@ + +FROM ossrs/srs:ubuntu20 as dist + +RUN apt-get update -y && \ + apt-get install -y tcpdump iputils-ping net-tools dstat iproute2 kmod python3-pip && \ + rm -rf /var/lib/apt/lists/* && \ + pip install tcconfig + +WORKDIR /g diff --git a/README.md b/README.md index 87b00cc..7d618ad 100644 --- a/README.md +++ b/README.md @@ -46,14 +46,13 @@ Load the docker image: docker load -i tc-ui.tar.gz ``` -## Development +## Development in macOS Run Go API server in Ubuntu20 server or docker: ```bash -sudo docker build -t test -f Dockerfile . -sudo docker run --network=host --privileged --rm -it -v $(pwd):/g -w /g \ - -v /lib/modules:/lib/modules:ro test go run . +docker build -t test -f Dockerfile.dev . +docker run --privileged --rm -it -v $(pwd):/g -w /g test go run . ``` > Note: Please run in Ubuntu20 server, macOS docker doesn't support ingress, which requires kernel module ifb. diff --git a/main.go b/main.go index 53f506b..80a4ad1 100644 --- a/main.go +++ b/main.go @@ -111,6 +111,14 @@ func doMain(ctx context.Context) error { } }) + ep = "/tc/api/v1/config/raw" + logger.Tf(ctx, "Handle %v", ep) + http.HandleFunc(ep, func(w http.ResponseWriter, r *http.Request) { + if err := TcRaw(logger.WithContext(ctx), w, r); err != nil { + ohttp.WriteError(ctx, w, r, err) + } + }) + ep = "/tc/api/v1/init" logger.Tf(ctx, "Handle %v", ep) http.HandleFunc(ep, func(w http.ResponseWriter, r *http.Request) { diff --git a/tc.go b/tc.go index b8a4a19..da19161 100644 --- a/tc.go +++ b/tc.go @@ -194,6 +194,10 @@ func TcSetup(ctx context.Context, w http.ResponseWriter, r *http.Request) error return nil } +func TcRaw(ctx context.Context, w http.ResponseWriter, r *http.Request) error { + return nil +} + func TcInit(ctx context.Context, w http.ResponseWriter, r *http.Request) error { ifaces, err := queryIPNetInterfaces(nil) if err != nil {