mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
restricitng allow unsealed if transforms not possible
This commit is contained in:
parent
4c386fac8e
commit
25e469a639
@ -3897,6 +3897,8 @@ components:
|
|||||||
type: boolean
|
type: boolean
|
||||||
allowUnsealed:
|
allowUnsealed:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
transformSupported:
|
||||||
|
type: boolean
|
||||||
enableIce:
|
enableIce:
|
||||||
type: boolean
|
type: boolean
|
||||||
iceUrl:
|
iceUrl:
|
||||||
@ -3953,6 +3955,8 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
searchable:
|
searchable:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
allowUnsealed:
|
||||||
|
type: boolean
|
||||||
pushEnabled:
|
pushEnabled:
|
||||||
type: boolean
|
type: boolean
|
||||||
sealable:
|
sealable:
|
||||||
@ -4291,8 +4295,6 @@ components:
|
|||||||
updated:
|
updated:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
allowUnsealed:
|
|
||||||
type: boolean
|
|
||||||
enableImage:
|
enableImage:
|
||||||
type: boolean
|
type: boolean
|
||||||
enableAudio:
|
enableAudio:
|
||||||
|
@ -4,8 +4,6 @@ set -e
|
|||||||
sqlite3 /var/lib/databag/databag.db "VACUUM;"
|
sqlite3 /var/lib/databag/databag.db "VACUUM;"
|
||||||
sqlite3 /var/lib/databag/databag.db "CREATE TABLE IF NOT EXISTS 'configs' ('id' integer NOT NULL UNIQUE,'config_id' text NOT NULL,'str_value' text,'num_value' integer,'bool_value' numeric,'bin_value' blob,PRIMARY KEY ('id'));"
|
sqlite3 /var/lib/databag/databag.db "CREATE TABLE IF NOT EXISTS 'configs' ('id' integer NOT NULL UNIQUE,'config_id' text NOT NULL,'str_value' text,'num_value' integer,'bool_value' numeric,'bin_value' blob,PRIMARY KEY ('id'));"
|
||||||
sqlite3 /var/lib/databag/databag.db "CREATE UNIQUE INDEX IF NOT EXISTS 'idx_configs_config_id' ON 'configs'('config_id');"
|
sqlite3 /var/lib/databag/databag.db "CREATE UNIQUE INDEX IF NOT EXISTS 'idx_configs_config_id' ON 'configs'('config_id');"
|
||||||
sqlite3 /var/lib/databag/databag.db "delete from configs where config_id='script_path';"
|
|
||||||
sqlite3 /var/lib/databag/databag.db "insert into configs (config_id, str_value) values ('script_path', '/opt/databag/transform/');"
|
|
||||||
|
|
||||||
if [[ -v ADMIN ]]; then
|
if [[ -v ADMIN ]]; then
|
||||||
sqlite3 /var/lib/databag/databag.db "delete from configs where config_id='configured';"
|
sqlite3 /var/lib/databag/databag.db "delete from configs where config_id='configured';"
|
||||||
@ -20,5 +18,5 @@ if [ "$DEV" == "1" ]; then
|
|||||||
done
|
done
|
||||||
else
|
else
|
||||||
cd /app/databag/net/server
|
cd /app/databag/net/server
|
||||||
/usr/local/go/bin/go run databag -p 7000 -w /app/databag/net/web/build -s /var/lib/databag
|
/usr/local/go/bin/go run databag -p 7000 -w /app/databag/net/web/build -s /var/lib/databag -t /opt/databag/transform
|
||||||
fi
|
fi
|
||||||
|
@ -29,6 +29,7 @@ func GetNodeConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
config.IcePassword = getStrConfigValue(CNFIcePassword, "")
|
config.IcePassword = getStrConfigValue(CNFIcePassword, "")
|
||||||
config.EnableOpenAccess = getBoolConfigValue(CNFEnableOpenAccess, false);
|
config.EnableOpenAccess = getBoolConfigValue(CNFEnableOpenAccess, false);
|
||||||
config.OpenAccessLimit = getNumConfigValue(CNFOpenAccessLimit, 0);
|
config.OpenAccessLimit = getNumConfigValue(CNFOpenAccessLimit, 0);
|
||||||
|
config.TransformSupported = getStrConfigValue(CNFScriptPath, "") != "";
|
||||||
|
|
||||||
WriteResponse(w, config)
|
WriteResponse(w, config)
|
||||||
}
|
}
|
||||||
|
@ -372,6 +372,8 @@ type NodeConfig struct {
|
|||||||
|
|
||||||
AccountStorage int64 `json:"accountStorage"`
|
AccountStorage int64 `json:"accountStorage"`
|
||||||
|
|
||||||
|
TransformSupported bool `json:"transformSupported"`
|
||||||
|
|
||||||
AllowUnsealed bool `json:"allowUnsealed"`
|
AllowUnsealed bool `json:"allowUnsealed"`
|
||||||
|
|
||||||
PushSupported bool `json:"pushSupported"`
|
PushSupported bool `json:"pushSupported"`
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
|
|
||||||
var DB *gorm.DB;
|
var DB *gorm.DB;
|
||||||
|
|
||||||
func SetPath(path string) {
|
func SetPath(storePath string, transformPath string) {
|
||||||
db, err := gorm.Open(sqlite.Open(path + "/databag.db"), &gorm.Config{
|
db, err := gorm.Open(sqlite.Open(storePath + "/databag.db"), &gorm.Config{
|
||||||
Logger: logger.Default.LogMode(logger.Silent),
|
Logger: logger.Default.LogMode(logger.Silent),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -20,12 +20,27 @@ func SetPath(path string) {
|
|||||||
}
|
}
|
||||||
AutoMigrate(db)
|
AutoMigrate(db)
|
||||||
|
|
||||||
// upsert key type
|
// upsert asset path
|
||||||
err = db.Transaction(func(tx *gorm.DB) error {
|
err = db.Transaction(func(tx *gorm.DB) error {
|
||||||
if res := tx.Clauses(clause.OnConflict{
|
if res := tx.Clauses(clause.OnConflict{
|
||||||
Columns: []clause.Column{{Name: "config_id"}},
|
Columns: []clause.Column{{Name: "config_id"}},
|
||||||
DoUpdates: clause.AssignmentColumns([]string{"str_value"}),
|
DoUpdates: clause.AssignmentColumns([]string{"str_value"}),
|
||||||
}).Create(&Config{ConfigID: "asset_path", StrValue: path + "/assets"}).Error; res != nil {
|
}).Create(&Config{ConfigID: "asset_path", StrValue: storePath + "/assets"}).Error; res != nil {
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err);
|
||||||
|
panic("failed to set database path")
|
||||||
|
}
|
||||||
|
|
||||||
|
// upsert script path
|
||||||
|
err = db.Transaction(func(tx *gorm.DB) error {
|
||||||
|
if res := tx.Clauses(clause.OnConflict{
|
||||||
|
Columns: []clause.Column{{Name: "config_id"}},
|
||||||
|
DoUpdates: clause.AssignmentColumns([]string{"str_value"}),
|
||||||
|
}).Create(&Config{ConfigID: "script_path", StrValue: transformPath}).Error; res != nil {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
var cert string
|
var cert string
|
||||||
var key string
|
var key string
|
||||||
|
var transformPath string
|
||||||
|
|
||||||
port := ":443"
|
port := ":443"
|
||||||
storePath := "/var/lib/databag"
|
storePath := "/var/lib/databag"
|
||||||
@ -29,19 +30,21 @@ func main() {
|
|||||||
cert = args[i + 1]
|
cert = args[i + 1]
|
||||||
} else if args[i] == "-k" {
|
} else if args[i] == "-k" {
|
||||||
key = args[i + 1]
|
key = args[i + 1]
|
||||||
|
} else if args[i] == "-t" {
|
||||||
|
transformPath = args[i + 1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
store.SetPath(storePath);
|
store.SetPath(storePath, transformPath);
|
||||||
router := app.NewRouter(webApp)
|
router := app.NewRouter(webApp)
|
||||||
origins := handlers.AllowedOrigins([]string{"*"})
|
origins := handlers.AllowedOrigins([]string{"*"})
|
||||||
methods := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS"})
|
methods := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS"})
|
||||||
|
|
||||||
if cert != "" && key != "" {
|
if cert != "" && key != "" {
|
||||||
log.Printf("using args:" + " -s " + storePath + " -w " + webApp + " -p " + port[1:] + " -c " + cert + " -k " + key)
|
log.Printf("using args:" + " -s " + storePath + " -w " + webApp + " -p " + port[1:] + " -c " + cert + " -k " + key + " -t " + transformPath)
|
||||||
log.Fatal(http.ListenAndServeTLS(port, cert, key, handlers.CORS(origins, methods)(router)))
|
log.Fatal(http.ListenAndServeTLS(port, cert, key, handlers.CORS(origins, methods)(router)))
|
||||||
} else {
|
} else {
|
||||||
log.Printf("using args:" + " -s " + storePath + " -w " + webApp + " -p " + port[1:]);
|
log.Printf("using args:" + " -s " + storePath + " -w " + webApp + " -p " + port[1:] + " -t " + transformPath)
|
||||||
log.Fatal(http.ListenAndServe(port, handlers.CORS(origins, methods)(router)))
|
log.Fatal(http.ListenAndServe(port, handlers.CORS(origins, methods)(router)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,11 +139,13 @@ export function Dashboard() {
|
|||||||
<Switch onChange={(e) => actions.setPushSupported(e)} size="small"
|
<Switch onChange={(e) => actions.setPushSupported(e)} size="small"
|
||||||
defaultChecked={true} checked={state.pushSupported} />
|
defaultChecked={true} checked={state.pushSupported} />
|
||||||
</div>
|
</div>
|
||||||
|
{ state.transformSupported && (
|
||||||
<div className="field">
|
<div className="field">
|
||||||
<div>Allow Unsealed Topics: </div>
|
<div>Allow Unsealed Topics: </div>
|
||||||
<Switch onChange={(e) => actions.setAllowUnsealed(e)} size="small"
|
<Switch onChange={(e) => actions.setAllowUnsealed(e)} size="small"
|
||||||
defaultChecked={true} checked={state.allowUnsealed} />
|
defaultChecked={true} checked={state.allowUnsealed} />
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
<div className="field label">
|
<div className="field label">
|
||||||
<span>Topic Content:</span>
|
<span>Topic Content:</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -15,6 +15,7 @@ export function useDashboard() {
|
|||||||
keyType: null,
|
keyType: null,
|
||||||
pushSupported: null,
|
pushSupported: null,
|
||||||
allowUnsealed: null,
|
allowUnsealed: null,
|
||||||
|
transformSupported: false,
|
||||||
enableImage: null,
|
enableImage: null,
|
||||||
enableAudio: null,
|
enableAudio: null,
|
||||||
enableVideo: null,
|
enableVideo: null,
|
||||||
@ -129,7 +130,7 @@ export function useDashboard() {
|
|||||||
if (!state.busy) {
|
if (!state.busy) {
|
||||||
updateState({ busy: true });
|
updateState({ busy: true });
|
||||||
try {
|
try {
|
||||||
const { domain, keyType, accountStorage, pushSupported, allowUnsealed, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit } = state;
|
const { domain, keyType, accountStorage, pushSupported, transformSupported, allowUnsealed, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit } = state;
|
||||||
const storage = accountStorage * 1073741824;
|
const storage = accountStorage * 1073741824;
|
||||||
const config = { domain, accountStorage: storage, keyType, enableImage, enableAudio, enableVideo, pushSupported, allowUnsealed, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit };
|
const config = { domain, accountStorage: storage, keyType, enableImage, enableAudio, enableVideo, pushSupported, allowUnsealed, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit };
|
||||||
await setNodeConfig(app.state.adminToken, config);
|
await setNodeConfig(app.state.adminToken, config);
|
||||||
@ -147,9 +148,9 @@ export function useDashboard() {
|
|||||||
const syncConfig = async () => {
|
const syncConfig = async () => {
|
||||||
try {
|
try {
|
||||||
const config = await getNodeConfig(app.state.adminToken);
|
const config = await getNodeConfig(app.state.adminToken);
|
||||||
const { storage, domain, keyType, pushSupported, allowUnsealed, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit } = config;
|
const { storage, domain, keyType, pushSupported, transformSupported, allowUnsealed, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit } = config;
|
||||||
const accountStorage = Math.ceil(storage / 1073741824);
|
const accountStorage = Math.ceil(storage / 1073741824);
|
||||||
updateState({ configError: false, domain, accountStorage, keyType, enableImage, enableAudio, enableVideo, pushSupported, allowUnsealed, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit });
|
updateState({ configError: false, domain, accountStorage, keyType, enableImage, enableAudio, enableVideo, pushSupported, transformSupported, allowUnsealed, enableIce, iceUrl, iceUsername, icePassword, enableOpenAccess, openAccessLimit });
|
||||||
}
|
}
|
||||||
catch(err) {
|
catch(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
Loading…
Reference in New Issue
Block a user