Compare commits

..

1 Commits

Author SHA1 Message Date
fatedier
97dcb1e34b refactor: separate API handlers into dedicated packages with improved HTTP utilities 2026-01-14 19:43:49 +08:00
28 changed files with 6085 additions and 12637 deletions

View File

@@ -6,14 +6,6 @@ jobs:
resource_class: large
steps:
- checkout
- run:
name: Build web assets (frps)
command: make install build
working_directory: web/frps
- run:
name: Build web assets (frpc)
command: make install build
working_directory: web/frpc
- run: make
- run: make alltest

View File

@@ -19,15 +19,6 @@ jobs:
with:
go-version: '1.24'
cache: false
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Build web assets (frps)
run: make install build
working-directory: web/frps
- name: Build web assets (frpc)
run: make install build
working-directory: web/frpc
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:

View File

@@ -16,21 +16,13 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: '1.24'
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Build web assets (frps)
run: make install build
working-directory: web/frps
- name: Build web assets (frpc)
run: make install build
working-directory: web/frpc
- name: Make All
run: |
./package.sh
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean --release-notes=./Release.md

View File

@@ -2,22 +2,19 @@ export PATH := $(PATH):`go env GOPATH`/bin
export GO111MODULE=on
LDFLAGS := -s -w
.PHONY: web frps-web frpc-web frps frpc
all: env fmt web build
all: env fmt build
build: frps frpc
env:
@go version
web: frps-web frpc-web
frps-web:
$(MAKE) -C web/frps build
frpc-web:
$(MAKE) -C web/frpc build
# 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
fmt:
go fmt ./...
@@ -28,7 +25,7 @@ fmt-more:
gci:
gci write -s standard -s default -s "prefix(github.com/fatedier/frp/)" ./
vet: web
vet:
go vet ./...
frps:
@@ -39,7 +36,7 @@ frpc:
test: gotest
gotest: web
gotest:
go test -v --cover ./assets/...
go test -v --cover ./cmd/...
go test -v --cover ./client/...

View File

@@ -14,12 +14,12 @@ frp is an open source project with its ongoing development made possible entirel
<h3 align="center">Gold Sponsors</h3>
<!--gold sponsors start-->
<p align="center">
<a href="https://requestly.com/?utm_source=github&utm_medium=partnered&utm_campaign=frp" target="_blank">
<img width="480px" src="https://github.com/user-attachments/assets/24670320-997d-4d62-9bca-955c59fe883d">
<a href="https://go.warp.dev/frp" target="_blank">
<img width="360px" src="https://raw.githubusercontent.com/warpdotdev/brand-assets/refs/heads/main/Github/Sponsor/Warp-Github-LG-01.png">
<br>
<b>Requestly - Free & Open-Source alternative to Postman</b>
<b>Warp, built for collaborating with AI Agents</b>
<br>
<sub>All-in-one platform to Test, Mock and Intercept APIs.</sub>
<sub>Available for macOS, Linux and Windows</sub>
</a>
</p>
@@ -49,6 +49,15 @@ If you're looking for a meeting recording API, consider checking out [Recall.ai]
an API that records Zoom, Google Meet, Microsoft Teams, in-person meetings, and more.
</div>
<p align="center">
<a href="https://requestly.com/?utm_source=github&utm_medium=partnered&utm_campaign=frp" target="_blank">
<img width="480px" src="https://github.com/user-attachments/assets/24670320-997d-4d62-9bca-955c59fe883d">
<br>
<b>Requestly - Free & Open-Source alternative to Postman</b>
<br>
<sub>All-in-one platform to Test, Mock and Intercept APIs.</sub>
</a>
</p>
<!--gold sponsors end-->
## What is frp?

View File

@@ -16,12 +16,12 @@ frp 是一个完全开源的项目,我们的开发工作完全依靠赞助者
<h3 align="center">Gold Sponsors</h3>
<!--gold sponsors start-->
<p align="center">
<a href="https://requestly.com/?utm_source=github&utm_medium=partnered&utm_campaign=frp" target="_blank">
<img width="480px" src="https://github.com/user-attachments/assets/24670320-997d-4d62-9bca-955c59fe883d">
<a href="https://go.warp.dev/frp" target="_blank">
<img width="360px" src="https://raw.githubusercontent.com/warpdotdev/brand-assets/refs/heads/main/Github/Sponsor/Warp-Github-LG-01.png">
<br>
<b>Requestly - Free & Open-Source alternative to Postman</b>
<b>Warp, built for collaborating with AI Agents</b>
<br>
<sub>All-in-one platform to Test, Mock and Intercept APIs.</sub>
<sub>Available for macOS, Linux and Windows</sub>
</a>
</p>
@@ -51,6 +51,15 @@ If you're looking for a meeting recording API, consider checking out [Recall.ai]
an API that records Zoom, Google Meet, Microsoft Teams, in-person meetings, and more.
</div>
<p align="center">
<a href="https://requestly.com/?utm_source=github&utm_medium=partnered&utm_campaign=frp" target="_blank">
<img width="480px" src="https://github.com/user-attachments/assets/24670320-997d-4d62-9bca-955c59fe883d">
<br>
<b>Requestly - Free & Open-Source alternative to Postman</b>
<br>
<sub>All-in-one platform to Test, Mock and Intercept APIs.</sub>
</a>
</p>
<!--gold sponsors end-->
## 为什么使用 frp

View File

@@ -41,7 +41,7 @@ func Load(path string) {
}
func Register(fileSystem fs.FS) {
subFs, err := fs.Sub(fileSystem, "dist")
subFs, err := fs.Sub(fileSystem, "static")
if err == nil {
content = subFs
}

View File

@@ -6,9 +6,9 @@ import (
"github.com/fatedier/frp/assets"
)
//go:embed dist
var EmbedFS embed.FS
//go:embed static/*
var content embed.FS
func init() {
assets.Register(EmbedFS)
assets.Register(content)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>frp client</title>
<script type="module" crossorigin src="./index-BAsh6RH1.js"></script>
<link rel="stylesheet" crossorigin href="./index-JCcyRUo1.css">
</head>
<body>
<div id="app"></div>
</body>
</html>

14
assets/frps/embed.go Normal file
View File

@@ -0,0 +1,14 @@
package frpc
import (
"embed"
"github.com/fatedier/frp/assets"
)
//go:embed static/*
var content embed.FS
func init() {
assets.Register(content)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="utf-8">
<title>frp server</title>
<script type="module" crossorigin src="./index-r9B2t7lx.js"></script>
<link rel="stylesheet" crossorigin href="./index-Cl4R6mJh.css">
</head>
<body>
<div id="app"></div>
</body>
</html>

View File

@@ -15,9 +15,9 @@
package main
import (
_ "github.com/fatedier/frp/assets/frpc"
"github.com/fatedier/frp/cmd/frpc/sub"
"github.com/fatedier/frp/pkg/util/system"
_ "github.com/fatedier/frp/web/frpc"
)
func main() {

View File

@@ -15,9 +15,9 @@
package main
import (
_ "github.com/fatedier/frp/assets/frps"
_ "github.com/fatedier/frp/pkg/metrics"
"github.com/fatedier/frp/pkg/util/system"
_ "github.com/fatedier/frp/web/frps"
)
func main() {

View File

@@ -1,17 +1,9 @@
FROM node:22 AS web-builder
WORKDIR /web/frpc
COPY web/frpc/ ./
RUN npm install
RUN npm run build
FROM golang:1.24 AS building
COPY . /building
COPY --from=web-builder /web/frpc/dist /building/web/frpc/dist
WORKDIR /building
RUN env CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -tags frpc -o bin/frpc ./cmd/frpc
RUN make frpc
FROM alpine:3

View File

@@ -1,17 +1,9 @@
FROM node:22 AS web-builder
WORKDIR /web/frps
COPY web/frps/ ./
RUN npm install
RUN npm run build
FROM golang:1.24 AS building
COPY . /building
COPY --from=web-builder /web/frps/dist /building/web/frps/dist
WORKDIR /building
RUN env CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -tags frps -o bin/frps ./cmd/frps
RUN make frps
FROM alpine:3

View File

@@ -1,7 +1,4 @@
.PHONY: dist install build preview lint
install:
@npm install
.PHONY: dist build preview lint
build:
@npm run build

File diff suppressed because it is too large Load Diff

2975
web/frpc/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,4 @@
.PHONY: dist install build preview lint
install:
@npm install
.PHONY: dist build preview lint
build:
@npm run build

View File

@@ -1,14 +0,0 @@
package frps
import (
"embed"
"github.com/fatedier/frp/assets"
)
//go:embed dist
var EmbedFS embed.FS
func init() {
assets.Register(EmbedFS)
}

File diff suppressed because it is too large Load Diff

3015
web/frps/yarn.lock Normal file

File diff suppressed because it is too large Load Diff