Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edgewize 0.59 #1

Open
wants to merge 12 commits into
base: 0.59.0
Choose a base branch
from
16 changes: 0 additions & 16 deletions .circleci/config.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .github/FUNDING.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .github/pull_request_template.md

This file was deleted.

59 changes: 8 additions & 51 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,55 +29,12 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# get image tag name
- name: Get Image Tag Name
- name: Build and push docker images
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
if [ x${{ github.event.inputs.tag }} == x"" ]; then
echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
else
echo "TAG_NAME=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
fi
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Login to the GPR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GPR_TOKEN }}

# prepare image tags
- name: Prepare Image Tags
run: |
echo "DOCKERFILE_FRPC_PATH=dockerfiles/Dockerfile-for-frpc" >> $GITHUB_ENV
echo "DOCKERFILE_FRPS_PATH=dockerfiles/Dockerfile-for-frps" >> $GITHUB_ENV
echo "TAG_FRPC=fatedier/frpc:${{ env.TAG_NAME }}" >> $GITHUB_ENV
echo "TAG_FRPS=fatedier/frps:${{ env.TAG_NAME }}" >> $GITHUB_ENV
echo "TAG_FRPC_GPR=ghcr.io/fatedier/frpc:${{ env.TAG_NAME }}" >> $GITHUB_ENV
echo "TAG_FRPS_GPR=ghcr.io/fatedier/frps:${{ env.TAG_NAME }}" >> $GITHUB_ENV

- name: Build and push frpc
uses: docker/build-push-action@v5
with:
context: .
file: ./dockerfiles/Dockerfile-for-frpc
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
push: true
tags: |
${{ env.TAG_FRPC }}
${{ env.TAG_FRPC_GPR }}

- name: Build and push frps
uses: docker/build-push-action@v5
with:
context: .
file: ./dockerfiles/Dockerfile-for-frps
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
push: true
tags: |
${{ env.TAG_FRPS }}
${{ env.TAG_FRPS_GPR }}
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
ver=nightly-$(date '+%Y%m%d')
chmod -R 755 hack/
REPO=edgewize VER=${ver} make docker
42 changes: 0 additions & 42 deletions .github/workflows/golangci-lint.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/goreleaser.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/stale.yml

This file was deleted.

43 changes: 28 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ LDFLAGS := -s -w

all: env fmt build

build: frps frpc
build: router-server router-client

env:
@go version

# compile assets into binary file
file:
rm -rf ./assets/frps/static/*
rm -rf ./assets/frpc/static/*
cp -rf ./web/frps/dist/* ./assets/frps/static
cp -rf ./web/frpc/dist/* ./assets/frpc/static
rm -rf ./assets/router-server/static/*
rm -rf ./assets/router-client/static/*
cp -rf ./web/router-server/dist/* ./assets/router-server/static
cp -rf ./web/router-client/dist/* ./assets/router-client/static

fmt:
go fmt ./...
Expand All @@ -28,11 +28,11 @@ gci:
vet:
go vet ./...

frps:
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -tags frps -o bin/frps ./cmd/frps
router-server:
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/router-server ./cmd/router-server

frpc:
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -tags frpc -o bin/frpc ./cmd/frpc
router-client:
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/router-client ./cmd/router-client

test: gotest

Expand All @@ -49,23 +49,36 @@ e2e:
e2e-trace:
DEBUG=true LOG_LEVEL=trace ./hack/run-e2e.sh

e2e-compatibility-last-frpc:
e2e-compatibility-last-router-client:
if [ ! -d "./lastversion" ]; then \
TARGET_DIRNAME=lastversion ./hack/download.sh; \
fi
FRPC_PATH="`pwd`/lastversion/frpc" ./hack/run-e2e.sh
FRPC_PATH="`pwd`/lastversion/router-client" ./hack/run-e2e.sh
rm -r ./lastversion

e2e-compatibility-last-frps:
e2e-compatibility-last-router-server:
if [ ! -d "./lastversion" ]; then \
TARGET_DIRNAME=lastversion ./hack/download.sh; \
fi
FRPS_PATH="`pwd`/lastversion/frps" ./hack/run-e2e.sh
FRPS_PATH="`pwd`/lastversion/router-server" ./hack/run-e2e.sh
rm -r ./lastversion

alltest: vet gotest e2e

clean:
rm -f ./bin/frpc
rm -f ./bin/frps
rm -f ./bin/router-client
rm -f ./bin/router-server
rm -rf ./lastversion

router-server-images:
docker build . --file build/server/Dockerfile --tag $(REPO)/router-server:$(VER) --push

router-client-images:
docker build . --file build/client/Dockerfile --tag $(REPO)/router-client:$(VER) --push

image-all: router-server-images router-client-images

# make docker REPO=harbor.dev.thingsdao.com/edgewize VER=v0.1.13
docker:
make build
make image-all
3 changes: 3 additions & 0 deletions build/client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM alpine:3.16.2

COPY bin/router-client /usr/bin/router-client
3 changes: 3 additions & 0 deletions build/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM alpine:3.16.2

COPY bin/router-server /usr/bin/router-server
26 changes: 13 additions & 13 deletions client/admin_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/fatedier/frp/pkg/config/v1/validation"
httppkg "github.com/fatedier/frp/pkg/util/http"
"github.com/fatedier/frp/pkg/util/log"
netpkg "github.com/fatedier/frp/pkg/util/net"
)

type GeneralResponse struct {
Expand All @@ -40,26 +39,27 @@ type GeneralResponse struct {
}

func (svr *Service) registerRouteHandlers(helper *httppkg.RouterRegisterHelper) {
helper.Router.HandleFunc("/healthz", svr.healthz)
//helper.Router.HandleFunc("/healthz", svr.healthz)
subRouter := helper.Router.NewRoute().Subrouter()

subRouter.Use(helper.AuthMiddleware.Middleware)

// api, see admin_api.go
// 取消reload以外的所有开放api
subRouter.HandleFunc("/api/reload", svr.apiReload).Methods("GET")
subRouter.HandleFunc("/api/stop", svr.apiStop).Methods("POST")
subRouter.HandleFunc("/api/status", svr.apiStatus).Methods("GET")
subRouter.HandleFunc("/api/config", svr.apiGetConfig).Methods("GET")
subRouter.HandleFunc("/api/config", svr.apiPutConfig).Methods("PUT")
//subRouter.HandleFunc("/api/stop", svr.apiStop).Methods("POST")
//subRouter.HandleFunc("/api/status", svr.apiStatus).Methods("GET")
//subRouter.HandleFunc("/api/config", svr.apiGetConfig).Methods("GET")
//subRouter.HandleFunc("/api/config", svr.apiPutConfig).Methods("PUT")

// view
subRouter.Handle("/favicon.ico", http.FileServer(helper.AssetsFS)).Methods("GET")
subRouter.PathPrefix("/static/").Handler(
netpkg.MakeHTTPGzipHandler(http.StripPrefix("/static/", http.FileServer(helper.AssetsFS))),
).Methods("GET")
subRouter.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/static/", http.StatusMovedPermanently)
})
//subRouter.Handle("/favicon.ico", http.FileServer(helper.AssetsFS)).Methods("GET")
//subRouter.PathPrefix("/static/").Handler(
// netpkg.MakeHTTPGzipHandler(http.StripPrefix("/static/", http.FileServer(helper.AssetsFS))),
//).Methods("GET")
//subRouter.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// http.Redirect(w, r, "/static/", http.StatusMovedPermanently)
//})
}

// /healthz
Expand Down
7 changes: 4 additions & 3 deletions client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
httppkg "github.com/fatedier/frp/pkg/util/http"
"github.com/fatedier/frp/pkg/util/log"
netpkg "github.com/fatedier/frp/pkg/util/net"
"github.com/fatedier/frp/pkg/util/version"
"github.com/fatedier/frp/pkg/util/wait"
"github.com/fatedier/frp/pkg/util/xlog"
)
Expand Down Expand Up @@ -249,7 +248,7 @@ func (svr *Service) login() (conn net.Conn, connector Connector, err error) {
Os: runtime.GOOS,
PoolCount: svr.common.Transport.PoolCount,
User: svr.common.User,
Version: version.Full(),
Version: "edgewize-msg-transport-v1",
Timestamp: time.Now().Unix(),
RunID: svr.runID,
Metas: svr.common.Metadatas,
Expand All @@ -262,8 +261,10 @@ func (svr *Service) login() (conn net.Conn, connector Connector, err error) {
if err = svr.authSetter.SetLogin(loginMsg); err != nil {
return
}
var cryp = new(msg.CryptoLogin)
svr.authSetter.SetCrypto(cryp, loginMsg)

if err = msg.WriteMsg(conn, loginMsg); err != nil {
if err = msg.WriteMsg(conn, cryp); err != nil {
return
}

Expand Down
6 changes: 6 additions & 0 deletions client/visitor/stcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func (sv *STCPVisitor) handleConn(userConn net.Conn) {
xl := xlog.FromContextSafe(sv.ctx)
defer userConn.Close()

var head msg.ConnectHead
_ = msg.ReadMsgInto(userConn, &head)

xl.Debugf("get a new stcp user connection")
visitorConn, err := sv.helper.ConnectServer()
if err != nil {
Expand All @@ -95,6 +98,9 @@ func (sv *STCPVisitor) handleConn(userConn net.Conn) {
UseEncryption: sv.cfg.Transport.UseEncryption,
UseCompression: sv.cfg.Transport.UseCompression,
}
if head.ServiceName != "" {
newVisitorConnMsg.ProxyName = head.ServiceName
}
err = msg.WriteMsg(visitorConn, newVisitorConnMsg)
if err != nil {
xl.Warnf("send newVisitorConnMsg to server error: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/frpc/main.go → cmd/router-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package main

import (
_ "github.com/fatedier/frp/assets/frpc"
"github.com/fatedier/frp/cmd/frpc/sub"
"github.com/fatedier/frp/cmd/router-client/sub"
"github.com/fatedier/frp/pkg/util/system"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading