Skip to content

Commit 6e9d2d6

Browse files
committed
feat: add support for Android platform and RISC-V architecture in build script; update database connection string to enable WAL mode; bump dependencies for sqlite and other libraries; enhance remote shell feature with configuration check; add FAQ section to documentation
1 parent df0fa51 commit 6e9d2d6

File tree

16 files changed

+103
-64
lines changed

16 files changed

+103
-64
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ EXPOSE 9000
1919
# rpc port
2020
EXPOSE 9001
2121

22-
ENV DB_DSN /data/data.db
22+
ENV DB_DSN /data/data.db?_pragma=journal_mode(WAL)
2323

2424
ENTRYPOINT [ "/app/frp-panel" ]
2525

Dockerfile.standalone

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ EXPOSE 9000
5151
# rpc port
5252
EXPOSE 9001
5353

54-
ENV DB_DSN=/data/data.db
54+
ENV DB_DSN=/data/data.db?_pragma=journal_mode(WAL)
5555
ENTRYPOINT ["/app/frp-panel"]
5656
CMD ["master"]

biz/common/pty.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ import (
1313
)
1414

1515
func StartPTYConnect(c *app.Context, req *pb.CommonRequest, initMsg *pb.PTYClientMessage) (*pb.CommonResponse, error) {
16+
cfg := c.GetApp().GetConfig()
17+
18+
if !cfg.Client.Features.EnableRemoteShell {
19+
logger.Logger(c).Warn("remote shell is disabled, please set `CLIENT_FEATURES_ENABLE_REMOTE_SHELL=true` to enable remote shell")
20+
return nil, fmt.Errorf("remote shell is disabled, please set `CLIENT_FEATURES_ENABLE_REMOTE_SHELL=true` to enable remote shell")
21+
}
22+
1623
conn, err := c.GetApp().GetClientRPCHandler().GetCli().Call().PTYConnect(c)
1724
if err != nil {
1825
logger.Logger(c).WithError(err).Infof("rpc connect master error")

biz/master/client/helper.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func MakeClientShadowed(c *app.Context, serverID string, clientEntity *models.Cl
4747
var childClient *models.ClientEntity
4848
var err error
4949
if len(clientEntity.ConfigContent) != 0 {
50-
childClient, err = ChildClientForServer(c, serverID, clientEntity)
50+
childClient, _, err = ChildClientForServer(c, serverID, clientEntity)
5151
if err != nil {
5252
logger.Logger(c).WithError(err).Errorf("cannot create child client, id: [%s]", clientID)
5353
return nil, err
@@ -76,7 +76,8 @@ func MakeClientShadowed(c *app.Context, serverID string, clientEntity *models.Cl
7676
}
7777

7878
// ChildClientForServer 支持传入serverID和任意类型client,返回serverID对应的client in shadow,如果不存在则新建
79-
func ChildClientForServer(c *app.Context, serverID string, clientEntity *models.ClientEntity) (*models.ClientEntity, error) {
79+
// bool 表示是否新建
80+
func ChildClientForServer(c *app.Context, serverID string, clientEntity *models.ClientEntity) (*models.ClientEntity, bool, error) {
8081
userInfo := common.GetUserInfo(c)
8182

8283
originClientID := clientEntity.ClientID
@@ -89,19 +90,19 @@ func ChildClientForServer(c *app.Context, serverID string, clientEntity *models.
8990
OriginClientID: originClientID,
9091
}, lo.ToPtr(false))
9192
if err == nil {
92-
return existClient, nil
93+
return existClient, false, nil
9394
}
9495

9596
shadowCount, err := dao.NewQuery(c).CountClientsInShadow(userInfo, originClientID)
9697
if err != nil {
9798
logger.Logger(c).WithError(err).Errorf("cannot count shadow clients, id: [%s]", originClientID)
98-
return nil, err
99+
return nil, false, err
99100
}
100101

101102
copiedClient := &models.ClientEntity{}
102103
if err := deepcopy.Copy(copiedClient, clientEntity); err != nil {
103104
logger.Logger(c).WithError(err).Errorf("cannot copy client, id: [%s]", originClientID)
104-
return nil, err
105+
return nil, false, err
105106
}
106107
copiedClient.ServerID = serverID
107108
copiedClient.ClientID = app.ShadowedClientID(originClientID, shadowCount+1)
@@ -110,10 +111,10 @@ func ChildClientForServer(c *app.Context, serverID string, clientEntity *models.
110111
copiedClient.Stopped = false
111112
if err := dao.NewQuery(c).CreateClient(userInfo, copiedClient); err != nil {
112113
logger.Logger(c).WithError(err).Errorf("cannot create child client, id: [%s]", copiedClient.ClientID)
113-
return nil, err
114+
return nil, false, err
114115
}
115116

116-
return copiedClient, nil
117+
return copiedClient, true, nil
117118
}
118119

119120
func ValidFrpsScheme(scheme string) bool {

biz/master/client/update_tunnel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func UpdateFrpcHander(c *app.Context, req *pb.UpdateFRPCRequest) (*pb.UpdateFRPC
4747
cli := cliRecord.ClientEntity
4848

4949
if cli.IsShadow {
50-
cli, err = ChildClientForServer(c, serverID, cli)
50+
cli, _, err = ChildClientForServer(c, serverID, cli)
5151
if err != nil {
5252
logger.Logger(c).WithError(err).Errorf("cannot get child client, id: [%s]", reqClientID)
5353
return &pb.UpdateFRPCResponse{

biz/master/proxy/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func GetClientWithMakeShadow(c *app.Context, clientID, serverID string) (*models
5151
}
5252
}
5353
// shadow过,但没找到子客户端,需要新建
54-
clientEntity, err = client.ChildClientForServer(c, serverID, clientEntity)
54+
clientEntity, _, err = client.ChildClientForServer(c, serverID, clientEntity)
5555
if err != nil {
5656
logger.Logger(c).WithError(err).Errorf("cannot create child client, id: [%s]", clientID)
5757
return nil, err

biz/master/proxy/update_proxy_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func UpdateProxyConfig(c *app.Context, req *pb.UpdateProxyConfigRequest) (*pb.Up
4444
return nil, err
4545
}
4646

47-
clientEntity, err = client.ChildClientForServer(c, serverID, originClient.ClientEntity)
47+
clientEntity, _, err = client.ChildClientForServer(c, serverID, originClient.ClientEntity)
4848
if err != nil {
4949
logger.Logger(c).WithError(err).Errorf("cannot create child client, id: [%s]", clientID)
5050
return nil, err

build.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ build_binary() {
116116
# Platforms array
117117
PLATFORMS=()
118118
if [[ "$PLATFORM" == "all" ]]; then
119-
PLATFORMS=("windows" "linux" "darwin")
119+
PLATFORMS=("windows" "linux" "darwin" "android")
120120
else
121121
PLATFORMS=("$PLATFORM")
122122
fi
123123

124124
# Architectures array
125125
ARCHS=()
126126
if [[ "$ARCH" == "all" ]]; then
127-
ARCHS=("amd64" "arm64" "arm")
127+
ARCHS=("amd64" "arm64" "arm" "riscv64")
128128
else
129129
ARCHS=("$ARCH")
130130
fi
@@ -141,9 +141,11 @@ fi
141141
for platform in "${PLATFORMS[@]}"; do
142142
for arch in "${ARCHS[@]}"; do
143143
for bintype in "${BINTYPES[@]}"; do
144+
# 设置darwin和windows的白名单arch,只能是 arm64 amd64
145+
if [[ "$platform" == "darwin" && "$arch" != "arm64" && "$arch" != "amd64" ]]; then continue; fi
146+
if [[ "$platform" == "windows" && "$arch" != "arm64" && "$arch" != "amd64" ]]; then continue; fi
147+
if [[ "$platform" == "android" && "$arch" != "arm64" ]]; then continue; fi
144148
echo "Building $bintype binary for $platform-$arch"
145-
if [[ "$platform" == "darwin" && "$arch" == "arm" ]]; then continue; fi
146-
if [[ "$platform" == "windows" && "$arch" == "arm" ]]; then continue; fi
147149
build_binary "$platform" "$arch" "$bintype"
148150
done
149151
done

conf/settings.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type Config struct {
4545
} `env-prefix:"SERVER_"`
4646
DB struct {
4747
Type string `env:"TYPE" env-default:"sqlite3" env-description:"db type, mysql or sqlite3 and so on"`
48-
DSN string `env:"DSN" env-default:"/data/data.db" env-description:"db dsn, for sqlite is path, other is dsn, look at https://github.com/go-sql-driver/mysql#dsn-data-source-name"`
48+
DSN string `env:"DSN" env-default:"/data/data.db?_pragma=journal_mode(WAL)" env-description:"db dsn, for sqlite is path, other is dsn, look at https://github.com/go-sql-driver/mysql#dsn-data-source-name"`
4949
} `env-prefix:"DB_"`
5050
Client struct {
5151
ID string `env:"ID" env-description:"client id"`
@@ -64,7 +64,8 @@ type Config struct {
6464
} `env-prefix:"WORKERD_DOWNLOAD_URL_" env-description:"workerd download url"`
6565
} `env-prefix:"WORKER_" env-description:"worker's config"`
6666
Features struct {
67-
EnableFunctions bool `env:"ENABLE_FUNCTIONS" env-default:"true" env-description:"enable functions"`
67+
EnableFunctions bool `env:"ENABLE_FUNCTIONS" env-default:"true" env-description:"enable functions"`
68+
EnableRemoteShell bool `env:"ENABLE_REMOTE_SHELL" env-default:"true" env-description:"enable remote shell"`
6869
} `env-prefix:"FEATURES_" env-description:"features config"`
6970
} `env-prefix:"CLIENT_"`
7071
IsDebug bool `env:"IS_DEBUG" env-default:"false" env-description:"is debug mode"`

docs/.vitepress/config/en.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export const enConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
2727
collapsed: false,
2828
link: "/en/contribute",
2929
},
30+
{
31+
text: "FAQ",
32+
collapsed: false,
33+
link: "/en/faq",
34+
},
3035
{
3136
text: "Screenshots",
3237
collapsed: false,

0 commit comments

Comments
 (0)