Skip to content

CasaOS - A simple, easy-to-use, elegant open-source Personal Cloud system.

Merge branch 'add_file_drive'

link32980f403309
diff --cc go.mod
index 66e93ff,0b36533..6ffe8fb
--- a/go.mod
+++ b/go.mod
@@@ -20,9 -23,11 +21,10 @@@ require
github.com/googollee/go-socket.io v1.6.2
github.com/gorilla/websocket v1.5.0
github.com/hirochachacha/go-smb2 v1.1.0
- github.com/json-iterator/go v1.1.12
- github.com/maruel/natural v1.1.0
+ github.com/labstack/echo/v4 v4.10.0
github.com/mholt/archiver/v3 v3.5.1
github.com/patrickmn/go-cache v2.1.0+incompatible
+ github.com/pkg/errors v0.9.1
github.com/robfig/cron v1.2.0
github.com/satori/go.uuid v1.2.0
github.com/shirou/gopsutil/v3 v3.22.11
diff --cc go.sum
index d5f1dc6,acc3718..05cd2c6
--- a/go.sum
+++ b/go.sum
@@@ -143,10 -136,10 +143,12 @@@ github.com/jinzhu/inflection v1.0.0/go.
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
+github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
+github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
+ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
@@@ -201,10 -181,9 +203,12 @@@ github.com/patrickmn/go-cache v2.1.0+in
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
+github.com/perimeterx/marshmallow v1.1.4 h1:pZLDH9RjlLGGorbXhcaQLhfuV0pFMNfPO55FuFkxqLw=
+github.com/perimeterx/marshmallow v1.1.4/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
+github.com/pierrec/lz4/v4 v4.1.2 h1:qvY3YFXRQE/XB8MlLzJH7mSzBs74eA2gg52YTk6jUPM=
github.com/pierrec/lz4/v4 v4.1.2/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
+ github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc=
+ github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@@ -293,10 -275,12 +297,11 @@@ golang.org/x/net v0.0.0-20200513185701-
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
+ golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
-golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
-golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
-golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
+golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
+golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.3.0 h1:6l90koy8/LaBLmLu8jpHeHexzMwEita0zFfYlggy2F8=
golang.org/x/oauth2 v0.3.0/go.mod h1:rQrIauxkUhJ6CuwEXwymO2/eh4xz2ZWF1nBkcxS+tGk=
@@@ -325,11 -310,11 +330,11 @@@ golang.org/x/sys v0.0.0-20220728004956-
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
- golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
- golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+ golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
+ golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg=
+golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@@ -372,13 -356,12 +377,13 @@@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93X
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
- gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
- gorm.io/gorm v1.24.2 h1:9wR6CFD+G8nOusLdvkZelOEhpJVwwHzpQOUM+REd6U0=
gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
+ gorm.io/gorm v1.24.3 h1:WL2ifUmzR/SLp85CSURAfybcHnGZ+yLSGSxgYXlFBHg=
+ gorm.io/gorm v1.24.3/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=
diff --cc main.go
index b63d5fa,986e392..dbcdac9
--- a/main.go
+++ b/main.go
@@@ -14,11 -11,9 +14,12 @@@ import
"github.com/IceWhaleTech/CasaOS-Common/model"
"github.com/IceWhaleTech/CasaOS-Common/utils/constants"
"github.com/IceWhaleTech/CasaOS-Common/utils/logger"
+
+ util_http "github.com/IceWhaleTech/CasaOS-Common/utils/http"
+
"github.com/IceWhaleTech/CasaOS/pkg/cache"
"github.com/IceWhaleTech/CasaOS/pkg/config"
+ "github.com/IceWhaleTech/CasaOS/pkg/config/configfile"
"github.com/IceWhaleTech/CasaOS/pkg/sqlite"
"github.com/IceWhaleTech/CasaOS/pkg/utils/command"
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
@@@ -26,8 -21,10 +27,9 @@@
"github.com/IceWhaleTech/CasaOS/service"
"github.com/IceWhaleTech/CasaOS/types"
"github.com/coreos/go-systemd/daemon"
- "github.com/gin-gonic/gin"
"go.uber.org/zap"
+ _ "github.com/IceWhaleTech/CasaOS/drivers"
"github.com/robfig/cron"
"gorm.io/gorm"
)
@@@ -134,22 -134,10 +151,25 @@@ func main()
if err != nil {
panic(err)
}
- apiPaths := []string{
- routers := []string{"sys", "port", "file", "folder", "batch", "image", "samba", "notify", "socketio", "driver", "storage", "recover", "fs"}
- for _, v := range routers {
++ routers := []string{
+ "/v1/sys",
+ "/v1/port",
+ "/v1/file",
+ "/v1/folder",
+ "/v1/batch",
+ "/v1/image",
+ "/v1/samba",
+ "/v1/notify",
+ "/v1/socketio",
++ "/v1/driver",
++ "/v1/storage",
++ "/v1/recover",
+ route.V2APIPath,
+ route.V2DocPath,
+ }
- for _, apiPath := range apiPaths {
++ for _, apiPath := range routers {
err = service.MyService.Gateway().CreateRoute(&model.Route{
- Path: "/v1/" + v,
+ Path: apiPath,
Target: "http://" + listener.Addr().String(),
})
diff --cc route/v1/samba.go
index db21cfd,ce14f1b..39e0b66
--- a/route/v1/samba.go
+++ b/route/v1/samba.go
@@@ -12,7 -12,7 +12,8 @@@ package v
import (
"fmt"
+ "io/ioutil"
+ "net/http"
"os"
"path/filepath"
"regexp"
diff --cc service/service.go
index 0213a50,5c08b53..3f69e63
--- a/service/service.go
+++ b/service/service.go
@@@ -33,14 -30,20 +33,20 @@@ var
)
type Repository interface {
- // User() UserService
Casa() CasaService
+ Connections() ConnectionsService
+ Gateway() external.ManagementService
+ Health() HealthService
Notify() NotifyServer
Rely() RelyService
- System() SystemService
Shares() SharesService
- Connections() ConnectionsService
- Gateway() external.ManagementService
+ System() SystemService
+ Storage() StorageService
+ Storages() StoragesService
+ StoragePath() StoragePathService
+ FsListService() FsListService
+ FsLinkService() FsLinkService
+ FsService() FsService
}
func NewService(db *gorm.DB, RuntimePath string, socket *socketio.Server) Repository {
@@@ -54,27 -57,60 +60,62 @@@
}
return &store{
- casa: NewCasaService(),
- connections: NewConnectionsService(db),
- gateway: gatewayManagement,
- health: NewHealthService(),
- notify: NewNotifyService(db),
- rely: NewRelyService(db),
- shares: NewSharesService(db),
- system: NewSystemService(),
- gateway: gatewayManagement,
+ casa: NewCasaService(),
++ connections: NewConnectionsService(db),
++ gateway: gatewayManagement,
+ notify: NewNotifyService(db),
+ rely: NewRelyService(db),
+ system: NewSystemService(),
++ health: NewHealthService(),
+ shares: NewSharesService(db),
- connections: NewConnectionsService(db),
+ storage: NewStorageService(),
+ storages: NewStoragesService(),
+ storage_path: NewStoragePathService(),
+ fs_list: NewFsListService(),
+ fs_link: NewFsLinkService(),
+ fs: NewFsService(),
}
}
type store struct {
- db *gorm.DB
- casa CasaService
- connections ConnectionsService
- gateway external.ManagementService
- health HealthService
- notify NotifyServer
- rely RelyService
- shares SharesService
- system SystemService
+ db *gorm.DB
+ casa CasaService
+ notify NotifyServer
+ rely RelyService
+ system SystemService
+ shares SharesService
+ connections ConnectionsService
+ gateway external.ManagementService
+ storage StorageService
+ storages StoragesService
+ storage_path StoragePathService
+ fs_list FsListService
+ fs_link FsLinkService
+ fs FsService
++ health HealthService
+ }
+
+ func (c *store) FsLinkService() FsLinkService {
+ return c.fs_link
+ }
+ func (c *store) FsService() FsService {
+ return c.fs
+ }
+
+ func (c *store) FsListService() FsListService {
+ return c.fs_list
+ }
+
+ func (c *store) StoragePath() StoragePathService {
+ return c.storage_path
+ }
+
+ func (c *store) Storages() StoragesService {
+ return c.storages
+ }
+
+ func (c *store) Storage() StorageService {
+ return c.storage
}
func (c *store) Gateway() external.ManagementService {