Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* delete connect

* update user

* change branch

* API feedback (IceWhaleTech#341)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* change branch

* update route

* change branch

* Update route.go

* 0.3.4 Function development completed

* Update system.go

* update ui

* Completed v0.3.4 and released alpha

Co-authored-by: Tiger Wang (王豫) <[email protected]>
  • Loading branch information
LinkLeong and tigerinus authored Jul 22, 2022
1 parent 5cc41fa commit 6f98995
Show file tree
Hide file tree
Showing 108 changed files with 4,583 additions and 7,952 deletions.
2 changes: 1 addition & 1 deletion UI
Submodule UI updated 171 files
4 changes: 2 additions & 2 deletions alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: LinkLeong [email protected]
* @Date: 2022-06-27 11:37:26
* @LastEditors: LinkLeong
* @LastEditTime: 2022-07-01 15:51:29
* @LastEditTime: 2022-07-21 18:12:31
* @FilePath: /CasaOS/alpha.md
* @Description:
* @Website: https://www.casaos.io
Expand All @@ -17,7 +17,7 @@ There is a risk of data loss in non-release versions, so please be careful to ba

## Install/Update

``` curl -fsSL https://get.casaos.io | bash -s -- -v v0.3.3-alpha ```
``` curl -fsSL https://get.casaos.io | bash -s -- -v v0.3.4-alpha ```

## Check change log

Expand Down
10 changes: 1 addition & 9 deletions conf/conf.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@ TempPath = /var/lib/casaos/temp

[server]
HttpPort = 80
UDPPort =
RunMode = release
ServerApi = https://api.casaos.io/casaos-api
Handshake = socket.casaos.io
Token =
USBAutoMount =


[system]
WidgetList =


[file]
ShareDir =
DownloadDir =
[system]
8 changes: 2 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ require (
github.com/docker/go-connections v0.4.0
github.com/dsoprea/go-exif/v3 v3.0.0-20210625224831-a6301f85c82b
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
github.com/forease/gotld v0.0.0-20190808124948-c50ff635576b
github.com/gin-contrib/gzip v0.0.2
github.com/gin-gonic/gin v1.7.2
github.com/go-ini/ini v1.62.0
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-playground/validator/v10 v10.6.1 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/golang-jwt/jwt/v4 v4.4.1
Expand All @@ -38,9 +36,9 @@ require (
github.com/jinzhu/copier v0.3.2
github.com/json-iterator/go v1.1.11 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lucas-clemente/quic-go v0.25.0
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-sqlite3 v1.14.11 // indirect
github.com/mholt/archiver/v3 v3.5.1
Expand All @@ -50,16 +48,13 @@ require (
github.com/opencontainers/selinux v1.8.5 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/prestonTao/upnp v0.0.0-20150206124352-f4370df5e109
github.com/prometheus/procfs v0.7.3 // indirect
github.com/robfig/cron v1.2.0
github.com/satori/go.uuid v1.2.0
github.com/shirou/gopsutil/v3 v3.21.5
github.com/sirupsen/logrus v1.8.1
github.com/smartystreets/assertions v1.2.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/swaggo/gin-swagger v1.3.0
github.com/swaggo/swag v1.7.3
github.com/tidwall/gjson v1.10.2
github.com/tklauser/go-sysconf v0.3.6 // indirect
github.com/ugorji/go v1.2.6 // indirect
Expand All @@ -71,6 +66,7 @@ require (
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
golang.org/x/sys v0.0.0-20211020174200-9d6173849985 // indirect
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/tools v0.1.7 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
68 changes: 0 additions & 68 deletions go.sum

Large diffs are not rendered by default.

39 changes: 2 additions & 37 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var sqliteDB *gorm.DB

var configFlag = flag.String("c", "", "config address")
var dbFlag = flag.String("db", "", "db path")
var showUserInfo = flag.Bool("show-user-info", false, "show user info")
var resetUser = flag.Bool("ru", false, "reset user")
var user = flag.String("user", "", "user name")

Expand All @@ -42,10 +41,6 @@ func init() {
service.Cache = cache.Init()

service.GetToken()
service.UDPAddressMap = make(map[string]string)
//go service.SocketConnect()
service.CancelList = make(map[string]string)
service.InternalInspection = make(map[string][]string)
service.NewVersionApp = make(map[string]string)
route.InitFunction()

Expand All @@ -67,15 +62,7 @@ func init() {
// @BasePath /v1
func main() {
service.NotifyMsg = make(chan notify.Message, 10)
if *showUserInfo {
fmt.Println("CasaOS User Info")
fmt.Println("UserName:" + config.UserInfo.UserName)
fmt.Println("Password:" + config.UserInfo.PWD)
return
}
fmt.Println("Reset User", *resetUser)
if *resetUser {

if user == nil || len(*user) == 0 {
fmt.Println("user is empty")
return
Expand All @@ -89,42 +76,20 @@ func main() {
userData.Password = encryption.GetMD5ByStr(password)
service.MyService.User().UpdateUserPassword(userData)
fmt.Println("User reset successful")
fmt.Println("UserName:" + userData.UserName)
fmt.Println("UserName:" + userData.Username)
fmt.Println("Password:" + password)
return
}
go func() {
service.UDPService()
service.SendIPToServer()
}()
go route.SocketInit(service.NotifyMsg)
go func() {
for i := 0; i < 1000; i++ {
time.Sleep(2 * time.Second)
//service.NotifyMsg <- strconv.Itoa(i)
}
}()

//model.Setup()
//gredis.Setup()
r := route.InitRouter()
//service.SyncTask(sqliteDB)
cron2 := cron.New()
//every day execution
err := cron2.AddFunc("0 0/5 * * * *", func() {
//service.PushIpInfo(*&config.ServerInfo.Token)
//service.UpdataDDNSList(mysqldb)
//service.SyncTask(sqliteDB)

service.SendIPToServer()

service.LoopFriend()
//service.MyService.App().CheckNewImage()
})
if err != nil {
fmt.Println(err)
}
err = cron2.AddFunc("0/5 * * * * *", func() {
err := cron2.AddFunc("0/5 * * * * *", func() {
if service.ClientCount > 0 {
//route.SendNetINfoBySocket()
//route.SendCPUBySocket()
Expand Down
6 changes: 3 additions & 3 deletions middleware/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: LinkLeong [email protected]
* @Date: 2021-10-08 10:29:08
* @LastEditors: LinkLeong
* @LastEditTime: 2022-06-21 15:10:03
* @LastEditTime: 2022-07-13 11:26:12
* @FilePath: /CasaOS/middleware/gin.go
* @Description:
* @Website: https://www.casaos.io
Expand All @@ -26,14 +26,14 @@ func Cors() gin.HandlerFunc {
c.Header("Access-Control-Allow-Origin", "*")
c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE,UPDATE")
//允许跨域设置可以返回其他子段,可以自定义字段
c.Header("Access-Control-Allow-Headers", "Authorization, Content-Length, X-CSRF-Token, Token,session,Language")
c.Header("Access-Control-Allow-Headers", "Authorization, Content-Length, X-CSRF-Token, Token,session,Language,Content-Type,Access-Control-Allow-Origin,Access-Control-Allow-Headers,Access-Control-Allow-Methods,Connection,Host,Origin,Referer,User-Agent,X-Requested-With")
// 允许浏览器(客户端)可以解析的头部 (重要)
c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers")
//c.Writer.Header().Set("Access-Control-Allow-Headers", "Accept, Authorization, Content-Type, Content-Length, X-CSRF-Token, Token, session, Origin, Host, Connection, Accept-Encoding, Accept-Language, X-Requested-With")
//设置缓存时间
c.Header("Access-Control-Max-Age", "172800")
c.Header("Access-Control-Allow-Credentials", "true")
c.Set("content-type", "application/json")
c.Set("Content-Type", "application/json")
//}

//允许类型校验
Expand Down
27 changes: 0 additions & 27 deletions model/app-analyse.go

This file was deleted.

9 changes: 9 additions & 0 deletions model/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ type ServerAppListCollection struct {
Version string `json:"version"`
}

// @tiger - 对于用于出参的数据结构,静态信息(例如 title)和
// 动态信息(例如 state、query_count)应该划分到不同的数据结构中
//
// 这样的好处是
// 1 - 多次获取动态信息时可以减少出参复杂度,因为静态信息只获取一次就好
// 2 - 在未来的迭代中,可以降低维护成本(所有字段都展开放在一个层级维护成本略高)
//
// 另外,一些针对性字段,例如 Docker 相关的,可以用 map 来保存。
// 这样在未来增加多态 App,例如 Snap,不需要维护多个结构,或者一个结构保存不必要的字段
type ServerAppList struct {
Id uint `gorm:"column:id;primary_key" json:"id"`
Title string `json:"title"`
Expand Down
9 changes: 4 additions & 5 deletions model/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
* @Author: link [email protected]
* @Date: 2022-05-16 17:37:08
* @LastEditors: LinkLeong
* @LastEditTime: 2022-06-22 17:45:53
* @LastEditTime: 2022-07-13 10:46:38
* @FilePath: /CasaOS/model/category.go
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description:
*/
package model

Expand All @@ -18,7 +17,7 @@ type CategoryList struct {
//CreatedAt time.Time `json:"created_at"`
//
//UpdatedAt time.Time `json:"updated_at"`
Font string `json:"font"`
Font string `json:"font"` // @tiger - 如果这个和前端有关,应该不属于后端的出参范围,而是前端去界定
Name string `json:"name"`
Count uint `json:"count"`
Count uint `json:"count"` // @tiger - count 属于动态信息,应该单独放在一个出参结构中(原因见另外一个关于 静态/动态 出参的注释)
}
14 changes: 12 additions & 2 deletions model/disk.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* @Author: LinkLeong [email protected]
* @Date: 2022-07-13 10:43:45
* @LastEditors: LinkLeong
* @LastEditTime: 2022-07-13 11:00:04
* @FilePath: /CasaOS/model/disk.go
* @Description:
* @Website: https://www.casaos.io
* Copyright (c) 2022 by icewhale, All Rights Reserved.
*/
package model

type LSBLKModel struct {
Expand Down Expand Up @@ -53,8 +63,8 @@ type DriveUSB struct {
Size uint64 `json:"size"`
Used uint64 `json:"use"`
Model string `json:"model"`
Mount bool `json:"mount"` //是否完全挂载
Avail uint64 `json:"avail"` //可用空间
Mount bool `json:"mount"`
Avail uint64 `json:"avail"`
}

type Storage struct {
Expand Down
10 changes: 5 additions & 5 deletions model/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: LinkLeong [email protected]
* @Date: 2021-12-08 18:10:25
* @LastEditors: LinkLeong
* @LastEditTime: 2022-06-14 17:20:36
* @LastEditTime: 2022-07-13 10:49:16
* @FilePath: /CasaOS/model/docker.go
* @Description:
* @Website: https://www.casaos.io
Expand All @@ -11,8 +11,8 @@
package model

type DockerStatsModel struct {
Icon string `json:"icon"`
Title string `json:"title"`
Data interface{} `json:"data"`
Pre interface{} `json:"pre"`
Icon string `json:"icon"`
Title string `json:"title"`
Data interface{} `json:"data"`
Previous interface{} `json:"previous"`
}
21 changes: 11 additions & 10 deletions model/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,17 @@ func (p *PathArray) Scan(input interface{}) error {
//}

type CustomizationPostData struct {
CustomId string `json:"custom_id"`
Origin string `json:"origin"`
NetworkModel string `json:"network_model"`
Index string `json:"index"`
Icon string `json:"icon"`
Image string `json:"image"`
Envs EnvArray `json:"envs"`
Ports PortArray `json:"ports"`
Volumes PathArray `json:"volumes"`
Devices PathArray `json:"devices"`
ContainerName string `json:"container_name"`
CustomId string `json:"custom_id"`
Origin string `json:"origin"`
NetworkModel string `json:"network_model"`
Index string `json:"index"`
Icon string `json:"icon"`
Image string `json:"image"`
Envs EnvArray `json:"envs"`
Ports PortArray `json:"ports"`
Volumes PathArray `json:"volumes"`
Devices PathArray `json:"devices"`
//Port string `json:"port,omitempty"`
PortMap string `json:"port_map"`
CpuShares int64 `json:"cpu_shares"`
Expand Down
16 changes: 0 additions & 16 deletions model/notify/person.go

This file was deleted.

19 changes: 19 additions & 0 deletions model/notify/storage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* @Author: LinkLeong [email protected]
* @Date: 2022-07-15 10:43:00
* @LastEditors: LinkLeong
* @LastEditTime: 2022-07-15 10:56:17
* @FilePath: /CasaOS/model/notify/storage.go
* @Description:
* @Website: https://www.casaos.io
* Copyright (c) 2022 by icewhale, All Rights Reserved.
*/
package notify

type StorageMessage struct {
Type string `json:"type"` //sata,usb
Action string `json:"action"` //remove add
Path string `json:"path"`
Volume string `json:"volume"`
Size uint64 `json:"size"`
}
Loading

0 comments on commit 6f98995

Please sign in to comment.