add login fail warn &
add web client on/off & up admin peer filter & upgrade web client
This commit is contained in:
1 parent
0eb733cc33
commit
b4965e8885
20 files changed
+131
-47
No files matched your search
@@ -151,6 +151,8 @@
|
||||
|
||||
```yaml
|
||||
lang: "en"
|
||||
app:
|
||||
web-client: 1 # 1:启用 0:禁用
|
||||
gin:
|
||||
api-addr: "0.0.0.0:21114"
|
||||
mode: "release"
|
||||
@@ -181,12 +183,13 @@ logger:
|
||||
变量名前缀是`RUSTDESK_API`,环境变量如果存在将覆盖配置文件中的配置
|
||||
|
||||
| 变量名 | 说明 | 示例 |
|
||||
|-------------------------------------|--------------------------------------|-----------------------------|
|
||||
|------------------------------------|--------------------------------------|-----------------------------|
|
||||
| TZ | 时区 | Asia/Shanghai |
|
||||
| RUSTDESK_API_LANG | 语言 | `en`,`zh-CN` |
|
||||
| RUSTDESK_API_APP_WEB_CLIENT | 是否启用web-client; 1:启用,0:不启用; 默认启用 | 1 |
|
||||
| -----GIN配置----- | ---------- | ---------- |
|
||||
| RUSTDESK_API_GIN_TRUST_PROXY | 信任的代理IP列表,以`,`分割,默认信任所有 | 192.168.1.2,192.168.1.3 |
|
||||
| -----------GORM配置------------------ | ------------------------------------ | --------------------------- |
|
||||
| -----------GORM配置---------------- | ------------------------------------ | --------------------------- |
|
||||
| RUSTDESK_API_GORM_TYPE | 数据库类型sqlite或者mysql,默认sqlite | sqlite |
|
||||
| RUSTDESK_API_GORM_MAX_IDLE_CONNS | 数据库最大空闲连接数 | 10 |
|
||||
| RUSTDESK_API_GORM_MAX_OPEN_CONNS | 数据库最大打开连接数 | 100 |
|
||||
|
||||
+8
-5
@@ -157,6 +157,8 @@ installation are `admin` `admin`, please change the password immediately.
|
||||
|
||||
```yaml
|
||||
lang: "en"
|
||||
app:
|
||||
web-client: 1 # web client route 1:open 0:close
|
||||
gin:
|
||||
api-addr: "0.0.0.0:21114"
|
||||
mode: "release"
|
||||
@@ -187,22 +189,23 @@ logger:
|
||||
The prefix for variable names is `RUSTDESK_API`. If environment variables exist, they will override the configurations in the configuration file.
|
||||
|
||||
| Variable Name | Description | Example |
|
||||
|------------------------------------|-----------------------------------------------------------|--------------------------------|
|
||||
|------------------------------------|-----------------------------------------------------------|-------------------------------|
|
||||
| TZ | timezone | Asia/Shanghai |
|
||||
| RUSTDESK_API_LANG | Language | `en`,`zh-CN` |
|
||||
| ----- GIN Configuration ----- | --------------------------------------- | ------------------------------ |
|
||||
| RUSTDESK_API_APP_WEB_CLIENT | web client on/off; 1: on, 0 off, deault 1 | 1 |
|
||||
| ----- GIN Configuration ----- | --------------------------------------- | ----------------------------- |
|
||||
| RUSTDESK_API_GIN_TRUST_PROXY | Trusted proxy IPs, separated by commas. | 192.168.1.2,192.168.1.3 |
|
||||
| ----- GORM Configuration ----- | --------------------------------------- | ------------------------------ |
|
||||
| ----- GORM Configuration ----- | --------------------------------------- | ----------------------------- |
|
||||
| RUSTDESK_API_GORM_TYPE | Database type (`sqlite` or `mysql`). Default is `sqlite`. | sqlite |
|
||||
| RUSTDESK_API_GORM_MAX_IDLE_CONNS | Maximum idle connections | 10 |
|
||||
| RUSTDESK_API_GORM_MAX_OPEN_CONNS | Maximum open connections | 100 |
|
||||
| RUSTDESK_API_RUSTDESK_PERSONAL | Open Personal Api 1:Enable,0:Disable | 1 |
|
||||
| ----- MYSQL Configuration ----- | --------------------------------------- | ------------------------------ |
|
||||
| ----- MYSQL Configuration ----- | --------------------------------------- | ----------------------------- |
|
||||
| RUSTDESK_API_MYSQL_USERNAME | MySQL username | root |
|
||||
| RUSTDESK_API_MYSQL_PASSWORD | MySQL password | 111111 |
|
||||
| RUSTDESK_API_MYSQL_ADDR | MySQL address | 192.168.1.66:3306 |
|
||||
| RUSTDESK_API_MYSQL_DBNAME | MySQL database name | rustdesk |
|
||||
| ----- RUSTDESK Configuration ----- | --------------------------------------- | ------------------------------ |
|
||||
| ----- RUSTDESK Configuration ----- | --------------------------------------- | ----------------------------- |
|
||||
| RUSTDESK_API_RUSTDESK_ID_SERVER | Rustdesk ID server address | 192.168.1.66:21116 |
|
||||
| RUSTDESK_API_RUSTDESK_RELAY_SERVER | Rustdesk relay server address | 192.168.1.66:21117 |
|
||||
| RUSTDESK_API_RUSTDESK_API_SERVER | Rustdesk API server address | http://192.168.1.66:21114 |
|
||||
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
lang: "zh-CN"
|
||||
app:
|
||||
web-client: 1 # 1:启用 0:禁用
|
||||
gin:
|
||||
api-addr: "0.0.0.0:21114"
|
||||
mode: "release" #release,debug,test
|
||||
@@ -16,7 +18,7 @@ mysql:
|
||||
rustdesk:
|
||||
id-server: "192.168.1.66:21116"
|
||||
relay-server: "192.168.1.66:21117"
|
||||
api-server: "http://192.168.1.66:21114"
|
||||
api-server: "http://127.0.0.1:21114"
|
||||
key: "123456789"
|
||||
personal: 1
|
||||
logger:
|
||||
|
||||
@@ -14,8 +14,13 @@ const (
|
||||
DefaultConfig = "conf/config.yaml"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
WebClient int `mapstructure:"web-client"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Lang string `mapstructure:"lang"`
|
||||
App App
|
||||
Gorm Gorm
|
||||
Mysql Mysql
|
||||
Gin Gin
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
adResp "Gwen/http/response/admin"
|
||||
"Gwen/model"
|
||||
"Gwen/service"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -28,18 +29,21 @@ func (ct *Login) Login(c *gin.Context) {
|
||||
f := &admin.Login{}
|
||||
err := c.ShouldBindJSON(f)
|
||||
if err != nil {
|
||||
global.Logger.Warn(fmt.Sprintf("Login Fail: %s %s %s", "ParamsError", c.RemoteIP(), c.ClientIP()))
|
||||
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
errList := global.Validator.ValidStruct(c, f)
|
||||
if len(errList) > 0 {
|
||||
global.Logger.Warn(fmt.Sprintf("Login Fail: %s %s %s", "ParamsError", c.RemoteIP(), c.ClientIP()))
|
||||
response.Fail(c, 101, errList[0])
|
||||
return
|
||||
}
|
||||
u := service.AllService.UserService.InfoByUsernamePassword(f.Username, f.Password)
|
||||
|
||||
if u.Id == 0 {
|
||||
global.Logger.Warn(fmt.Sprintf("Login Fail: %s %s %s", "UsernameOrPasswordError", c.RemoteIP(), c.ClientIP()))
|
||||
response.Fail(c, 101, response.TranslateMsg(c, "UsernameOrPasswordError"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -96,6 +96,12 @@ func (ct *Peer) List(c *gin.Context) {
|
||||
lt := time.Now().Unix() + int64(query.TimeAgo)
|
||||
tx.Where("last_online_time > ?", lt)
|
||||
}
|
||||
if query.Id != "" {
|
||||
tx.Where("id like ?", "%"+query.Id+"%")
|
||||
}
|
||||
if query.Hostname != "" {
|
||||
tx.Where("hostname like ?", "%"+query.Hostname+"%")
|
||||
}
|
||||
})
|
||||
response.Success(c, res)
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
type Rustdesk struct {
|
||||
}
|
||||
|
||||
// ServerConfig 服务配置
|
||||
// ServerConfig RUSTDESK服务配置
|
||||
// @Tags ADMIN
|
||||
// @Summary 服务配置
|
||||
// @Summary RUSTDESK服务配置
|
||||
// @Description 服务配置,给webclient提供api-server
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
@@ -28,3 +28,19 @@ func (r *Rustdesk) ServerConfig(c *gin.Context) {
|
||||
}
|
||||
response.Success(c, cf)
|
||||
}
|
||||
|
||||
// AppConfig APP服务配置
|
||||
// @Tags ADMIN
|
||||
// @Summary APP服务配置
|
||||
// @Description APP服务配置
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 500 {object} response.Response
|
||||
// @Router /admin/app-config [get]
|
||||
// @Security token
|
||||
func (r *Rustdesk) AppConfig(c *gin.Context) {
|
||||
response.Success(c, &gin.H{
|
||||
"web_client": global.Config.App.WebClient,
|
||||
})
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"Gwen/model"
|
||||
"Gwen/service"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -402,7 +401,7 @@ func (a *Ab) PeerAdd(c *gin.Context) {
|
||||
response.Error(c, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||
return
|
||||
}
|
||||
fmt.Println(f)
|
||||
//fmt.Println(f)
|
||||
u := service.AllService.UserService.CurUser(c)
|
||||
f.UserId = u.Id
|
||||
ab := f.ToAddressBook()
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"Gwen/model"
|
||||
"Gwen/service"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
@@ -30,12 +31,14 @@ func (l *Login) Login(c *gin.Context) {
|
||||
err := c.ShouldBindJSON(f)
|
||||
//fmt.Println(f)
|
||||
if err != nil {
|
||||
global.Logger.Warn(fmt.Sprintf("Login Fail: %s %s %s", "ParamsError", c.RemoteIP(), c.ClientIP()))
|
||||
response.Error(c, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
errList := global.Validator.ValidStruct(c, f)
|
||||
if len(errList) > 0 {
|
||||
global.Logger.Warn(fmt.Sprintf("Login Fail: %s %s %s", "ParamsError", c.RemoteIP(), c.ClientIP()))
|
||||
response.Error(c, errList[0])
|
||||
return
|
||||
}
|
||||
@@ -43,6 +46,7 @@ func (l *Login) Login(c *gin.Context) {
|
||||
u := service.AllService.UserService.InfoByUsernamePassword(f.Username, f.Password)
|
||||
|
||||
if u.Id == 0 {
|
||||
global.Logger.Warn(fmt.Sprintf("Login Fail: %s %s %s", "UsernameOrPasswordError", c.RemoteIP(), c.ClientIP()))
|
||||
response.Error(c, response.TranslateMsg(c, "UsernameOrPasswordError"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ type Peer struct {
|
||||
// @Success 200 {string} string "SYSINFO_UPDATED,ID_NOT_FOUND"
|
||||
// @Failure 500 {object} response.ErrorResponse
|
||||
// @Router /sysinfo [post]
|
||||
// @Security BearerAuth
|
||||
func (p *Peer) SysInfo(c *gin.Context) {
|
||||
f := &requstform.PeerForm{}
|
||||
err := c.ShouldBindBodyWith(f, binding.JSON)
|
||||
@@ -30,17 +29,28 @@ func (p *Peer) SysInfo(c *gin.Context) {
|
||||
response.Error(c, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
fpe := f.ToPeer()
|
||||
pe := service.AllService.PeerService.FindById(f.Id)
|
||||
if pe == nil || pe.RowId == 0 {
|
||||
if pe.RowId == 0 {
|
||||
pe = f.ToPeer()
|
||||
pe.UserId = service.AllService.UserService.FindLatestUserIdFromLoginLogByUuid(pe.Uuid)
|
||||
err = service.AllService.PeerService.Create(pe)
|
||||
if err != nil {
|
||||
response.Error(c, response.TranslateMsg(c, "OperationFailed")+err.Error())
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if pe.UserId == 0 {
|
||||
pe.UserId = service.AllService.UserService.FindLatestUserIdFromLoginLogByUuid(pe.Uuid)
|
||||
}
|
||||
fpe.RowId = pe.RowId
|
||||
fpe.UserId = pe.UserId
|
||||
err = service.AllService.PeerService.Update(fpe)
|
||||
if err != nil {
|
||||
response.Error(c, response.TranslateMsg(c, "OperationFailed")+err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
//SYSINFO_UPDATED 上传成功
|
||||
//ID_NOT_FOUND 下次心跳会上传
|
||||
//直接响应文本
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func RustAuth() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
//fmt.Println(c.Request.Header)
|
||||
//fmt.Println(c.Request.URL, c.Request.Header)
|
||||
//获取HTTP_AUTHORIZATION
|
||||
token := c.GetHeader("Authorization")
|
||||
if token == "" {
|
||||
|
||||
@@ -36,4 +36,6 @@ func (f *PeerForm) ToPeer() *model.Peer {
|
||||
type PeerQuery struct {
|
||||
PageQuery
|
||||
TimeAgo int `json:"time_ago" form:"time_ago"`
|
||||
Id string `json:"id" form:"id"`
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
}
|
||||
@@ -30,6 +30,7 @@ func Init(g *gin.Engine) {
|
||||
|
||||
rs := &admin.Rustdesk{}
|
||||
adg.GET("/server-config", rs.ServerConfig)
|
||||
adg.GET("/app-config", rs.AppConfig)
|
||||
|
||||
//访问静态文件
|
||||
//g.StaticFS("/upload", http.Dir(global.Config.Gin.ResourcesPath+"/upload"))
|
||||
|
||||
+13
-8
@@ -47,17 +47,11 @@ func ApiInit(g *gin.Engine) {
|
||||
frg.POST("/sysinfo", pe.SysInfo)
|
||||
}
|
||||
|
||||
{
|
||||
w := &api.WebClient{}
|
||||
frg.POST("/shared-peer", w.SharedPeer)
|
||||
if global.Config.App.WebClient == 1 {
|
||||
WebClientRoutes(frg)
|
||||
}
|
||||
|
||||
frg.Use(middleware.RustAuth())
|
||||
{
|
||||
w := &api.WebClient{}
|
||||
frg.POST("/server-config", w.ServerConfig)
|
||||
}
|
||||
|
||||
{
|
||||
u := &api.User{}
|
||||
frg.GET("/user/info", u.Info)
|
||||
@@ -115,3 +109,14 @@ func PersonalRoutes(frg *gin.RouterGroup) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func WebClientRoutes(frg *gin.RouterGroup) {
|
||||
w := &api.WebClient{}
|
||||
{
|
||||
frg.POST("/shared-peer", w.SharedPeer)
|
||||
}
|
||||
{
|
||||
frg.POST("/server-config", middleware.RustAuth(), w.ServerConfig)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,13 @@ import (
|
||||
func WebInit(g *gin.Engine) {
|
||||
i := &web.Index{}
|
||||
g.GET("/", i.Index)
|
||||
|
||||
if global.Config.App.WebClient == 1 {
|
||||
g.GET("/webclient-config/index.js", i.ConfigJs)
|
||||
}
|
||||
|
||||
if global.Config.App.WebClient == 1 {
|
||||
g.StaticFS("/webclient", http.Dir(global.Config.Gin.ResourcesPath+"/web"))
|
||||
}
|
||||
g.StaticFS("/_admin", http.Dir(global.Config.Gin.ResourcesPath+"/admin"))
|
||||
}
|
||||
@@ -16,6 +16,7 @@ type SqliteConfig struct {
|
||||
|
||||
func NewSqlite(sqliteConf *SqliteConfig) *gorm.DB {
|
||||
db, err := gorm.Open(sqlite.Open("./data/rustdeskapi.db"), &gorm.Config{
|
||||
DisableForeignKeyConstraintWhenMigrating: true,
|
||||
Logger: logger.New(
|
||||
global.Logger, // io writer
|
||||
logger.Config{
|
||||
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
var yi=Object.defineProperty;var xi=(e,u,r)=>u in e?yi(e,u,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[u]=r;var v=(e,u,r)=>(xi(e,typeof u!="symbol"?u+"":u,r),r);import{m as o,l as Pu,s as Ai,Q as Ci,a as gi,b as wu,P as Si}from"./vendor.js";const Bi=function(){const u=document.createElement("link").relList;if(u&&u.supports&&u.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const t of i)if(t.type==="childList")for(const s of t.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(i){const t={};return i.integrity&&(t.integrity=i.integrity),i.referrerpolicy&&(t.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?t.credentials="include":i.crossorigin==="anonymous"?t.credentials="omit":t.credentials="same-origin",t}function n(i){if(i.ep)return;i.ep=!0;const t=r(i);fetch(i.href,t)}};Bi();window._gwen={};window._gwen.kv={};const pu=localStorage.getItem("api-server");function oi(e){for(var u=[],r=0,n=e.length;r<n;++r)u.push(e.charCodeAt(r));var i=new Uint8Array(u);return i}function Pi(){const u=window.location.hash.substring(3).split("&");for(var r=0;r<u.length;r++){var n=u[r].split("=");window._gwen.kv[n[0]]=n[1]}}Pi();const Ru=window._gwen.kv.id||"";Ru&&localStorage.setItem("remote-id",Ru);const bu=window._gwen.kv.share_token||"";bu&&fetch(pu+"/api/shared-peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({share_token:bu})}).then(e=>e.json()).then(e=>{if(e.code===0){localStorage.setItem("custom-rendezvous-server",e.data.id_server),localStorage.setItem("key",e.data.key);const u=e.data.peer;localStorage.setItem("remote-id",u.info.id),u.tmppwd=oi(window.atob(u.tmppwd)).toString();const r=JSON.parse(localStorage.getItem("peers"))||{};r[u.info.id]=u,localStorage.setItem("peers",JSON.stringify(r))}});const ai=()=>setTimeout(()=>{const e=localStorage.getItem("access_token");e&&pu?fetch(pu+"/api/server-config",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+e}}).then(u=>u.json()).then(u=>{if(u.code===0&&((!localStorage.getItem("custom-rendezvous-server")||!localStorage.getItem("key"))&&(localStorage.setItem("custom-rendezvous-server",u.data.id_server),localStorage.setItem("key",u.data.key)),u.data.peers)){const r=JSON.parse(localStorage.getItem("peers"))||{};let n=!1;Object.keys(u.data.peers).forEach(i=>{if(r[i]?r[i].info=u.data.peers[i].info:(r[i]=u.data.peers[i],n=!0),r[i].info&&r[i].info.hash&&!r[i].password){let t=window.atob(r[i].info.hash);const s=oi(t);r[i].password=s.toString(),r[i].remember=!0}}),localStorage.setItem("peers",JSON.stringify(r)),n&&window.location.reload()}}):ai()},1e3);ai();var B=(e=>(e[e.Unknown=0]="Unknown",e[e.Alt=1]="Alt",e[e.Backspace=2]="Backspace",e[e.CapsLock=3]="CapsLock",e[e.Control=4]="Control",e[e.Delete=5]="Delete",e[e.DownArrow=6]="DownArrow",e[e.End=7]="End",e[e.Escape=8]="Escape",e[e.F1=9]="F1",e[e.F10=10]="F10",e[e.F11=11]="F11",e[e.F12=12]="F12",e[e.F2=13]="F2",e[e.F3=14]="F3",e[e.F4=15]="F4",e[e.F5=16]="F5",e[e.F6=17]="F6",e[e.F7=18]="F7",e[e.F8=19]="F8",e[e.F9=20]="F9",e[e.Home=21]="Home",e[e.LeftArrow=22]="LeftArrow",e[e.Meta=23]="Meta",e[e.Option=24]="Option",e[e.PageDown=25]="PageDown",e[e.PageUp=26]="PageUp",e[e.Return=27]="Return",e[e.RightArrow=28]="RightArrow",e[e.Shift=29]="Shift",e[e.Space=30]="Space",e[e.Tab=31]="Tab",e[e.UpArrow=32]="UpArrow",e[e.Numpad0=33]="Numpad0",e[e.Numpad1=34]="Numpad1",e[e.Numpad2=35]="Numpad2",e[e.Numpad3=36]="Numpad3",e[e.Numpad4=37]="Numpad4",e[e.Numpad5=38]="Numpad5",e[e.Numpad6=39]="Numpad6",e[e.Numpad7=40]="Numpad7",e[e.Numpad8=41]="Numpad8",e[e.Numpad9=42]="Numpad9",e[e.Cancel=43]="Cancel",e[e.Clear=44]="Clear",e[e.Menu=45]="Menu",e[e.Pause=46]="Pause",e[e.Kana=47]="Kana",e[e.Hangul=48]="Hangul",e[e.Junja=49]="Junja",e[e.Final=50]="Final",e[e.Hanja=51]="Hanja",e[e.Kanji=52]="Kanji",e[e.Convert=53]="Convert",e[e.Select=54]="Select",e[e.Print=55]="Print",e[e.Execute=56]="Execute",e[e.Snapshot=57]="Snapshot",e[e.Insert=58]="Insert",e[e.Help=59]="Help",e[e.Sleep=60]="Sleep",e[e.Separator=61]="Separator",e[e.Scroll=62]="Scroll",e[e.NumLock=63]="NumLock",e[e.RWin=64]="RWin",e[e.Apps=65]="Apps",e[e.Multiply=66]="Multiply",e[e.Add=67]="Add",e[e.Subtract=68]="Subtract",e[e.Decimal=69]="Decimal",e[e.Divide=70]="Divide",e[e.Equals=71]="Equals",e[e.NumpadEnter=72]="NumpadEnter",e[e.RShift=73]="RShift",e[e.RControl=74]="RControl",e[e.RAlt=75]="RAlt",e[e.CtrlAltDel=100]="CtrlAltDel",e[e.LockScreen=101]="LockScreen",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(B||{});function ru(e){switch(e){case 0:case"Unknown":return 0;case 1:case"Alt":return 1;case 2:case"Backspace":return 2;case 3:case"CapsLock":return 3;case 4:case"Control":return 4;case 5:case"Delete":return 5;case 6:case"DownArrow":return 6;case 7:case"End":return 7;case 8:case"Escape":return 8;case 9:case"F1":return 9;case 10:case"F10":return 10;case 11Line truncated
|
||||
var xi=Object.defineProperty;var Ai=(e,u,r)=>u in e?xi(e,u,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[u]=r;var v=(e,u,r)=>(Ai(e,typeof u!="symbol"?u+"":u,r),r);import{m as o,l as Pu,s as Ci,Q as gi,a as Si,b as wu,P as Bi}from"./vendor.js";const Pi=function(){const u=document.createElement("link").relList;if(u&&u.supports&&u.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const t of i)if(t.type==="childList")for(const s of t.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(i){const t={};return i.integrity&&(t.integrity=i.integrity),i.referrerpolicy&&(t.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?t.credentials="include":i.crossorigin==="anonymous"?t.credentials="omit":t.credentials="same-origin",t}function n(i){if(i.ep)return;i.ep=!0;const t=r(i);fetch(i.href,t)}};Pi();window._gwen={};window._gwen.kv={};const oi=localStorage.getItem("api-server");function ai(e){for(var u=[],r=0,n=e.length;r<n;++r)u.push(e.charCodeAt(r));var i=new Uint8Array(u);return i}function wi(){const u=window.location.hash.substring(3).split("&");for(var r=0;r<u.length;r++){var n=u[r].split("=");window._gwen.kv[n[0]]=n[1]}}wi();const Ru=window._gwen.kv.id||"";Ru&&localStorage.setItem("remote-id",Ru);const bu=window._gwen.kv.share_token||"";bu&&fetch(oi+"/api/shared-peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({share_token:bu})}).then(e=>e.json()).then(e=>{if(e.code===0){localStorage.setItem("custom-rendezvous-server",e.data.id_server),localStorage.setItem("key",e.data.key);const u=e.data.peer;localStorage.setItem("remote-id",u.info.id),u.tmppwd=ai(window.atob(u.tmppwd)).toString();const r=JSON.parse(localStorage.getItem("peers"))||{};r[u.info.id]=u,localStorage.setItem("peers",JSON.stringify(r))}});let Xe=!1;function si(e){console.log("getServerConf",e),!Xe&&(Xe=!0,fetch(oi+"/api/server-config",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+e}}).then(u=>u.json()).then(u=>{if(Xe=!1,u.code===0&&((!localStorage.getItem("custom-rendezvous-server")||!localStorage.getItem("key"))&&(localStorage.setItem("custom-rendezvous-server",u.data.id_server),localStorage.setItem("key",u.data.key)),u.data.peers)){const r=JSON.parse(localStorage.getItem("peers"))||{};let n=!1;Object.keys(u.data.peers).forEach(i=>{if(r[i]?r[i].info=u.data.peers[i].info:(r[i]=u.data.peers[i],n=!0),r[i].info&&r[i].info.hash&&!r[i].password){let t=window.atob(r[i].info.hash);const s=ai(t);r[i].password=s.toString(),r[i].remember=!0}}),localStorage.setItem("peers",JSON.stringify(r)),n&&window.location.reload()}}).catch(u=>{Xe=!1}))}var B=(e=>(e[e.Unknown=0]="Unknown",e[e.Alt=1]="Alt",e[e.Backspace=2]="Backspace",e[e.CapsLock=3]="CapsLock",e[e.Control=4]="Control",e[e.Delete=5]="Delete",e[e.DownArrow=6]="DownArrow",e[e.End=7]="End",e[e.Escape=8]="Escape",e[e.F1=9]="F1",e[e.F10=10]="F10",e[e.F11=11]="F11",e[e.F12=12]="F12",e[e.F2=13]="F2",e[e.F3=14]="F3",e[e.F4=15]="F4",e[e.F5=16]="F5",e[e.F6=17]="F6",e[e.F7=18]="F7",e[e.F8=19]="F8",e[e.F9=20]="F9",e[e.Home=21]="Home",e[e.LeftArrow=22]="LeftArrow",e[e.Meta=23]="Meta",e[e.Option=24]="Option",e[e.PageDown=25]="PageDown",e[e.PageUp=26]="PageUp",e[e.Return=27]="Return",e[e.RightArrow=28]="RightArrow",e[e.Shift=29]="Shift",e[e.Space=30]="Space",e[e.Tab=31]="Tab",e[e.UpArrow=32]="UpArrow",e[e.Numpad0=33]="Numpad0",e[e.Numpad1=34]="Numpad1",e[e.Numpad2=35]="Numpad2",e[e.Numpad3=36]="Numpad3",e[e.Numpad4=37]="Numpad4",e[e.Numpad5=38]="Numpad5",e[e.Numpad6=39]="Numpad6",e[e.Numpad7=40]="Numpad7",e[e.Numpad8=41]="Numpad8",e[e.Numpad9=42]="Numpad9",e[e.Cancel=43]="Cancel",e[e.Clear=44]="Clear",e[e.Menu=45]="Menu",e[e.Pause=46]="Pause",e[e.Kana=47]="Kana",e[e.Hangul=48]="Hangul",e[e.Junja=49]="Junja",e[e.Final=50]="Final",e[e.Hanja=51]="Hanja",e[e.Kanji=52]="Kanji",e[e.Convert=53]="Convert",e[e.Select=54]="Select",e[e.Print=55]="Print",e[e.Execute=56]="Execute",e[e.Snapshot=57]="Snapshot",e[e.Insert=58]="Insert",e[e.Help=59]="Help",e[e.Sleep=60]="Sleep",e[e.Separator=61]="Separator",e[e.Scroll=62]="Scroll",e[e.NumLock=63]="NumLock",e[e.RWin=64]="RWin",e[e.Apps=65]="Apps",e[e.Multiply=66]="Multiply",e[e.Add=67]="Add",e[e.Subtract=68]="Subtract",e[e.Decimal=69]="Decimal",e[e.Divide=70]="Divide",e[e.Equals=71]="Equals",e[e.NumpadEnter=72]="NumpadEnter",e[e.RShift=73]="RShift",e[e.RControl=74]="RControl",e[e.RAlt=75]="RAlt",e[e.CtrlAltDel=100]="CtrlAltDel",e[e.LockScreen=101]="LockScreen",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(B||{});function iu(e){switch(e){case 0:case"Unknown":return 0;case 1:case"Alt":return 1;case 2:case"Backspace":return 2;case 3:case"CapsLock":return 3;case 4:case"Control":return 4;case 5:case"Delete":return 5;case 6:case"DownArrow":return 6;case 7:case"End":return 7;case 8:case"Escape":return 8;case 9:case"F1":return 9;case 10:case"F10":return 10;case 11:caLine truncated
|
||||
<div id="connect" style="text-align: center"><table style="display: inline-block">
|
||||
<tr><td><span>Host: </span></td><td><input id="host" /></td></tr>
|
||||
<tr><td><span>Key: </span></td><td><input id="key" /></td></tr>
|
||||
@@ -19,4 +19,4 @@ var yi=Object.defineProperty;var xi=(e,u,r)=>u in e?yi(e,u,{enumerable:!0,config
|
||||
<canvas id="player"></canvas>
|
||||
<canvas id="test-yuv-decoder-canvas"></canvas>
|
||||
</div>
|
||||
`;let e;window.init(),document.body.onload=()=>{const r=document.querySelector("#host");r.value=localStorage.getItem("custom-rendezvous-server");const n=document.querySelector("#id");n.value=localStorage.getItem("id");const i=document.querySelector("#key");i.value=localStorage.getItem("key"),e=YUVCanvas.attach(document.getElementById("player"))},window.connect=()=>{const r=document.querySelector("#host");localStorage.setItem("custom-rendezvous-server",r.value);const n=document.querySelector("#id");localStorage.setItem("id",n.value);const i=document.querySelector("#key");localStorage.setItem("key",i.value),(async()=>{const s=hi();s.setMsgbox(u),s.setDraw(l=>{Eu(l),e.drawFrame(l)}),document.querySelector("div#status").style.display="block",document.querySelector("div#connect").style.display="none",document.querySelector("div#text").innerHTML="Connecting ...",await s.start(n.value)})()},window.cancel=()=>{ki(),document.querySelector("div#connect").style.display="block",document.querySelector("div#password").style.display="none",document.querySelector("div#status").style.display="none",document.querySelector("div#canvas").style.display="none"},window.confirm=()=>{const r=document.querySelector("input#password").value;r&&(document.querySelector("div#password").style.display="none",ku().login(r))}}
|
||||
`;let e;window.init(),document.body.onload=()=>{const r=document.querySelector("#host");r.value=localStorage.getItem("custom-rendezvous-server");const n=document.querySelector("#id");n.value=localStorage.getItem("id");const i=document.querySelector("#key");i.value=localStorage.getItem("key"),e=YUVCanvas.attach(document.getElementById("player"))},window.connect=()=>{const r=document.querySelector("#host");localStorage.setItem("custom-rendezvous-server",r.value);const n=document.querySelector("#id");localStorage.setItem("id",n.value);const i=document.querySelector("#key");localStorage.setItem("key",i.value),(async()=>{const s=Fi();s.setMsgbox(u),s.setDraw(l=>{Eu(l),e.drawFrame(l)}),document.querySelector("div#status").style.display="block",document.querySelector("div#connect").style.display="none",document.querySelector("div#text").innerHTML="Connecting ...",await s.start(n.value)})()},window.cancel=()=>{hi(),document.querySelector("div#connect").style.display="block",document.querySelector("div#password").style.display="none",document.querySelector("div#status").style.display="none",document.querySelector("div#canvas").style.display="none"},window.confirm=()=>{const r=document.querySelector("input#password").value;r&&(document.querySelector("div#password").style.display="none",ku().login(r))}}
|
||||
Vendored
+20
-9
@@ -1,11 +1,14 @@
|
||||
import Connection from "./connection";
|
||||
import _sodium from "libsodium-wrappers";
|
||||
import { CursorData } from "./message";
|
||||
import {loadVp9} from "./codec";
|
||||
import {checkIfRetry, version} from "./gen_js_from_hbb";
|
||||
import {initZstd, translate} from "./common";
|
||||
import PCMPlayer from "pcm-player";
|
||||
import {getServerConf} from "./ljw";
|
||||
|
||||
window.myconsole = (...args) => {
|
||||
console.log(args);
|
||||
}
|
||||
window.curConn = undefined;
|
||||
window.isMobile = () => {
|
||||
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
|
||||
@@ -126,6 +129,7 @@ export function newConn() {
|
||||
}
|
||||
|
||||
let sodium;
|
||||
|
||||
export async function verify(signed, pk) {
|
||||
if (!sodium) {
|
||||
await _sodium.ready;
|
||||
@@ -178,6 +182,7 @@ export function decrypt(signed, nonce, key) {
|
||||
}
|
||||
|
||||
window.setByName = (name, value) => {
|
||||
myconsole('setByName', name, value);
|
||||
switch (name) {
|
||||
case 'remote_id':
|
||||
localStorage.setItem('remote-id', value);
|
||||
@@ -256,6 +261,9 @@ window.setByName = (name, value) => {
|
||||
case 'option':
|
||||
value = JSON.parse(value);
|
||||
localStorage.setItem(value.name, value.value);
|
||||
if (value.name === 'access_token' && value.value) {
|
||||
getServerConf(value.value);
|
||||
}
|
||||
break;
|
||||
case 'peer_option':
|
||||
value = JSON.parse(value);
|
||||
@@ -271,6 +279,7 @@ window.setByName = (name, value) => {
|
||||
|
||||
window.getByName = (name, arg) => {
|
||||
let v = _getByName(name, arg);
|
||||
myconsole('getByName', name, arg, v);
|
||||
if (typeof v == 'string' || v instanceof String) return v;
|
||||
if (v == undefined || v == null) return '';
|
||||
return JSON.stringify(v);
|
||||
@@ -299,7 +308,11 @@ function _getByName(name, arg) {
|
||||
case 'toggle_option':
|
||||
return curConn.getOption(arg) || false;
|
||||
case 'option':
|
||||
return localStorage.getItem(arg);
|
||||
const v = localStorage.getItem(arg);
|
||||
if (arg === 'access_token' && v) {
|
||||
getServerConf(v);
|
||||
}
|
||||
return v;
|
||||
case 'image_quality':
|
||||
return curConn.getImageQuality();
|
||||
case 'translate':
|
||||
@@ -336,7 +349,8 @@ window.init = async () => {
|
||||
opusWorker.onmessage = (e) => {
|
||||
pcmPlayer.feed(e.data);
|
||||
}
|
||||
loadVp9(() => { });
|
||||
loadVp9(() => {
|
||||
});
|
||||
await initZstd();
|
||||
console.log('init done');
|
||||
}
|
||||
@@ -362,8 +376,7 @@ export function copyToClipboard(text) {
|
||||
// Internet Explorer-specific code path to prevent textarea being shown while dialog is visible.
|
||||
return window.clipboardData.setData("Text", text);
|
||||
|
||||
}
|
||||
else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
|
||||
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
|
||||
var textarea = document.createElement("textarea");
|
||||
textarea.textContent = text;
|
||||
textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in Microsoft Edge.
|
||||
@@ -371,12 +384,10 @@ export function copyToClipboard(text) {
|
||||
textarea.select();
|
||||
try {
|
||||
return document.execCommand("copy"); // Security exception may be thrown by some browsers.
|
||||
}
|
||||
catch (ex) {
|
||||
} catch (ex) {
|
||||
console.warn("Copy to clipboard failed.", ex);
|
||||
// return prompt("Copy to clipboard: Ctrl+C, Enter", text);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+10
-11
@@ -49,11 +49,13 @@ if (share_token) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const autoWriteServer = () => {
|
||||
return setTimeout(() => {
|
||||
const token = localStorage.getItem('access_token')
|
||||
if (token && apiserver) {
|
||||
let fetching = false
|
||||
export function getServerConf(token){
|
||||
console.log('getServerConf', token)
|
||||
if(fetching){
|
||||
return
|
||||
}
|
||||
fetching = true
|
||||
fetch(apiserver + "/api/server-config", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -62,12 +64,12 @@ const autoWriteServer = () => {
|
||||
}
|
||||
}
|
||||
).then(res => res.json()).then(res => {
|
||||
fetching = false
|
||||
if (res.code === 0) {
|
||||
if (!localStorage.getItem('custom-rendezvous-server') || !localStorage.getItem('key')) {
|
||||
localStorage.setItem('custom-rendezvous-server', res.data.id_server)
|
||||
localStorage.setItem('key', res.data.key)
|
||||
}
|
||||
|
||||
if (res.data.peers) {
|
||||
const oldPeers = JSON.parse(localStorage.getItem('peers')) || {}
|
||||
let needUpdate = false
|
||||
@@ -91,10 +93,7 @@ const autoWriteServer = () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catch(_ => {
|
||||
fetching = false
|
||||
})
|
||||
} else {
|
||||
autoWriteServer()
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
autoWriteServer()
|
||||
@@ -262,3 +262,10 @@ func (us *UserService) UserThirdInfo(userId uint, op string) *model.UserThird {
|
||||
global.DB.Where("user_id = ? and third_type = ?", userId, op).First(ut)
|
||||
return ut
|
||||
}
|
||||
|
||||
// FindLatestUserIdFromLoginLogByUuid 根据uuid查找最后登录的用户id
|
||||
func (us *UserService) FindLatestUserIdFromLoginLogByUuid(uuid string) uint {
|
||||
llog := &model.LoginLog{}
|
||||
global.DB.Where("uuid = ?", uuid).Order("id desc").First(llog)
|
||||
return llog.UserId
|
||||
}
|
||||
Reference in new issue
Block a user