Skip to content

Commit df0fa51

Browse files
committed
feat: rpc url and api url settings on front
1 parent e5bb9db commit df0fa51

File tree

17 files changed

+433
-77
lines changed

17 files changed

+433
-77
lines changed

conf/helper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ func FRPsAuthOption(cfg Config, isDefault bool) v1.HTTPPluginOptions {
4141
if isDefault {
4242
port = cfg.Master.APIPort
4343
} else {
44-
port = cfg.Master.InternalFRPAuthServerPort
44+
port = cfg.Server.InternalFRPAuthServerPort
4545
}
4646
authUrl, err := url.Parse(fmt.Sprintf("http://%s:%d%s",
47-
cfg.Master.InternalFRPAuthServerHost,
47+
cfg.Server.InternalFRPAuthServerHost,
4848
port,
49-
cfg.Master.InternalFRPAuthServerPath))
49+
cfg.Server.InternalFRPAuthServerPath))
5050
if err != nil {
5151
logger.Logger(context.Background()).WithError(err).Fatalf("parse auth url error")
5252
}

conf/settings.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ type Config struct {
2929
GithubProxyUrl string `env:"GITHUB_PROXY_URL" env-default:"https://ghfast.top/" env-description:"github proxy url"`
3030
} `env-prefix:"APP_"`
3131
Master struct {
32-
APIPort int `env:"API_PORT" env-default:"9000" env-description:"master api port"`
33-
APIHost string `env:"API_HOST" env-description:"master host, can behind proxy like cdn"`
34-
APIScheme string `env:"API_SCHEME" env-default:"http" env-description:"master api scheme"`
35-
CacheSize int `env:"CACHE_SIZE" env-default:"10" env-description:"cache size in MB"`
36-
RPCHost string `env:"RPC_HOST" env-default:"127.0.0.1" env-description:"master host, is a public ip or domain"`
37-
RPCPort int `env:"RPC_PORT" env-default:"9001" env-description:"master rpc port"`
38-
InternalFRPServerHost string `env:"INTERNAL_FRP_SERVER_HOST" env-description:"internal frp server host, used for client connection"`
32+
APIPort int `env:"API_PORT" env-default:"9000" env-description:"master api port"`
33+
APIHost string `env:"API_HOST" env-description:"master host, can behind proxy like cdn"`
34+
APIScheme string `env:"API_SCHEME" env-default:"http" env-description:"master api scheme"`
35+
CacheSize int `env:"CACHE_SIZE" env-default:"10" env-description:"cache size in MB"`
36+
RPCHost string `env:"RPC_HOST" env-default:"127.0.0.1" env-description:"master host, is a public ip or domain"`
37+
RPCPort int `env:"RPC_PORT" env-default:"9001" env-description:"master rpc port"`
38+
InternalFRPServerHost string `env:"INTERNAL_FRP_SERVER_HOST" env-description:"internal frp server host, used for client connection"`
39+
} `env-prefix:"MASTER_"`
40+
Server struct {
41+
APIPort int `env:"API_PORT" env-default:"8999" env-description:"server api port"`
3942
InternalFRPAuthServerHost string `env:"INTERNAL_FRP_AUTH_SERVER_HOST" env-default:"127.0.0.1" env-description:"internal frp auth server host"`
4043
InternalFRPAuthServerPort int `env:"INTERNAL_FRP_AUTH_SERVER_PORT" env-default:"8999" env-description:"internal frp auth server port"`
4144
InternalFRPAuthServerPath string `env:"INTERNAL_FRP_AUTH_SERVER_PATH" env-default:"/auth" env-description:"internal frp auth server path"`
42-
} `env-prefix:"MASTER_"`
43-
Server struct {
44-
APIPort int `env:"API_PORT" env-default:"8999" env-description:"server api port"`
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"`

docs/deploy-server.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Server 推荐使用 docker 部署!不推荐直接安装到服务器中
44

55
注意 ⚠️:client 和 server 的启动指令可能会随着项目更新而改变,虽然在项目迭代时会注意前后兼容,但仍难以完全适配,因此 client 和 server 的启动指令以 master 生成为准
66

7+
> `default` 服务端禁止单独部署,直接在 webui 中配置即可。重复部署会造成 `default` 服务端无法正常工作。
8+
9+
> `server` 会占用 8999 端口,请确保该端口未被占用。如果冲突,请修改 `server``SERVER_API_PORT``INTERNAL_FRP_AUTH_SERVER_PORT` 环境变量,要确保两个端口一致。`default` 服务端也会占用这个端口,因此不能在同一台机器以**默认配置**部署 `server``default` 服务端,需要修改 `server` 的环境变量来避免冲突。
10+
711
> 如果只有一台公网服务器需要管理,那么使用 `master` 自带的 `default` 服务端即可,无需单独部署 `server`,但要注意在 `master` 启动后要配置 `default` 服务端
812
913
## 在 Linux 上部署

docs/en/deploy-server.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ We recommend deploying the Server via Docker! Direct installation on the host is
44

55
**Note ⚠️:** The startup commands for `client` and `server` may change as the project evolves. Although we strive for backward compatibility, the commands generated by the Master’s web UI should be treated as authoritative.
66

7+
> The `default` server cannot be deployed separately. It should be configured in the webui. Repeated deployment will cause the `default` server to malfunction.
8+
9+
> The `server` will occupy port 8999. Please ensure that this port is not occupied. If there is a conflict, please modify the `SERVER_API_PORT` and `INTERNAL_FRP_AUTH_SERVER_PORT` environment variables of the `server`, ensuring that the two ports are the same. The `default` server will also occupy this port, so you cannot deploy the `server` and `default` server on the same machine with **default configuration**. You need to modify the environment variables of the `server` to avoid conflicts.
10+
711
> If you only have one public-facing server to manage, you can use the Master’s built-in `default` server without deploying a separate Server. Remember to configure the `default` server after starting the Master.
812
913
## Deploying on Linux

www/components/frpc/client_item.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { useMutation, useQuery } from '@tanstack/react-query'
2626
import { deleteClient, listClient } from '@/api/client'
2727
import { useRouter } from 'next/router'
2828
import { useStore } from '@nanostores/react'
29-
import { $frontendPreference, $platformInfo, $useServerGithubProxyUrl } from '@/store/user'
29+
import { $frontendPreference, $platformInfo } from '@/store/user'
3030
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
3131
import { getClientsStatus } from '@/api/platform'
3232
import { Client, ClientType } from '@/lib/pb/common'
@@ -125,7 +125,6 @@ export const columns: ColumnDef<ClientTableSchema>[] = [
125125
export const ClientID = ({ client }: { client: ClientTableSchema }) => {
126126
const { t } = useTranslation()
127127
const platformInfo = useStore($platformInfo)
128-
const useGithubProxyUrl = useStore($useServerGithubProxyUrl)
129128
const frontendPreference = useStore($frontendPreference)
130129

131130
if (!platformInfo) {
@@ -152,7 +151,9 @@ export const ClientID = ({ client }: { client: ClientTableSchema }) => {
152151
<div className="grid gap-2">
153152
<div className="grid grid-cols-2 items-center gap-4 justify-items-center">
154153
<Label>{t('client.install.use_github_proxy_url')}</Label>
155-
<Checkbox onCheckedChange={$useServerGithubProxyUrl.set} defaultChecked={useGithubProxyUrl} />
154+
<Checkbox onCheckedChange={(checked) => {
155+
$frontendPreference.set({ ...frontendPreference, useServerGithubProxyUrl: checked === 'indeterminate' ? false : checked })
156+
}} defaultChecked={frontendPreference.useServerGithubProxyUrl} />
156157
</div>
157158
<div className="grid grid-cols-2 items-center gap-4 justify-items-center">
158159
<Label>{t('client.install.github_proxy_url')}</Label>
@@ -165,8 +166,8 @@ export const ClientID = ({ client }: { client: ClientTableSchema }) => {
165166
navigator.clipboard.writeText(
166167
WindowsInstallCommand('client', client, {
167168
...platformInfo,
168-
githubProxyUrl: useGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
169-
}, useGithubProxyUrl),
169+
githubProxyUrl: frontendPreference.useServerGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
170+
}, frontendPreference.useServerGithubProxyUrl),
170171
)
171172
}
172173
disabled={!platformInfo}
@@ -179,8 +180,8 @@ export const ClientID = ({ client }: { client: ClientTableSchema }) => {
179180
readOnly
180181
value={WindowsInstallCommand('client', client, {
181182
...platformInfo,
182-
githubProxyUrl: useGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
183-
}, useGithubProxyUrl)}
183+
githubProxyUrl: frontendPreference.useServerGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
184+
}, frontendPreference.useServerGithubProxyUrl)}
184185
className="flex-1"
185186
/>
186187
</div>
@@ -189,8 +190,8 @@ export const ClientID = ({ client }: { client: ClientTableSchema }) => {
189190
onClick={() =>
190191
navigator.clipboard.writeText(LinuxInstallCommand('client', client, {
191192
...platformInfo,
192-
githubProxyUrl: useGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
193-
}, useGithubProxyUrl))
193+
githubProxyUrl: frontendPreference.useServerGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
194+
}, frontendPreference.useServerGithubProxyUrl))
194195
}
195196
disabled={!platformInfo}
196197
size="sm"
@@ -202,8 +203,8 @@ export const ClientID = ({ client }: { client: ClientTableSchema }) => {
202203
readOnly
203204
value={LinuxInstallCommand('client', client, {
204205
...platformInfo,
205-
githubProxyUrl: useGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
206-
}, useGithubProxyUrl)}
206+
githubProxyUrl: frontendPreference.useServerGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
207+
}, frontendPreference.useServerGithubProxyUrl)}
207208
className="flex-1"
208209
/>
209210
</div>
@@ -344,7 +345,6 @@ export const ClientActions: React.FC<ClientItemProps> = ({ client, table }) => {
344345
const { t } = useTranslation()
345346
const router = useRouter()
346347
const platformInfo = useStore($platformInfo)
347-
const useGithubProxyUrl = useStore($useServerGithubProxyUrl)
348348
const frontendPreference = useStore($frontendPreference)
349349

350350
const removeClient = useMutation({
@@ -433,8 +433,8 @@ export const ClientActions: React.FC<ClientItemProps> = ({ client, table }) => {
433433
if (platformInfo) {
434434
navigator.clipboard.writeText(LinuxInstallCommand('client', client, {
435435
...platformInfo,
436-
githubProxyUrl: useGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
437-
}, useGithubProxyUrl))
436+
githubProxyUrl: frontendPreference.useServerGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
437+
}, frontendPreference.useServerGithubProxyUrl))
438438
toast(t('client.actions_menu.copy_success'))
439439
} else {
440440
toast(t('client.actions_menu.copy_failed'))

www/components/frps/server_item.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import {
2020
DropdownMenuSeparator,
2121
DropdownMenuTrigger,
2222
} from '@/components/ui/dropdown-menu'
23-
import React, { useState } from 'react'
23+
import React from 'react'
2424
import { ClientEnvFile, ExecCommandStr, LinuxInstallCommand, WindowsInstallCommand } from '@/lib/consts'
2525
import { useMutation, useQuery } from '@tanstack/react-query'
2626
import { deleteServer } from '@/api/server'
2727
import { useRouter } from 'next/router'
2828
import { useStore } from '@nanostores/react'
29-
import { $frontendPreference, $platformInfo, $useServerGithubProxyUrl } from '@/store/user'
29+
import { $frontendPreference, $platformInfo } from '@/store/user'
3030
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
3131
import { getClientsStatus } from '@/api/platform'
3232
import { ClientType } from '@/lib/pb/common'
@@ -124,7 +124,6 @@ export const columns: ColumnDef<ServerTableSchema>[] = [
124124
export const ServerID = ({ server }: { server: ServerTableSchema }) => {
125125
const { t } = useTranslation()
126126
const platformInfo = useStore($platformInfo)
127-
const useGithubProxyUrl = useStore($useServerGithubProxyUrl)
128127
const frontendPreference = useStore($frontendPreference)
129128

130129
if (!platformInfo) {
@@ -151,7 +150,9 @@ export const ServerID = ({ server }: { server: ServerTableSchema }) => {
151150
<div className="grid gap-2">
152151
<div className="grid grid-cols-2 items-center gap-4 justify-items-center">
153152
<Label>{t('client.install.use_github_proxy_url')}</Label>
154-
<Checkbox onCheckedChange={$useServerGithubProxyUrl.set} defaultChecked={useGithubProxyUrl} />
153+
<Checkbox onCheckedChange={(checked) => {
154+
$frontendPreference.set({ ...frontendPreference, useServerGithubProxyUrl: checked === 'indeterminate' ? false : checked })
155+
}} defaultChecked={frontendPreference.useServerGithubProxyUrl} />
155156
</div>
156157
<div className="grid grid-cols-2 items-center gap-4 justify-items-center">
157158
<Label>{t('client.install.github_proxy_url')}</Label>
@@ -162,8 +163,8 @@ export const ServerID = ({ server }: { server: ServerTableSchema }) => {
162163
<Button
163164
onClick={() => navigator.clipboard.writeText(WindowsInstallCommand('server', server, {
164165
...platformInfo,
165-
githubProxyUrl: useGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
166-
}, useGithubProxyUrl))}
166+
githubProxyUrl: frontendPreference.useServerGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
167+
}, frontendPreference.useServerGithubProxyUrl))}
167168
disabled={!platformInfo}
168169
size="sm"
169170
variant="outline"
@@ -174,17 +175,17 @@ export const ServerID = ({ server }: { server: ServerTableSchema }) => {
174175
readOnly
175176
value={WindowsInstallCommand('server', server, {
176177
...platformInfo,
177-
githubProxyUrl: useGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
178-
}, useGithubProxyUrl)}
178+
githubProxyUrl: frontendPreference.useServerGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
179+
}, frontendPreference.useServerGithubProxyUrl)}
179180
className="flex-1"
180181
/>
181182
</div>
182183
<div className="grid grid-cols-2 items-center gap-4">
183184
<Button
184185
onClick={() => navigator.clipboard.writeText(LinuxInstallCommand('server', server, {
185186
...platformInfo,
186-
githubProxyUrl: useGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
187-
}, useGithubProxyUrl))}
187+
githubProxyUrl: frontendPreference.useServerGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
188+
}, frontendPreference.useServerGithubProxyUrl))}
188189
disabled={!platformInfo}
189190
size="sm"
190191
variant="outline"
@@ -195,8 +196,8 @@ export const ServerID = ({ server }: { server: ServerTableSchema }) => {
195196
readOnly
196197
value={LinuxInstallCommand('server', server, {
197198
...platformInfo,
198-
githubProxyUrl: useGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
199-
}, useGithubProxyUrl)}
199+
githubProxyUrl: frontendPreference.useServerGithubProxyUrl && frontendPreference.githubProxyUrl ? frontendPreference.githubProxyUrl : platformInfo.githubProxyUrl,
200+
}, frontendPreference.useServerGithubProxyUrl)}
200201
className="flex-1"
201202
/>
202203
</div>

www/components/nav-user.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import {
44
ChevronsUpDown,
55
LogOut,
6+
SettingsIcon,
67
User as UserIcon, // 别名避免和 User 类型冲突
78
} from 'lucide-react'
89
import Link from 'next/link'
@@ -67,13 +68,18 @@ export function NavUser({ user }: NavUserProps) {
6768
</div>
6869
</DropdownMenuLabel>
6970

70-
{/* 使用 next/link 创建 “User Info” 菜单项 */}
7171
<DropdownMenuItem asChild>
7272
<Link href="/user-info" className="w-full flex items-center space-x-2">
7373
<UserIcon className="h-4 w-4" />
7474
<span>{t('common.userInfo')}</span>
7575
</Link>
7676
</DropdownMenuItem>
77+
<DropdownMenuItem asChild>
78+
<Link href="/platform-settings" className="w-full flex items-center space-x-2">
79+
<SettingsIcon className="h-4 w-4" />
80+
<span>{t('平台设置')}</span>
81+
</Link>
82+
</DropdownMenuItem>
7783

7884
<DropdownMenuSeparator />
7985

0 commit comments

Comments
 (0)