mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2026-02-04 21:30:36 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b66fc3c06d | ||
|
|
ab2e1a9236 | ||
|
|
ab77b400a1 | ||
|
|
eb7ab63563 | ||
|
|
4cf7d01622 | ||
|
|
a876078a9c | ||
|
|
495f2ae3c6 | ||
|
|
4e6d11baf0 |
45
README.md
45
README.md
@@ -49,21 +49,22 @@
|
|||||||
### API 服务
|
### API 服务
|
||||||
基本实现了PC端基础的接口。支持Personal版本接口,可以通过配置文件`rustdesk.personal`或环境变量`RUSTDESK_API_RUSTDESK_PERSONAL`来控制是否启用
|
基本实现了PC端基础的接口。支持Personal版本接口,可以通过配置文件`rustdesk.personal`或环境变量`RUSTDESK_API_RUSTDESK_PERSONAL`来控制是否启用
|
||||||
|
|
||||||
#### 登录
|
<table>
|
||||||
|
<tr>
|
||||||
- 添加了`github`, `google` 以及`OIDC`授权登录,需要在后台配置好就可以用了,具体可看后台OAuth配置
|
<td width="50%" align="center" colspan="2"><b>登录</b></td>
|
||||||
- 添加了web后台授权登录,点击后直接登录后台就自动登录客户端了
|
</tr>
|
||||||
|
<tr>
|
||||||

|
<td width="50%" align="center" colspan="2"><img src="docs/pc_login.png"></td>
|
||||||
|
</tr>
|
||||||
#### 地址簿
|
<tr>
|
||||||
|
<td width="50%" align="center"><b>地址簿</b></td>
|
||||||

|
<td width="50%" align="center"><b>群组</b></td>
|
||||||
|
</tr>
|
||||||
#### 群组
|
<tr>
|
||||||
群组分为`共享组`和`普通组`,共享组中所有人都能看到小组成员的设备,普通组只有管理员能看到所有小组成员的设备
|
<td width="50%" align="center"><img src="docs/pc_ab.png"></td>
|
||||||
|
<td width="50%" align="center"><img src="docs/pc_gr.png"></td>
|
||||||

|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
### Web Admin:
|
### Web Admin:
|
||||||
|
|
||||||
@@ -75,6 +76,7 @@
|
|||||||

|

|
||||||
2. 普通用户界面
|
2. 普通用户界面
|
||||||

|

|
||||||
|
|
||||||
右上角可以更改密码,可以切换语言,可以切换`白天/黑夜`模式
|
右上角可以更改密码,可以切换语言,可以切换`白天/黑夜`模式
|
||||||
|
|
||||||

|

|
||||||
@@ -330,4 +332,15 @@ jwt:
|
|||||||
- [WIKI](https://github.com/lejianwen/rustdesk-api/wiki)
|
- [WIKI](https://github.com/lejianwen/rustdesk-api/wiki)
|
||||||
- [链接超时问题](https://github.com/lejianwen/rustdesk-api/issues/92)
|
- [链接超时问题](https://github.com/lejianwen/rustdesk-api/issues/92)
|
||||||
- [修改客户端ID](https://github.com/abdullah-erturk/RustDesk-ID-Changer)
|
- [修改客户端ID](https://github.com/abdullah-erturk/RustDesk-ID-Changer)
|
||||||
- [webclient来源](https://hub.docker.com/r/keyurbhole/flutter_web_desk)
|
- [webclient来源](https://hub.docker.com/r/keyurbhole/flutter_web_desk)
|
||||||
|
|
||||||
|
|
||||||
|
## 鸣谢
|
||||||
|
|
||||||
|
感谢所有做过贡献的人!
|
||||||
|
|
||||||
|
<a href="https://github.com/lejianwen/rustdesk-api/graphs/contributors">
|
||||||
|
<img src="https://contrib.rocks/image?repo=lejianwen/rustdesk-api" />
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
42
README_EN.md
42
README_EN.md
@@ -47,22 +47,22 @@ desktop software that provides self-hosted solutions.
|
|||||||
### API Service
|
### API Service
|
||||||
Basic implementation of the PC client's primary interfaces.Supports the Personal version api, which can be enabled by configuring the `rustdesk.personal` file or the `RUSTDESK_API_RUSTDESK_PERSONAL` environment variable.
|
Basic implementation of the PC client's primary interfaces.Supports the Personal version api, which can be enabled by configuring the `rustdesk.personal` file or the `RUSTDESK_API_RUSTDESK_PERSONAL` environment variable.
|
||||||
|
|
||||||
#### Login
|
<table>
|
||||||
|
<tr>
|
||||||
- Added `GitHub`, `Google` and `OIDC` login, which can be used after configuration in the admin panel. See the OAuth
|
<td width="50%" align="center" colspan="2"><b>Login</b></td>
|
||||||
configuration section for details.
|
</tr>
|
||||||
- Added authorization login for the web admin panel.
|
<tr>
|
||||||
|
<td width="50%" align="center" colspan="2"><img src="docs/en_img/pc_login.png"></td>
|
||||||

|
</tr>
|
||||||
|
<tr>
|
||||||
#### Address Book
|
<td width="50%" align="center"><b>Address Book</b></td>
|
||||||
|
<td width="50%" align="center"><b>Groups</b></td>
|
||||||

|
</tr>
|
||||||
|
<tr>
|
||||||
#### Groups
|
<td width="50%" align="center"><img src="docs/en_img/pc_ab.png"></td>
|
||||||
Groups are divided into `shared groups` and `regular groups`. In shared groups, everyone can see the peers of all group members, while in regular groups, only administrators can see all members' peers.
|
<td width="50%" align="center"><img src="docs/en_img/pc_gr.png"></td>
|
||||||
|
</tr>
|
||||||

|
</table>
|
||||||
|
|
||||||
### Web Admin
|
### Web Admin
|
||||||
|
|
||||||
@@ -334,4 +334,12 @@ Download the release from [release](https://github.com/lejianwen/rustdesk-api/re
|
|||||||
- [WIKI](https://github.com/lejianwen/rustdesk-api/wiki)
|
- [WIKI](https://github.com/lejianwen/rustdesk-api/wiki)
|
||||||
- [Connection Timeout](https://github.com/lejianwen/rustdesk-api/issues/92)
|
- [Connection Timeout](https://github.com/lejianwen/rustdesk-api/issues/92)
|
||||||
- [Change client ID](https://github.com/abdullah-erturk/RustDesk-ID-Changer)
|
- [Change client ID](https://github.com/abdullah-erturk/RustDesk-ID-Changer)
|
||||||
- [Web client source](https://hub.docker.com/r/keyurbhole/flutter_web_desk)
|
- [Web client source](https://hub.docker.com/r/keyurbhole/flutter_web_desk)
|
||||||
|
|
||||||
|
## Acknowledgements
|
||||||
|
|
||||||
|
Thanks to everyone who contributed!
|
||||||
|
|
||||||
|
<a href="https://github.com/lejianwen/rustdesk-api/graphs/contributors">
|
||||||
|
<img src="https://contrib.rocks/image?repo=lejianwen/rustdesk-api" />
|
||||||
|
</a>
|
||||||
|
|||||||
@@ -102,9 +102,6 @@ func InitGlobal() {
|
|||||||
//配置解析
|
//配置解析
|
||||||
global.Viper = config.Init(&global.Config, global.ConfigPath)
|
global.Viper = config.Init(&global.Config, global.ConfigPath)
|
||||||
|
|
||||||
//从配置文件中加载密钥
|
|
||||||
config.LoadKeyFile(&global.Config.Rustdesk)
|
|
||||||
|
|
||||||
//日志
|
//日志
|
||||||
global.Logger = logger.New(&logger.Config{
|
global.Logger = logger.New(&logger.Config{
|
||||||
Path: global.Config.Logger.Path,
|
Path: global.Config.Logger.Path,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ rustdesk:
|
|||||||
webclient-magic-queryonline: 0
|
webclient-magic-queryonline: 0
|
||||||
logger:
|
logger:
|
||||||
path: "./runtime/log.txt"
|
path: "./runtime/log.txt"
|
||||||
level: "debug" #trace,debug,info,warn,error,fatal
|
level: "warn" #trace,debug,info,warn,error,fatal
|
||||||
report-caller: true
|
report-caller: true
|
||||||
proxy:
|
proxy:
|
||||||
enable: false
|
enable: false
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init 初始化配置
|
// Init 初始化配置
|
||||||
func Init(rowVal interface{}, path string) *viper.Viper {
|
func Init(rowVal *Config, path string) *viper.Viper {
|
||||||
if path == "" {
|
if path == "" {
|
||||||
path = DefaultConfig
|
path = DefaultConfig
|
||||||
}
|
}
|
||||||
@@ -61,11 +61,14 @@ func Init(rowVal interface{}, path string) *viper.Viper {
|
|||||||
if err2 := v.Unmarshal(rowVal); err2 != nil {
|
if err2 := v.Unmarshal(rowVal); err2 != nil {
|
||||||
fmt.Println(err2)
|
fmt.Println(err2)
|
||||||
}
|
}
|
||||||
|
rowVal.Rustdesk.LoadKeyFile()
|
||||||
|
rowVal.Rustdesk.ParsePort()
|
||||||
})
|
})
|
||||||
if err := v.Unmarshal(rowVal); err != nil {
|
if err := v.Unmarshal(rowVal); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
rowVal.Rustdesk.LoadKeyFile()
|
||||||
|
rowVal.Rustdesk.ParsePort()
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,31 +2,56 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultIdServerPort = 21116
|
||||||
|
DefaultRelayServerPort = 21117
|
||||||
)
|
)
|
||||||
|
|
||||||
type Rustdesk struct {
|
type Rustdesk struct {
|
||||||
IdServer string `mapstructure:"id-server"`
|
IdServer string `mapstructure:"id-server"`
|
||||||
RelayServer string `mapstructure:"relay-server"`
|
IdServerPort int `mapstructure:"-"`
|
||||||
ApiServer string `mapstructure:"api-server"`
|
RelayServer string `mapstructure:"relay-server"`
|
||||||
Key string `mapstructure:"key"`
|
RelayServerPort int `mapstructure:"-"`
|
||||||
KeyFile string `mapstructure:"key-file"`
|
ApiServer string `mapstructure:"api-server"`
|
||||||
Personal int `mapstructure:"personal"`
|
Key string `mapstructure:"key"`
|
||||||
|
KeyFile string `mapstructure:"key-file"`
|
||||||
|
Personal int `mapstructure:"personal"`
|
||||||
//webclient-magic-queryonline
|
//webclient-magic-queryonline
|
||||||
WebclientMagicQueryonline int `mapstructure:"webclient-magic-queryonline"`
|
WebclientMagicQueryonline int `mapstructure:"webclient-magic-queryonline"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadKeyFile(rustdesk *Rustdesk) {
|
func (rd *Rustdesk) LoadKeyFile() {
|
||||||
// Load key file
|
// Load key file
|
||||||
if rustdesk.Key != "" {
|
if rd.Key != "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if rustdesk.KeyFile != "" {
|
if rd.KeyFile != "" {
|
||||||
// Load key from file
|
// Load key from file
|
||||||
b, err := os.ReadFile(rustdesk.KeyFile)
|
b, err := os.ReadFile(rd.KeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rustdesk.Key = string(b)
|
rd.Key = string(b)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func (rd *Rustdesk) ParsePort() {
|
||||||
|
// Parse port
|
||||||
|
idres := strings.Split(rd.IdServer, ":")
|
||||||
|
if len(idres) == 1 {
|
||||||
|
rd.IdServerPort = DefaultIdServerPort
|
||||||
|
} else if len(idres) == 2 {
|
||||||
|
rd.IdServerPort, _ = strconv.Atoi(idres[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
relayres := strings.Split(rd.RelayServer, ":")
|
||||||
|
if len(relayres) == 1 {
|
||||||
|
rd.RelayServerPort = DefaultRelayServerPort
|
||||||
|
} else if len(relayres) == 2 {
|
||||||
|
rd.RelayServerPort, _ = strconv.Atoi(relayres[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 67 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 67 KiB |
@@ -4,18 +4,19 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/go-playground/locales/en"
|
"github.com/go-playground/locales/en"
|
||||||
"github.com/go-playground/locales/es"
|
"github.com/go-playground/locales/es"
|
||||||
|
"github.com/go-playground/locales/fr"
|
||||||
"github.com/go-playground/locales/ko"
|
"github.com/go-playground/locales/ko"
|
||||||
"github.com/go-playground/locales/ru"
|
"github.com/go-playground/locales/ru"
|
||||||
"github.com/go-playground/locales/fr"
|
|
||||||
"github.com/go-playground/locales/zh_Hans_CN"
|
"github.com/go-playground/locales/zh_Hans_CN"
|
||||||
|
"github.com/go-playground/locales/zh_Hant"
|
||||||
ut "github.com/go-playground/universal-translator"
|
ut "github.com/go-playground/universal-translator"
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
en_translations "github.com/go-playground/validator/v10/translations/en"
|
en_translations "github.com/go-playground/validator/v10/translations/en"
|
||||||
es_translations "github.com/go-playground/validator/v10/translations/es"
|
es_translations "github.com/go-playground/validator/v10/translations/es"
|
||||||
|
fr_translations "github.com/go-playground/validator/v10/translations/fr"
|
||||||
ru_translations "github.com/go-playground/validator/v10/translations/ru"
|
ru_translations "github.com/go-playground/validator/v10/translations/ru"
|
||||||
zh_translations "github.com/go-playground/validator/v10/translations/zh"
|
zh_translations "github.com/go-playground/validator/v10/translations/zh"
|
||||||
fr_translations "github.com/go-playground/validator/v10/translations/fr"
|
zh_tw_translations "github.com/go-playground/validator/v10/translations/zh_tw"
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,8 +30,9 @@ func ApiInitValidator() {
|
|||||||
ruT := ru.New()
|
ruT := ru.New()
|
||||||
esT := es.New()
|
esT := es.New()
|
||||||
frT := fr.New()
|
frT := fr.New()
|
||||||
|
zhTwT := zh_Hant.New()
|
||||||
|
|
||||||
uni := ut.New(enT, cn, koT, ruT, esT, frT)
|
uni := ut.New(enT, cn, koT, ruT, esT, frT, zhTwT)
|
||||||
|
|
||||||
enTrans, _ := uni.GetTranslator("en")
|
enTrans, _ := uni.GetTranslator("en")
|
||||||
zhTrans, _ := uni.GetTranslator("zh_Hans_CN")
|
zhTrans, _ := uni.GetTranslator("zh_Hans_CN")
|
||||||
@@ -38,6 +40,7 @@ func ApiInitValidator() {
|
|||||||
ruTrans, _ := uni.GetTranslator("ru")
|
ruTrans, _ := uni.GetTranslator("ru")
|
||||||
esTrans, _ := uni.GetTranslator("es")
|
esTrans, _ := uni.GetTranslator("es")
|
||||||
frTrans, _ := uni.GetTranslator("fr")
|
frTrans, _ := uni.GetTranslator("fr")
|
||||||
|
zhTwTrans, _ := uni.GetTranslator("zh_Hant")
|
||||||
|
|
||||||
err := zh_translations.RegisterDefaultTranslations(validate, zhTrans)
|
err := zh_translations.RegisterDefaultTranslations(validate, zhTrans)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -65,6 +68,10 @@ func ApiInitValidator() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
err = zh_tw_translations.RegisterDefaultTranslations(validate, zhTwTrans)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
validate.RegisterTagNameFunc(func(field reflect.StructField) string {
|
validate.RegisterTagNameFunc(func(field reflect.StructField) string {
|
||||||
label := field.Tag.Get("label")
|
label := field.Tag.Get("label")
|
||||||
@@ -125,6 +132,13 @@ func getTranslatorForLang(lang string) ut.Translator {
|
|||||||
case "zh":
|
case "zh":
|
||||||
trans, _ := Validator.UT.GetTranslator("zh_Hans_CN")
|
trans, _ := Validator.UT.GetTranslator("zh_Hans_CN")
|
||||||
return trans
|
return trans
|
||||||
|
case "zh_TW":
|
||||||
|
fallthrough
|
||||||
|
case "zh-TW":
|
||||||
|
fallthrough
|
||||||
|
case "zh-tw":
|
||||||
|
trans, _ := Validator.UT.GetTranslator("zh_Hant")
|
||||||
|
return trans
|
||||||
case "ko":
|
case "ko":
|
||||||
trans, _ := Validator.UT.GetTranslator("ko")
|
trans, _ := Validator.UT.GetTranslator("ko")
|
||||||
return trans
|
return trans
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ type User struct {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200 {object} apiResp.UserPayload
|
// @Success 200 {object} apiResp.UserPayload
|
||||||
// @Failure 500 {object} response.Response
|
// @Failure 500 {object} response.Response
|
||||||
// @Router /api [get]
|
// @Router /currentUser [get]
|
||||||
// @Security token
|
// @Security token
|
||||||
func (u *User) Info(c *gin.Context) {
|
func (u *User) Info(c *gin.Context) {
|
||||||
user := service.AllService.UserService.CurUser(c)
|
user := service.AllService.UserService.CurUser(c)
|
||||||
|
|||||||
137
resources/i18n/zh_TW.toml
Normal file
137
resources/i18n/zh_TW.toml
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
[Test]
|
||||||
|
description = "test"
|
||||||
|
one = "測試1 {{.P0}}"
|
||||||
|
other = "測試2 {{.P0}}"
|
||||||
|
|
||||||
|
[ParamsError]
|
||||||
|
description = "Params validation failed."
|
||||||
|
one = "引數錯誤。"
|
||||||
|
other = "引數錯誤。"
|
||||||
|
|
||||||
|
[OperationFailed]
|
||||||
|
description = "OperationFailed."
|
||||||
|
one = "操作失敗。"
|
||||||
|
other = "操作失敗。"
|
||||||
|
|
||||||
|
[OperationSuccess]
|
||||||
|
description = "OperationSuccess."
|
||||||
|
one = "操作成功。"
|
||||||
|
other = "操作成功。"
|
||||||
|
|
||||||
|
[ItemExists]
|
||||||
|
description = "Item already exists."
|
||||||
|
one = "資料已存在。"
|
||||||
|
other = "資料已存在。"
|
||||||
|
|
||||||
|
[ItemNotFound]
|
||||||
|
description = "Item not found."
|
||||||
|
one = "資料不存在。"
|
||||||
|
other = "資料不存在。"
|
||||||
|
|
||||||
|
[NoAccess]
|
||||||
|
description = "No access."
|
||||||
|
one = "無許可權。"
|
||||||
|
other = "無許可權。"
|
||||||
|
|
||||||
|
[UsernameOrPasswordError]
|
||||||
|
description = "Username or password error."
|
||||||
|
one = "使用者名稱或密碼錯誤。"
|
||||||
|
other = "使用者名稱或密碼錯誤。"
|
||||||
|
|
||||||
|
[SystemError]
|
||||||
|
description = "System error."
|
||||||
|
one = "系統錯誤。"
|
||||||
|
other = "系統錯誤。"
|
||||||
|
|
||||||
|
[ConfigNotFound]
|
||||||
|
description = "Config not found."
|
||||||
|
one = "配置不存在。"
|
||||||
|
other = "配置不存在。"
|
||||||
|
|
||||||
|
#授權過期
|
||||||
|
[OauthExpired]
|
||||||
|
description = "Oauth expired."
|
||||||
|
one = "授權過期,請重新授權。"
|
||||||
|
other = "授權過期,請重新授權。"
|
||||||
|
|
||||||
|
[OauthFailed]
|
||||||
|
description = "Oauth failed."
|
||||||
|
one = "授權失敗。"
|
||||||
|
other = "授權失敗。"
|
||||||
|
|
||||||
|
[OauthHasBindOtherUser]
|
||||||
|
description = "Oauth has bind other user."
|
||||||
|
one = "授權已繫結其他使用者。"
|
||||||
|
other = "授權已繫結其他使用者。"
|
||||||
|
|
||||||
|
[ParamIsEmpty]
|
||||||
|
description = "Param is empty."
|
||||||
|
one = "{{.P0}} 為空。"
|
||||||
|
other = "{{.P0}} 為空。"
|
||||||
|
|
||||||
|
[BindFail]
|
||||||
|
description = "Bind fail."
|
||||||
|
one = "繫結失敗。"
|
||||||
|
other = "繫結失敗。"
|
||||||
|
[BindSuccess]
|
||||||
|
description = "Bind success."
|
||||||
|
one = "繫結成功。"
|
||||||
|
other = "繫結成功。"
|
||||||
|
[OauthHasBeenSuccess]
|
||||||
|
description = "Oauth has been success."
|
||||||
|
one = "授權已成功。"
|
||||||
|
other = "授權已成功。"
|
||||||
|
[OauthSuccess]
|
||||||
|
description = "Oauth success."
|
||||||
|
one = "授權成功。"
|
||||||
|
other = "授權成功。"
|
||||||
|
[OauthRegisterSuccess]
|
||||||
|
description = "Oauth register success."
|
||||||
|
one = "授權註冊成功。"
|
||||||
|
other = "授權註冊成功。"
|
||||||
|
[OauthRegisterFailed]
|
||||||
|
description = "Oauth register failed."
|
||||||
|
one = "授權註冊失敗。"
|
||||||
|
other = "授權註冊失敗。"
|
||||||
|
[GetOauthTokenError]
|
||||||
|
description = "Get oauth token error."
|
||||||
|
one = "獲取授權token失敗。"
|
||||||
|
other = "獲取授權token失敗。"
|
||||||
|
[GetOauthUserInfoError]
|
||||||
|
description = "Get oauth user info error."
|
||||||
|
one = "獲取授權使用者資訊失敗。"
|
||||||
|
other = "獲取授權使用者資訊失敗。"
|
||||||
|
[DecodeOauthUserInfoError]
|
||||||
|
description = "Decode oauth user info error."
|
||||||
|
one = "解析授權使用者資訊失敗。"
|
||||||
|
other = "解析授權使用者資訊失敗。"
|
||||||
|
|
||||||
|
[OldPasswordError]
|
||||||
|
description = "Old password error."
|
||||||
|
one = "舊密碼錯誤。"
|
||||||
|
other = "舊密碼錯誤。"
|
||||||
|
|
||||||
|
|
||||||
|
[DefaultGroup]
|
||||||
|
description = "Default group."
|
||||||
|
one = "預設組"
|
||||||
|
other = "預設組"
|
||||||
|
|
||||||
|
[ShareGroup]
|
||||||
|
description = "Share group."
|
||||||
|
one = "共享組"
|
||||||
|
other = "共享組"
|
||||||
|
[RegisterClosed]
|
||||||
|
description = "Register closed."
|
||||||
|
one = "註冊已關閉。"
|
||||||
|
other = "註冊已關閉。"
|
||||||
|
|
||||||
|
[CaptchaRequired]
|
||||||
|
description = "Captcha required."
|
||||||
|
one = "需要驗證碼。"
|
||||||
|
other = "需要驗證碼。"
|
||||||
|
|
||||||
|
[CaptchaError]
|
||||||
|
description = "Captcha error."
|
||||||
|
one = "驗證碼錯誤。"
|
||||||
|
other = "驗證碼錯誤。"
|
||||||
@@ -41,7 +41,14 @@ func (is *ServerCmdService) Create(u *model.ServerCmd) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SendCmd 发送命令
|
// SendCmd 发送命令
|
||||||
func (is *ServerCmdService) SendCmd(port string, cmd string, arg string) (string, error) {
|
func (is *ServerCmdService) SendCmd(target string, cmd string, arg string) (string, error) {
|
||||||
|
port := 0
|
||||||
|
switch target {
|
||||||
|
case model.ServerCmdTargetIdServer:
|
||||||
|
port = global.Config.Rustdesk.IdServerPort - 1
|
||||||
|
case model.ServerCmdTargetRelayServer:
|
||||||
|
port = global.Config.Rustdesk.RelayServerPort
|
||||||
|
}
|
||||||
//组装命令
|
//组装命令
|
||||||
cmd = cmd + " " + arg
|
cmd = cmd + " " + arg
|
||||||
res, err := is.SendSocketCmd("v6", port, cmd)
|
res, err := is.SendSocketCmd("v6", port, cmd)
|
||||||
@@ -57,14 +64,14 @@ func (is *ServerCmdService) SendCmd(port string, cmd string, arg string) (string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SendSocketCmd
|
// SendSocketCmd
|
||||||
func (is *ServerCmdService) SendSocketCmd(ty string, port string, cmd string) (string, error) {
|
func (is *ServerCmdService) SendSocketCmd(ty string, port int, cmd string) (string, error) {
|
||||||
addr := "[::1]"
|
addr := "[::1]"
|
||||||
tcp := "tcp6"
|
tcp := "tcp6"
|
||||||
if ty == "v4" {
|
if ty == "v4" {
|
||||||
tcp = "tcp"
|
tcp = "tcp"
|
||||||
addr = "127.0.0.1"
|
addr = "127.0.0.1"
|
||||||
}
|
}
|
||||||
conn, err := net.Dial(tcp, fmt.Sprintf("%s:%s", addr, port))
|
conn, err := net.Dial(tcp, fmt.Sprintf("%s:%v", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
global.Logger.Debugf("%s connect to id server failed: %v", ty, err)
|
global.Logger.Debugf("%s connect to id server failed: %v", ty, err)
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
Reference in New Issue
Block a user