mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 11:39:17 +00:00
more golint renaming
This commit is contained in:
parent
19dc8ca900
commit
d5e8fc7394
@ -72,7 +72,7 @@ func AddAccount(w http.ResponseWriter, r *http.Request) {
|
|||||||
fingerprint := hex.EncodeToString(hash[:])
|
fingerprint := hex.EncodeToString(hash[:])
|
||||||
|
|
||||||
// create path for account data
|
// create path for account data
|
||||||
path := getStrConfigValue(CONFIG_ASSETPATH, APPDefaultPath) + "/" + fingerprint
|
path := getStrConfigValue(CNFAssetPath, APPDefaultPath) + "/" + fingerprint
|
||||||
if err := os.Mkdir(path, os.ModePerm); err != nil {
|
if err := os.Mkdir(path, os.ModePerm); err != nil {
|
||||||
ErrResponse(w, http.StatusInternalServerError, err)
|
ErrResponse(w, http.StatusInternalServerError, err)
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ func AddAccount(w http.ResponseWriter, r *http.Request) {
|
|||||||
Image: detail.Image,
|
Image: detail.Image,
|
||||||
Revision: account.ProfileRevision,
|
Revision: account.ProfileRevision,
|
||||||
Version: APPVersion,
|
Version: APPVersion,
|
||||||
Node: getStrConfigValue(CONFIG_DOMAIN, ""),
|
Node: getStrConfigValue(CNFDomain, ""),
|
||||||
}
|
}
|
||||||
|
|
||||||
// send response
|
// send response
|
||||||
|
@ -37,7 +37,7 @@ func AddAccountApp(w http.ResponseWriter, r *http.Request) {
|
|||||||
Name: appData.Name,
|
Name: appData.Name,
|
||||||
Description: appData.Description,
|
Description: appData.Description,
|
||||||
Image: appData.Image,
|
Image: appData.Image,
|
||||||
Url: appData.Url,
|
URL: appData.URL,
|
||||||
Token: access,
|
Token: access,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// save new file
|
// save new file
|
||||||
id := uuid.New().String()
|
id := uuid.New().String()
|
||||||
path := getStrConfigValue(CONFIG_ASSETPATH, APPDefaultPath) + "/" + channelSlot.Account.GUID + "/" + id
|
path := getStrConfigValue(CNFAssetPath, APPDefaultPath) + "/" + channelSlot.Account.GUID + "/" + id
|
||||||
if err := r.ParseMultipartForm(32 << 20); err != nil {
|
if err := r.ParseMultipartForm(32 << 20); err != nil {
|
||||||
ErrResponse(w, http.StatusBadRequest, err)
|
ErrResponse(w, http.StatusBadRequest, err)
|
||||||
return
|
return
|
||||||
@ -172,7 +172,7 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func isStorageFull(act *store.Account) (full bool, err error) {
|
func isStorageFull(act *store.Account) (full bool, err error) {
|
||||||
|
|
||||||
storage := getNumConfigValue(CONFIG_STORAGE, 0);
|
storage := getNumConfigValue(CNFStorage, 0);
|
||||||
if storage == 0 {
|
if storage == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func ClearCardNotes(w http.ResponseWriter, r *http.Request) {
|
|||||||
// save and update contact revision
|
// save and update contact revision
|
||||||
err = store.DB.Transaction(func(tx *gorm.DB) error {
|
err = store.DB.Transaction(func(tx *gorm.DB) error {
|
||||||
slot.Card.Notes = ""
|
slot.Card.Notes = ""
|
||||||
slot.Card.DetailRevision += 1
|
slot.Card.DetailRevision++
|
||||||
if res := tx.Save(&slot.Card).Error; res != nil {
|
if res := tx.Save(&slot.Card).Error; res != nil {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ func GetAccountAvailable(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func getAvailableAccounts() (available int64, err error) {
|
func getAvailableAccounts() (available int64, err error) {
|
||||||
|
|
||||||
open := getBoolConfigValue(CONFIG_OPENACCESS, true)
|
open := getBoolConfigValue(CNFOpenAccess, true)
|
||||||
limit := getNumConfigValue(CONFIG_ACCOUNTLIMIT, 16)
|
limit := getNumConfigValue(CNFAccountLimit, 16)
|
||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
if err = store.DB.Model(&store.Account{}).Count(&count).Error; err != nil {
|
if err = store.DB.Model(&store.Account{}).Count(&count).Error; err != nil {
|
||||||
|
@ -23,7 +23,7 @@ func GetAccountListing(w http.ResponseWriter, r *http.Request) {
|
|||||||
Location: account.AccountDetail.Location,
|
Location: account.AccountDetail.Location,
|
||||||
ImageSet: account.AccountDetail.Image != "",
|
ImageSet: account.AccountDetail.Image != "",
|
||||||
Version: APPVersion,
|
Version: APPVersion,
|
||||||
Node: getStrConfigValue(CONFIG_DOMAIN, ""),
|
Node: getStrConfigValue(CNFDomain, ""),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ func GetAccountListingMessage(w http.ResponseWriter, r *http.Request) {
|
|||||||
Location: detail.Location,
|
Location: detail.Location,
|
||||||
Image: detail.Image,
|
Image: detail.Image,
|
||||||
Version: APPVersion,
|
Version: APPVersion,
|
||||||
Node: getStrConfigValue(CONFIG_DOMAIN, ""),
|
Node: getStrConfigValue(CNFDomain, ""),
|
||||||
}
|
}
|
||||||
msg, res := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
|
msg, res := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
|
||||||
APPSignPKCS1V15, account.GUID, APPMsgIdentity, &identity)
|
APPSignPKCS1V15, account.GUID, APPMsgIdentity, &identity)
|
||||||
|
@ -21,7 +21,7 @@ func GetAccountStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// construct response
|
// construct response
|
||||||
status := &AccountStatus{}
|
status := &AccountStatus{}
|
||||||
status.StorageAvailable = getNumConfigValue(CONFIG_STORAGE, 0);
|
status.StorageAvailable = getNumConfigValue(CNFStorage, 0);
|
||||||
for _, asset := range assets {
|
for _, asset := range assets {
|
||||||
status.StorageUsed += asset.Size
|
status.StorageUsed += asset.Size
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ func GetChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// construct file path
|
// construct file path
|
||||||
path := getStrConfigValue(CONFIG_ASSETPATH, APPDefaultPath) + "/" + act.GUID + "/" + asset.AssetID
|
path := getStrConfigValue(CNFAssetPath, APPDefaultPath) + "/" + act.GUID + "/" + asset.AssetID
|
||||||
http.ServeFile(w, r, path)
|
http.ServeFile(w, r, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@ func GetNodeConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// get node config fields
|
// get node config fields
|
||||||
var config NodeConfig;
|
var config NodeConfig;
|
||||||
config.Domain = getStrConfigValue(CONFIG_DOMAIN, "");
|
config.Domain = getStrConfigValue(CNFDomain, "");
|
||||||
config.AccountLimit = getNumConfigValue(CONFIG_ACCOUNTLIMIT, 16);
|
config.AccountLimit = getNumConfigValue(CNFAccountLimit, 16);
|
||||||
config.OpenAccess = getBoolConfigValue(CONFIG_OPENACCESS, true);
|
config.OpenAccess = getBoolConfigValue(CNFOpenAccess, true);
|
||||||
config.AccountStorage = getNumConfigValue(CONFIG_STORAGE, 0);
|
config.AccountStorage = getNumConfigValue(CNFStorage, 0);
|
||||||
|
|
||||||
WriteResponse(w, config);
|
WriteResponse(w, config);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
func GetNodeStatus(w http.ResponseWriter, r *http.Request) {
|
func GetNodeStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
var config store.Config
|
var config store.Config
|
||||||
err := store.DB.Where("config_id = ?", CONFIG_CONFIGURED).First(&config).Error
|
err := store.DB.Where("config_id = ?", CNFConfigured).First(&config).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
WriteResponse(w, true)
|
WriteResponse(w, true)
|
||||||
|
@ -50,7 +50,7 @@ func GetOpenMessage(w http.ResponseWriter, r *http.Request) {
|
|||||||
Location: detail.Location,
|
Location: detail.Location,
|
||||||
Image: detail.Image,
|
Image: detail.Image,
|
||||||
Version: APPVersion,
|
Version: APPVersion,
|
||||||
Node: getStrConfigValue(CONFIG_DOMAIN, ""),
|
Node: getStrConfigValue(CNFDomain, ""),
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
|
msg, err := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
|
||||||
|
@ -40,7 +40,7 @@ func GetProfileMessage(w http.ResponseWriter, r *http.Request) {
|
|||||||
Location: detail.Location,
|
Location: detail.Location,
|
||||||
Image: detail.Image,
|
Image: detail.Image,
|
||||||
Version: APPVersion,
|
Version: APPVersion,
|
||||||
Node: getStrConfigValue(CONFIG_DOMAIN, ""),
|
Node: getStrConfigValue(CNFDomain, ""),
|
||||||
}
|
}
|
||||||
msg, res := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
|
msg, res := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
|
||||||
APPSignPKCS1V15, account.GUID, APPMsgIdentity, &identity)
|
APPSignPKCS1V15, account.GUID, APPMsgIdentity, &identity)
|
||||||
|
@ -78,7 +78,7 @@ func RemoveAccount(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete asset files
|
// delete asset files
|
||||||
path := getStrConfigValue(CONFIG_ASSETPATH, APPDefaultPath) + "/" + account.GUID
|
path := getStrConfigValue(CNFAssetPath, APPDefaultPath) + "/" + account.GUID
|
||||||
if err = os.RemoveAll(path); err != nil {
|
if err = os.RemoveAll(path); err != nil {
|
||||||
ErrMsg(err)
|
ErrMsg(err)
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ func RemoveNodeAccount(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete asset files
|
// delete asset files
|
||||||
path := getStrConfigValue(CONFIG_ASSETPATH, APPDefaultPath) + "/" + account.GUID
|
path := getStrConfigValue(CNFAssetPath, APPDefaultPath) + "/" + account.GUID
|
||||||
if err = os.RemoveAll(path); err != nil {
|
if err = os.RemoveAll(path); err != nil {
|
||||||
ErrMsg(err)
|
ErrMsg(err)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ func SetAccountAccess(w http.ResponseWriter, r *http.Request) {
|
|||||||
Name: appData.Name,
|
Name: appData.Name,
|
||||||
Description: appData.Description,
|
Description: appData.Description,
|
||||||
Image: appData.Image,
|
Image: appData.Image,
|
||||||
Url: appData.Url,
|
URL: appData.URL,
|
||||||
Token: access,
|
Token: access,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ func SetCardNotes(w http.ResponseWriter, r *http.Request) {
|
|||||||
// save and update contact revision
|
// save and update contact revision
|
||||||
err = store.DB.Transaction(func(tx *gorm.DB) error {
|
err = store.DB.Transaction(func(tx *gorm.DB) error {
|
||||||
slot.Card.Notes = notes
|
slot.Card.Notes = notes
|
||||||
slot.Card.DetailRevision += 1
|
slot.Card.DetailRevision++
|
||||||
if res := tx.Save(&slot.Card).Error; res != nil {
|
if res := tx.Save(&slot.Card).Error; res != nil {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ func SetCardStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
slot.Card.NotifiedArticle = articleRevision
|
slot.Card.NotifiedArticle = articleRevision
|
||||||
slot.Card.NotifiedChannel = channelRevision
|
slot.Card.NotifiedChannel = channelRevision
|
||||||
slot.Card.NotifiedProfile = profileRevision
|
slot.Card.NotifiedProfile = profileRevision
|
||||||
slot.Card.DetailRevision += 1
|
slot.Card.DetailRevision++
|
||||||
|
|
||||||
// save and update contact revision
|
// save and update contact revision
|
||||||
err = store.DB.Transaction(func(tx *gorm.DB) error {
|
err = store.DB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
@ -29,7 +29,7 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
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(&store.Config{ConfigID: CONFIG_DOMAIN, StrValue: config.Domain}).Error; res != nil {
|
}).Create(&store.Config{ConfigID: CNFDomain, StrValue: config.Domain}).Error; res != nil {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
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{"num_value"}),
|
DoUpdates: clause.AssignmentColumns([]string{"num_value"}),
|
||||||
}).Create(&store.Config{ConfigID: CONFIG_ACCOUNTLIMIT, NumValue: config.AccountLimit}).Error; res != nil {
|
}).Create(&store.Config{ConfigID: CNFAccountLimit, NumValue: config.AccountLimit}).Error; res != nil {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
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{"bool_value"}),
|
DoUpdates: clause.AssignmentColumns([]string{"bool_value"}),
|
||||||
}).Create(&store.Config{ConfigID: CONFIG_ACCOUNTLIMIT, BoolValue: config.OpenAccess}).Error; res != nil {
|
}).Create(&store.Config{ConfigID: CNFAccountLimit, BoolValue: config.OpenAccess}).Error; res != nil {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
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{"num_value"}),
|
DoUpdates: clause.AssignmentColumns([]string{"num_value"}),
|
||||||
}).Create(&store.Config{ConfigID: CONFIG_STORAGE, NumValue: config.AccountStorage}).Error; res != nil {
|
}).Create(&store.Config{ConfigID: CNFStorage, NumValue: config.AccountStorage}).Error; res != nil {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
func SetNodeStatus(w http.ResponseWriter, r *http.Request) {
|
func SetNodeStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
var config store.Config
|
var config store.Config
|
||||||
err := store.DB.Where("config_id = ?", CONFIG_CONFIGURED).First(&config).Error
|
err := store.DB.Where("config_id = ?", CNFConfigured).First(&config).Error
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@ -27,10 +27,10 @@ func SetNodeStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = store.DB.Transaction(func(tx *gorm.DB) error {
|
err = store.DB.Transaction(func(tx *gorm.DB) error {
|
||||||
if res := tx.Create(&store.Config{ConfigID: CONFIG_TOKEN, StrValue: token}).Error; res != nil {
|
if res := tx.Create(&store.Config{ConfigID: CNFToken, StrValue: token}).Error; res != nil {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
if res := tx.Create(&store.Config{ConfigID: CONFIG_CONFIGURED, BoolValue: true}).Error; res != nil {
|
if res := tx.Create(&store.Config{ConfigID: CNFConfigured, BoolValue: true}).Error; res != nil {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -78,12 +78,12 @@ func ParamAdminToken(r *http.Request) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// nothing to do if not configured
|
// nothing to do if not configured
|
||||||
if !getBoolConfigValue(CONFIG_CONFIGURED, false) {
|
if !getBoolConfigValue(CNFConfigured, false) {
|
||||||
return http.StatusUnauthorized, errors.New("node not configured")
|
return http.StatusUnauthorized, errors.New("node not configured")
|
||||||
}
|
}
|
||||||
|
|
||||||
// compare password
|
// compare password
|
||||||
value := getStrConfigValue(CONFIG_TOKEN, "");
|
value := getStrConfigValue(CNFToken, "");
|
||||||
if (value != token) {
|
if (value != token) {
|
||||||
return http.StatusUnauthorized, errors.New("invalid admin token")
|
return http.StatusUnauthorized, errors.New("invalid admin token")
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,14 @@ import (
|
|||||||
"databag/internal/store"
|
"databag/internal/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
const CONFIG_OPENACCESS = "open_access"
|
const CNFOpenAccess = "open_access"
|
||||||
const CONFIG_ACCOUNTLIMIT = "account_limit"
|
const CNFAccountLimit = "account_limit"
|
||||||
const CONFIG_CONFIGURED = "configured"
|
const CNFConfigured = "configured"
|
||||||
const CONFIG_TOKEN = "token"
|
const CNFToken = "token"
|
||||||
const CONFIG_DOMAIN = "domain"
|
const CNFDomain = "domain"
|
||||||
const CONFIG_STORAGE = "storage"
|
const CNFStorage = "storage"
|
||||||
const CONFIG_ASSETPATH = "asset_path"
|
const CNFAssetPath = "asset_path"
|
||||||
const CONFIG_SCRIPTPATH = "script_path"
|
const CNFScriptPath = "script_path"
|
||||||
|
|
||||||
func getStrConfigValue(configID string, empty string) string {
|
func getStrConfigValue(configID string, empty string) string {
|
||||||
var config store.Config
|
var config store.Config
|
||||||
|
@ -13,7 +13,7 @@ func garbageCollect(act *store.Account) {
|
|||||||
defer garbageSync.Unlock()
|
defer garbageSync.Unlock()
|
||||||
|
|
||||||
// get all asset files
|
// get all asset files
|
||||||
dir := getStrConfigValue(CONFIG_ASSETPATH, APPDefaultPath) + "/" + act.GUID
|
dir := getStrConfigValue(CNFAssetPath, APPDefaultPath) + "/" + act.GUID
|
||||||
files, err := os.ReadDir(dir)
|
files, err := os.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrMsg(err)
|
ErrMsg(err)
|
||||||
|
@ -26,14 +26,14 @@ func GenerateRsaKeyPair() (*rsa.PrivateKey, *rsa.PublicKey, string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string {
|
func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string {
|
||||||
privkey_bytes := x509.MarshalPKCS1PrivateKey(privkey)
|
privkeyBytes := x509.MarshalPKCS1PrivateKey(privkey)
|
||||||
privkey_pem := pem.EncodeToMemory(
|
privkeyPEM := pem.EncodeToMemory(
|
||||||
&pem.Block{
|
&pem.Block{
|
||||||
Type: "RSA PRIVATE KEY",
|
Type: "RSA PRIVATE KEY",
|
||||||
Bytes: privkey_bytes,
|
Bytes: privkeyBytes,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return string(privkey_pem)
|
return string(privkeyPEM)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error) {
|
func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error) {
|
||||||
@ -51,18 +51,18 @@ func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExportRsaPublicKeyAsPemStr(pubkey *rsa.PublicKey) (string, error) {
|
func ExportRsaPublicKeyAsPemStr(pubkey *rsa.PublicKey) (string, error) {
|
||||||
pubkey_bytes, err := x509.MarshalPKIXPublicKey(pubkey)
|
pubkeyBytes, err := x509.MarshalPKIXPublicKey(pubkey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
pubkey_pem := pem.EncodeToMemory(
|
pubkeyPEM := pem.EncodeToMemory(
|
||||||
&pem.Block{
|
&pem.Block{
|
||||||
Type: "RSA PUBLIC KEY",
|
Type: "RSA PUBLIC KEY",
|
||||||
Bytes: pubkey_bytes,
|
Bytes: pubkeyBytes,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
return string(pubkey_pem), nil
|
return string(pubkeyPEM), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseRsaPublicKeyFromPemStr(pubPEM string) (*rsa.PublicKey, error) {
|
func ParseRsaPublicKeyFromPemStr(pubPEM string) (*rsa.PublicKey, error) {
|
||||||
|
@ -41,13 +41,13 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// config data path
|
// config data path
|
||||||
scripts := &store.Config{ ConfigID: CONFIG_SCRIPTPATH, StrValue: "./testscripts" }
|
scripts := &store.Config{ ConfigID: CNFScriptPath, StrValue: "./testscripts" }
|
||||||
if err := store.DB.Save(scripts).Error; err != nil {
|
if err := store.DB.Save(scripts).Error; err != nil {
|
||||||
panic("failed to configure scripts path")
|
panic("failed to configure scripts path")
|
||||||
}
|
}
|
||||||
|
|
||||||
// config data path
|
// config data path
|
||||||
path := &store.Config{ ConfigID: CONFIG_ASSETPATH, StrValue: "./testdata" }
|
path := &store.Config{ ConfigID: CNFAssetPath, StrValue: "./testdata" }
|
||||||
if err := store.DB.Save(path).Error; err != nil {
|
if err := store.DB.Save(path).Error; err != nil {
|
||||||
panic("failed to configure data path")
|
panic("failed to configure data path")
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ func getProfileModel(account *store.Account) *Profile {
|
|||||||
Image: account.AccountDetail.Image,
|
Image: account.AccountDetail.Image,
|
||||||
Revision: account.ProfileRevision,
|
Revision: account.ProfileRevision,
|
||||||
Version: APPVersion,
|
Version: APPVersion,
|
||||||
Node: getStrConfigValue(CONFIG_DOMAIN, ""),
|
Node: getStrConfigValue(CNFDomain, ""),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ type AppData struct {
|
|||||||
|
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
|
|
||||||
Url string `json:"url,omitempty"`
|
URL string `json:"url,omitempty"`
|
||||||
|
|
||||||
Image string `json:"image,omitempty"`
|
Image string `json:"image,omitempty"`
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ func SendNotifications() {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case notification := <-notify:
|
case notification := <-notify:
|
||||||
node := getStrConfigValue(CONFIG_DOMAIN, "")
|
node := getStrConfigValue(CNFDomain, "")
|
||||||
if notification.Node == node {
|
if notification.Node == node {
|
||||||
SendLocalNotification(notification)
|
SendLocalNotification(notification)
|
||||||
} else {
|
} else {
|
||||||
|
@ -91,7 +91,7 @@ type App struct {
|
|||||||
Name string
|
Name string
|
||||||
Description string
|
Description string
|
||||||
Image string
|
Image string
|
||||||
Url string
|
URL string
|
||||||
Token string `gorm:"not null;index:appguid,unique"`
|
Token string `gorm:"not null;index:appguid,unique"`
|
||||||
Created int64 `gorm:"autoCreateTime"`
|
Created int64 `gorm:"autoCreateTime"`
|
||||||
Account Account `gorm:"references:GUID"`
|
Account Account `gorm:"references:GUID"`
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
const TEST_TIMEOUT = 5
|
const testTimeout = 5
|
||||||
|
|
||||||
type TestCondition struct {
|
type TestCondition struct {
|
||||||
check func(*TestApp) bool
|
check func(*TestApp) bool
|
||||||
@ -810,7 +810,7 @@ func (a *TestApp) WaitFor(check func(*TestApp) bool) error {
|
|||||||
var wake = make(chan bool, 1)
|
var wake = make(chan bool, 1)
|
||||||
a.setCondition(&TestCondition{channel: done, check: check, })
|
a.setCondition(&TestCondition{channel: done, check: check, })
|
||||||
go func(){
|
go func(){
|
||||||
time.Sleep(TEST_TIMEOUT * time.Second)
|
time.Sleep(testTimeout * time.Second)
|
||||||
wake <- true
|
wake <- true
|
||||||
}()
|
}()
|
||||||
select {
|
select {
|
||||||
|
@ -612,7 +612,7 @@ func AddTestAccount(username string) (guid string, token string, err error) {
|
|||||||
app := AppData{
|
app := AppData{
|
||||||
Name: "Appy",
|
Name: "Appy",
|
||||||
Description: "A test app",
|
Description: "A test app",
|
||||||
Url: "http://app.coredb.org",
|
URL: "http://app.coredb.org",
|
||||||
};
|
};
|
||||||
var claim Claim
|
var claim Claim
|
||||||
var msg DataMessage
|
var msg DataMessage
|
||||||
|
@ -88,8 +88,8 @@ func transcodeDefault() {
|
|||||||
func transcodeAsset(asset *store.Asset) {
|
func transcodeAsset(asset *store.Asset) {
|
||||||
|
|
||||||
// prepare script path
|
// prepare script path
|
||||||
data := getStrConfigValue(CONFIG_ASSETPATH, APPDefaultPath)
|
data := getStrConfigValue(CNFAssetPath, APPDefaultPath)
|
||||||
script := getStrConfigValue(CONFIG_SCRIPTPATH, ".")
|
script := getStrConfigValue(CNFScriptPath, ".")
|
||||||
re := regexp.MustCompile("^[a-zA-Z0-9_]*$")
|
re := regexp.MustCompile("^[a-zA-Z0-9_]*$")
|
||||||
|
|
||||||
if !re.MatchString(asset.Transform) {
|
if !re.MatchString(asset.Transform) {
|
||||||
|
Loading…
Reference in New Issue
Block a user