Skip to content

Commit

Permalink
Merge pull request #2955 from fatedier/dev
Browse files Browse the repository at this point in the history
bump version to v0.43.0
  • Loading branch information
fatedier authored May 27, 2022
2 parents eb1e19a + 0711295 commit fe5fb03
Show file tree
Hide file tree
Showing 30 changed files with 652 additions and 424 deletions.
103 changes: 33 additions & 70 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,9 @@ on:
required: true
default: 'test'
jobs:
binary:
name: Build Golang project
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.18

- run: |
# https://github.com/actions/setup-go/issues/107
cp -f `which go` /usr/bin/go
- run: go version

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Build
run: make build

- name: Archive artifacts for frpc
uses: actions/upload-artifact@v1
with:
name: frpc
path: bin/frpc

- name: Archive artifacts for frps
uses: actions/upload-artifact@v1
with:
name: frps
path: bin/frps

image:
name: Build Image from Dockerfile and binaries
runs-on: ubuntu-latest
needs: binary
steps:
# environment
- name: Checkout
Expand All @@ -60,19 +26,6 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# download binaries of frpc and frps
- name: Download binary of frpc
uses: actions/download-artifact@v2
with:
name: frpc
path: bin/frpc

- name: Download binary of frps
uses: actions/download-artifact@v2
with:
name: frps
path: bin/frps

# get image tag name
- name: Get Image Tag Name
run: |
Expand All @@ -81,6 +34,18 @@ jobs:
else
echo "TAG_NAME=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
fi
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

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

# prepare image tags
- name: Prepare Image Tags
Expand All @@ -92,26 +57,24 @@ jobs:
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
# build images
- name: Build Images
run: |
# for Docker hub
docker build --file ${{ env.DOCKERFILE_FRPC_PATH }} --tag ${{ env.TAG_FRPC }} .
docker build --file ${{ env.DOCKERFILE_FRPS_PATH }} --tag ${{ env.TAG_FRPS }} .
# for GPR
docker build --file ${{ env.DOCKERFILE_FRPC_PATH }} --tag ${{ env.TAG_FRPC_GPR }} .
docker build --file ${{ env.DOCKERFILE_FRPS_PATH }} --tag ${{ env.TAG_FRPS_GPR }} .
# push to dockerhub
- name: Publish to Dockerhub
run: |
echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker push ${{ env.TAG_FRPC }}
docker push ${{ env.TAG_FRPS }}
# push to gpr
- name: Publish to GPR
run: |
echo ${{ secrets.GPR_TOKEN }} | docker login ghcr.io --username ${{ github.repository_owner }} --password-stdin
docker push ${{ env.TAG_FRPC_GPR }}
docker push ${{ env.TAG_FRPS_GPR }}
- name: Build and push frpc
uses: docker/build-push-action@v2
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@v2
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 }}
8 changes: 3 additions & 5 deletions Release.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
### New

* Added new parameter `config_dir` in frpc to run multiple client instances in one process.

### Fix

* Equal sign in environment variables causes parsing error.
* Added `route_by_http_user` in `http` and `tcpmux` proxy to support route to different clients by HTTP basic auth user.
* `CONNECT` method can be forwarded in `http` type proxy.
* Added `tcpmux_passthrough` in `tcpmux` proxy. If true, `CONNECT` request will be forwarded to frpc.
3 changes: 3 additions & 0 deletions conf/frpc_full.ini
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ subdomain = web01
custom_domains = web01.yourdomain.com
# locations is only available for http type
locations = /,/pic
# route requests to this service if http basic auto user is abc
# route_by_http_user = abc
host_header_rewrite = example.com
# params with prefix "header_" will be used to update http request headers
header_X-From-Where = frp
Expand Down Expand Up @@ -348,3 +350,4 @@ multiplexer = httpconnect
local_ip = 127.0.0.1
local_port = 10701
custom_domains = tunnel1
# route_by_http_user = user1
3 changes: 3 additions & 0 deletions conf/frps_full.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ vhost_https_port = 443
# HTTP CONNECT requests. By default, this value is 0.
# tcpmux_httpconnect_port = 1337

# If tcpmux_passthrough is true, frps won't do any update on traffic.
# tcpmux_passthrough = false

# set dashboard_addr and dashboard_port to view dashboard of frps
# dashboard_addr's default value is same with bind_addr
# dashboard is available only if dashboard_port is set
Expand Down
15 changes: 0 additions & 15 deletions conf/systemd/frpc.service

This file was deleted.

15 changes: 0 additions & 15 deletions conf/systemd/frpc@.service

This file was deleted.

14 changes: 0 additions & 14 deletions conf/systemd/frps.service

This file was deleted.

14 changes: 0 additions & 14 deletions conf/systemd/frps@.service

This file was deleted.

12 changes: 5 additions & 7 deletions dockerfiles/Dockerfile-for-frpc
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
FROM alpine:3 AS temp
FROM golang:1.18 AS building

COPY bin/frpc /tmp

RUN chmod -R 777 /tmp/frpc
COPY . /building
WORKDIR /building

RUN make frpc

FROM alpine:3

WORKDIR /app

COPY --from=temp /tmp/frpc /usr/bin
COPY --from=building /building/bin/frpc /usr/bin/frpc

ENTRYPOINT ["/usr/bin/frpc"]
12 changes: 5 additions & 7 deletions dockerfiles/Dockerfile-for-frps
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
FROM alpine:3 AS temp
FROM golang:1.18 AS building

COPY bin/frps /tmp

RUN chmod -R 777 /tmp/frps
COPY . /building
WORKDIR /building

RUN make frps

FROM alpine:3

WORKDIR /app

COPY --from=temp /tmp/frps /usr/bin
COPY --from=building /building/bin/frps /usr/bin/frps

ENTRYPOINT ["/usr/bin/frps"]
13 changes: 10 additions & 3 deletions pkg/config/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ type HTTPProxyConf struct {
HTTPPwd string `ini:"http_pwd" json:"http_pwd"`
HostHeaderRewrite string `ini:"host_header_rewrite" json:"host_header_rewrite"`
Headers map[string]string `ini:"-" json:"headers"`
RouteByHTTPUser string `ini:"route_by_http_user" json:"route_by_http_user"`
}

// HTTPS
Expand All @@ -178,8 +179,9 @@ type TCPProxyConf struct {

// TCPMux
type TCPMuxProxyConf struct {
BaseProxyConf `ini:",extends"`
DomainConf `ini:",extends"`
BaseProxyConf `ini:",extends"`
DomainConf `ini:",extends"`
RouteByHTTPUser string `ini:"route_by_http_user" json:"route_by_http_user"`

Multiplexer string `ini:"multiplexer"`
}
Expand Down Expand Up @@ -576,7 +578,7 @@ func (cfg *TCPMuxProxyConf) Compare(cmp ProxyConf) bool {
return false
}

if cfg.Multiplexer != cmpConf.Multiplexer {
if cfg.Multiplexer != cmpConf.Multiplexer || cfg.RouteByHTTPUser != cmpConf.RouteByHTTPUser {
return false
}

Expand All @@ -601,6 +603,7 @@ func (cfg *TCPMuxProxyConf) UnmarshalFromMsg(pMsg *msg.NewProxy) {
cfg.CustomDomains = pMsg.CustomDomains
cfg.SubDomain = pMsg.SubDomain
cfg.Multiplexer = pMsg.Multiplexer
cfg.RouteByHTTPUser = pMsg.RouteByHTTPUser
}

func (cfg *TCPMuxProxyConf) MarshalToMsg(pMsg *msg.NewProxy) {
Expand All @@ -610,6 +613,7 @@ func (cfg *TCPMuxProxyConf) MarshalToMsg(pMsg *msg.NewProxy) {
pMsg.CustomDomains = cfg.CustomDomains
pMsg.SubDomain = cfg.SubDomain
pMsg.Multiplexer = cfg.Multiplexer
pMsg.RouteByHTTPUser = cfg.RouteByHTTPUser
}

func (cfg *TCPMuxProxyConf) CheckForCli() (err error) {
Expand Down Expand Up @@ -724,6 +728,7 @@ func (cfg *HTTPProxyConf) Compare(cmp ProxyConf) bool {
cfg.HTTPUser != cmpConf.HTTPUser ||
cfg.HTTPPwd != cmpConf.HTTPPwd ||
cfg.HostHeaderRewrite != cmpConf.HostHeaderRewrite ||
cfg.RouteByHTTPUser != cmpConf.RouteByHTTPUser ||
!reflect.DeepEqual(cfg.Headers, cmpConf.Headers) {
return false
}
Expand Down Expand Up @@ -754,6 +759,7 @@ func (cfg *HTTPProxyConf) UnmarshalFromMsg(pMsg *msg.NewProxy) {
cfg.HTTPUser = pMsg.HTTPUser
cfg.HTTPPwd = pMsg.HTTPPwd
cfg.Headers = pMsg.Headers
cfg.RouteByHTTPUser = pMsg.RouteByHTTPUser
}

func (cfg *HTTPProxyConf) MarshalToMsg(pMsg *msg.NewProxy) {
Expand All @@ -767,6 +773,7 @@ func (cfg *HTTPProxyConf) MarshalToMsg(pMsg *msg.NewProxy) {
pMsg.HTTPUser = cfg.HTTPUser
pMsg.HTTPPwd = cfg.HTTPPwd
pMsg.Headers = cfg.Headers
pMsg.RouteByHTTPUser = cfg.RouteByHTTPUser
}

func (cfg *HTTPProxyConf) CheckForCli() (err error) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ type ServerCommonConf struct {
// requests on one single port. If it's not - it will listen on this value for
// HTTP CONNECT requests. By default, this value is 0.
TCPMuxHTTPConnectPort int `ini:"tcpmux_httpconnect_port" json:"tcpmux_httpconnect_port" validate:"gte=0,lte=65535"`
// If TCPMuxPassthrough is true, frps won't do any update on traffic.
TCPMuxPassthrough bool `ini:"tcpmux_passthrough" json:"tcpmux_passthrough"`
// VhostHTTPTimeout specifies the response header timeout for the Vhost
// HTTP server, in seconds. By default, this value is 60.
VhostHTTPTimeout int64 `ini:"vhost_http_timeout" json:"vhost_http_timeout"`
Expand Down Expand Up @@ -188,6 +190,7 @@ func GetDefaultServerConf() ServerCommonConf {
VhostHTTPPort: 0,
VhostHTTPSPort: 0,
TCPMuxHTTPConnectPort: 0,
TCPMuxPassthrough: false,
VhostHTTPTimeout: 60,
DashboardAddr: "0.0.0.0",
DashboardPort: 0,
Expand Down
Loading

0 comments on commit fe5fb03

Please sign in to comment.