sync: 0.6.1 from main (a713cf7b2dd1ff08528a121913ede8bd2cd3ffbd)
This commit is contained in:
1 parent
f40d1578c6
commit
e114b838f2
3 files changed
+217
-210
No files matched your search
@@ -20,14 +20,18 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Read version
|
||||||
|
id: version
|
||||||
|
run: echo "version=$(cat VERSION 2>/dev/null || echo '0.0.0')" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: evoapicloud/evolution-go
|
images: evoapicloud/evolution-go
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=branch
|
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
|
type=raw,value=${{ steps.version.outputs.version }}
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
@@ -46,12 +50,15 @@ jobs:
|
|||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
build-args: |
|
||||||
|
VERSION=${{ steps.version.outputs.version }}
|
||||||
|
|
||||||
- name: Image digest
|
- name: Image digest
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
Binary file not shown.
+209
-209
@@ -24,17 +24,17 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _k1 = []byte{0xc2, 0x6b, 0x5a, 0x73, 0x89, 0x09, 0x3a, 0x13, 0xc2, 0xd8, 0x93, 0x6d, 0x36, 0x85, 0x78, 0x1f, 0xc3, 0xca, 0xe9, 0x25, 0x77, 0x5e, 0x72, 0x06, 0xe4, 0x0b, 0x58, 0x29, 0x12, 0x0b, 0xa6, 0xf8, 0x4d, 0x00, 0x97, 0x01, 0xda, 0x84, 0x3e, 0x8b, 0x70, 0xd0}
|
var _k1 = []byte{0xf0, 0x55, 0xb5, 0x79, 0xf1, 0x44, 0xd3, 0xd2, 0xe8, 0xd3, 0xf9, 0xad, 0x09, 0x86, 0x40, 0xae, 0xaa, 0x44, 0x70, 0x31, 0x72, 0xf5, 0x9b, 0xd6, 0x89, 0xaa, 0xa9, 0xe5, 0xee, 0x58, 0x1b, 0x4f, 0x16, 0x66, 0xe9, 0xe9, 0xdb, 0xac, 0x9b, 0xe5, 0xf7, 0x54}
|
||||||
var _k0 = []byte{0xaa, 0x1f, 0x2e, 0x03, 0xfa, 0x33, 0x15, 0x3c, 0xae, 0xb1, 0xf0, 0x08, 0x58, 0xf6, 0x1d, 0x31, 0xa6, 0xbc, 0x86, 0x49, 0x02, 0x2a, 0x1b, 0x69, 0x8a, 0x6d, 0x37, 0x5c, 0x7c, 0x6f, 0xc7, 0x8c, 0x24, 0x6f, 0xf9, 0x2f, 0xb9, 0xeb, 0x53, 0xa5, 0x12, 0xa2}
|
var _k0 = []byte{0x98, 0x21, 0xc1, 0x09, 0x82, 0x7e, 0xfc, 0xfd, 0x84, 0xba, 0x9a, 0xc8, 0x67, 0xf5, 0x25, 0x80, 0xcf, 0x32, 0x1f, 0x5d, 0x07, 0x81, 0xf2, 0xb9, 0xe7, 0xcc, 0xc6, 0x90, 0x80, 0x3c, 0x7a, 0x3b, 0x7f, 0x09, 0x87, 0xc7, 0xb8, 0xc3, 0xf6, 0xcb, 0x95, 0x26}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_aprp string
|
_f1g string
|
||||||
_5h1m string
|
_08 string
|
||||||
)
|
)
|
||||||
|
|
||||||
func _qo() string {
|
func _040() string {
|
||||||
if _aprp != "" && _5h1m != "" {
|
if _f1g != "" && _08 != "" {
|
||||||
return _bl(_aprp, _5h1m)
|
return _yg(_f1g, _08)
|
||||||
}
|
}
|
||||||
parts := [...]string{"h", "tt", "ps", "://", "li", "ce", "nse", ".", "ev", "ol", "ut", "io", "nf", "ou", "nd", "at", "io", "n.", "co", "m.", "br"}
|
parts := [...]string{"h", "tt", "ps", "://", "li", "ce", "nse", ".", "ev", "ol", "ut", "io", "nf", "ou", "nd", "at", "io", "n.", "co", "m.", "br"}
|
||||||
var s string
|
var s string
|
||||||
@@ -44,9 +44,9 @@ func _qo() string {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func _bl(enc, key string) string {
|
func _yg(enc, key string) string {
|
||||||
encBytes := _bj(enc)
|
encBytes := _rw(enc)
|
||||||
keyBytes := _bj(key)
|
keyBytes := _rw(key)
|
||||||
if len(keyBytes) == 0 {
|
if len(keyBytes) == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@@ -57,18 +57,18 @@ func _bl(enc, key string) string {
|
|||||||
return string(out)
|
return string(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _bj(s string) []byte {
|
func _rw(s string) []byte {
|
||||||
if len(s)%2 != 0 {
|
if len(s)%2 != 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
b := make([]byte, len(s)/2)
|
b := make([]byte, len(s)/2)
|
||||||
for i := 0; i < len(s); i += 2 {
|
for i := 0; i < len(s); i += 2 {
|
||||||
b[i/2] = _rxcg(s[i])<<4 | _rxcg(s[i+1])
|
b[i/2] = _rp(s[i])<<4 | _rp(s[i+1])
|
||||||
}
|
}
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func _rxcg(c byte) byte {
|
func _rp(c byte) byte {
|
||||||
switch {
|
switch {
|
||||||
case c >= '0' && c <= '9':
|
case c >= '0' && c <= '9':
|
||||||
return c - '0'
|
return c - '0'
|
||||||
@@ -80,62 +80,62 @@ func _rxcg(c byte) byte {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var _dewb = &http.Client{Timeout: 10 * time.Second}
|
var _q7h = &http.Client{Timeout: 10 * time.Second}
|
||||||
|
|
||||||
func _41(body []byte, secret string) string {
|
func _gc(body []byte, secret string) string {
|
||||||
mac := hmac.New(sha256.New, []byte(secret))
|
mac := hmac.New(sha256.New, []byte(secret))
|
||||||
mac.Write(body)
|
mac.Write(body)
|
||||||
return hex.EncodeToString(mac.Sum(nil))
|
return hex.EncodeToString(mac.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func _1jm(path string, payload interface{}, _gi4p string) (*http.Response, error) {
|
func _6l(path string, payload interface{}, _6m string) (*http.Response, error) {
|
||||||
body, err := json.Marshal(payload)
|
body, err := json.Marshal(payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := _qo() + path
|
url := _040() + path
|
||||||
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body))
|
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
req.Header.Set("X-Api-Key", _gi4p)
|
req.Header.Set("X-Api-Key", _6m)
|
||||||
req.Header.Set("X-Signature", _41(body, _gi4p))
|
req.Header.Set("X-Signature", _gc(body, _6m))
|
||||||
|
|
||||||
return _dewb.Do(req)
|
return _q7h.Do(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _fcb(path string) (*http.Response, error) {
|
func _fq0(path string) (*http.Response, error) {
|
||||||
url := _qo() + path
|
url := _040() + path
|
||||||
return _dewb.Get(url)
|
return _q7h.Get(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _ef1m(path string, payload interface{}) (*http.Response, error) {
|
func _8cs0(path string, payload interface{}) (*http.Response, error) {
|
||||||
body, err := json.Marshal(payload)
|
body, err := json.Marshal(payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := _qo() + path
|
url := _040() + path
|
||||||
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body))
|
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
return _dewb.Do(req)
|
return _q7h.Do(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _ch(resp *http.Response) error {
|
func _ngm(resp *http.Response) error {
|
||||||
b, _ := io.ReadAll(resp.Body)
|
b, _ := io.ReadAll(resp.Body)
|
||||||
var _rsbr struct {
|
var _b8g struct {
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Error string `json:"error"`
|
Error string `json:"error"`
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(b, &_rsbr); err == nil {
|
if err := json.Unmarshal(b, &_b8g); err == nil {
|
||||||
msg := _rsbr.Message
|
msg := _b8g.Message
|
||||||
if msg == "" {
|
if msg == "" {
|
||||||
msg = _rsbr.Error
|
msg = _b8g.Error
|
||||||
}
|
}
|
||||||
if msg != "" {
|
if msg != "" {
|
||||||
return fmt.Errorf("%s (HTTP %d)", strings.ToLower(msg), resp.StatusCode)
|
return fmt.Errorf("%s (HTTP %d)", strings.ToLower(msg), resp.StatusCode)
|
||||||
@@ -163,48 +163,48 @@ const (
|
|||||||
ConfigKeyCustomerID = "customer_id"
|
ConfigKeyCustomerID = "customer_id"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _tz *gorm.DB
|
var _24 *gorm.DB
|
||||||
|
|
||||||
func SetDB(db *gorm.DB) {
|
func SetDB(db *gorm.DB) {
|
||||||
_tz = db
|
_24 = db
|
||||||
}
|
}
|
||||||
|
|
||||||
func MigrateDB() error {
|
func MigrateDB() error {
|
||||||
if _tz == nil {
|
if _24 == nil {
|
||||||
return fmt.Errorf("core: database not set, call SetDB first")
|
return fmt.Errorf("core: database not set, call SetDB first")
|
||||||
}
|
}
|
||||||
return _tz.AutoMigrate(&RuntimeConfig{})
|
return _24.AutoMigrate(&RuntimeConfig{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func _yy7a(key string) (string, error) {
|
func _wizb(key string) (string, error) {
|
||||||
if _tz == nil {
|
if _24 == nil {
|
||||||
return "", fmt.Errorf("core: database not set")
|
return "", fmt.Errorf("core: database not set")
|
||||||
}
|
}
|
||||||
var _s7 RuntimeConfig
|
var _68uq RuntimeConfig
|
||||||
_2p := _tz.Where("key = ?", key).First(&_s7)
|
_jsrz := _24.Where("key = ?", key).First(&_68uq)
|
||||||
if _2p.Error != nil {
|
if _jsrz.Error != nil {
|
||||||
return "", _2p.Error
|
return "", _jsrz.Error
|
||||||
}
|
}
|
||||||
return _s7.Value, nil
|
return _68uq.Value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _uy(key, value string) error {
|
func _kjt(key, value string) error {
|
||||||
if _tz == nil {
|
if _24 == nil {
|
||||||
return fmt.Errorf("core: database not set")
|
return fmt.Errorf("core: database not set")
|
||||||
}
|
}
|
||||||
var _s7 RuntimeConfig
|
var _68uq RuntimeConfig
|
||||||
_2p := _tz.Where("key = ?", key).First(&_s7)
|
_jsrz := _24.Where("key = ?", key).First(&_68uq)
|
||||||
if _2p.Error != nil {
|
if _jsrz.Error != nil {
|
||||||
return _tz.Create(&RuntimeConfig{Key: key, Value: value}).Error
|
return _24.Create(&RuntimeConfig{Key: key, Value: value}).Error
|
||||||
}
|
}
|
||||||
return _tz.Model(&_s7).Update("value", value).Error
|
return _24.Model(&_68uq).Update("value", value).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func _m8a0(key string) {
|
func _rf(key string) {
|
||||||
if _tz == nil {
|
if _24 == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_tz.Where("key = ?", key).Delete(&RuntimeConfig{})
|
_24.Where("key = ?", key).Delete(&RuntimeConfig{})
|
||||||
}
|
}
|
||||||
|
|
||||||
type RuntimeData struct {
|
type RuntimeData struct {
|
||||||
@@ -213,67 +213,67 @@ type RuntimeData struct {
|
|||||||
CustomerID int
|
CustomerID int
|
||||||
}
|
}
|
||||||
|
|
||||||
func _zy() (*RuntimeData, error) {
|
func _pjgm() (*RuntimeData, error) {
|
||||||
_gi4p, err := _yy7a(ConfigKeyAPIKey)
|
_6m, err := _wizb(ConfigKeyAPIKey)
|
||||||
if err != nil || _gi4p == "" {
|
if err != nil || _6m == "" {
|
||||||
return nil, fmt.Errorf("no license found")
|
return nil, fmt.Errorf("no license found")
|
||||||
}
|
}
|
||||||
|
|
||||||
_che, _ := _yy7a(ConfigKeyTier)
|
_c85, _ := _wizb(ConfigKeyTier)
|
||||||
customerIDStr, _ := _yy7a(ConfigKeyCustomerID)
|
customerIDStr, _ := _wizb(ConfigKeyCustomerID)
|
||||||
customerID, _ := strconv.Atoi(customerIDStr)
|
customerID, _ := strconv.Atoi(customerIDStr)
|
||||||
|
|
||||||
return &RuntimeData{
|
return &RuntimeData{
|
||||||
APIKey: _gi4p,
|
APIKey: _6m,
|
||||||
Tier: _che,
|
Tier: _c85,
|
||||||
CustomerID: customerID,
|
CustomerID: customerID,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _cyg(rd *RuntimeData) error {
|
func _fkrv(rd *RuntimeData) error {
|
||||||
if err := _uy(ConfigKeyAPIKey, rd.APIKey); err != nil {
|
if err := _kjt(ConfigKeyAPIKey, rd.APIKey); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := _uy(ConfigKeyTier, rd.Tier); err != nil {
|
if err := _kjt(ConfigKeyTier, rd.Tier); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if rd.CustomerID > 0 {
|
if rd.CustomerID > 0 {
|
||||||
if err := _uy(ConfigKeyCustomerID, strconv.Itoa(rd.CustomerID)); err != nil {
|
if err := _kjt(ConfigKeyCustomerID, strconv.Itoa(rd.CustomerID)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _kn0() {
|
func _h0s2() {
|
||||||
_m8a0(ConfigKeyAPIKey)
|
_rf(ConfigKeyAPIKey)
|
||||||
_m8a0(ConfigKeyTier)
|
_rf(ConfigKeyTier)
|
||||||
_m8a0(ConfigKeyCustomerID)
|
_rf(ConfigKeyCustomerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _xf7() (string, error) {
|
func _8u0() (string, error) {
|
||||||
id, err := _yy7a(ConfigKeyInstanceID)
|
id, err := _wizb(ConfigKeyInstanceID)
|
||||||
if err == nil && len(id) == 36 {
|
if err == nil && len(id) == 36 {
|
||||||
return id, nil
|
return id, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
id = _05()
|
id = _05n()
|
||||||
if id == "" {
|
if id == "" {
|
||||||
id, err = _97zd()
|
id, err = _s3()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := _uy(ConfigKeyInstanceID, id); err != nil {
|
if err := _kjt(ConfigKeyInstanceID, id); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return id, nil
|
return id, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _05() string {
|
func _05n() string {
|
||||||
hostname, _ := os.Hostname()
|
hostname, _ := os.Hostname()
|
||||||
macAddr := _q5j()
|
macAddr := _uq4()
|
||||||
if hostname == "" && macAddr == "" {
|
if hostname == "" && macAddr == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@@ -284,13 +284,13 @@ func _05() string {
|
|||||||
for i := 16; i < len(seed); i++ {
|
for i := 16; i < len(seed); i++ {
|
||||||
h[i%16] ^= seed[i]
|
h[i%16] ^= seed[i]
|
||||||
}
|
}
|
||||||
h[6] = (h[6] & 0x0f) | 0x40 // _wy 4
|
h[6] = (h[6] & 0x0f) | 0x40 // _jii2 4
|
||||||
h[8] = (h[8] & 0x3f) | 0x80 // variant
|
h[8] = (h[8] & 0x3f) | 0x80 // variant
|
||||||
return fmt.Sprintf("%08x-%04x-%04x-%04x-%012x",
|
return fmt.Sprintf("%08x-%04x-%04x-%04x-%012x",
|
||||||
h[0:4], h[4:6], h[6:8], h[8:10], h[10:16])
|
h[0:4], h[4:6], h[6:8], h[8:10], h[10:16])
|
||||||
}
|
}
|
||||||
|
|
||||||
func _q5j() string {
|
func _uq4() string {
|
||||||
interfaces, err := net.Interfaces()
|
interfaces, err := net.Interfaces()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
@@ -306,7 +306,7 @@ func _q5j() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func _97zd() (string, error) {
|
func _s3() (string, error) {
|
||||||
var b [16]byte
|
var b [16]byte
|
||||||
if _, err := rand.Read(b[:]); err != nil {
|
if _, err := rand.Read(b[:]); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -317,20 +317,20 @@ func _97zd() (string, error) {
|
|||||||
b[0:4], b[4:6], b[6:8], b[8:10], b[10:16]), nil
|
b[0:4], b[4:6], b[6:8], b[8:10], b[10:16]), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _qmdk atomic.Value // set during activation
|
var _tjmw atomic.Value // set during activation
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
_qmdk.Store([]byte{0})
|
_tjmw.Store([]byte{0})
|
||||||
}
|
}
|
||||||
|
|
||||||
func ComputeSessionSeed(instanceName string, rc *RuntimeContext) []byte {
|
func ComputeSessionSeed(instanceName string, rc *RuntimeContext) []byte {
|
||||||
if rc == nil || !rc._kjn.Load() {
|
if rc == nil || !rc._e8s.Load() {
|
||||||
return nil // Will cause panic in caller — intentional
|
return nil // Will cause panic in caller — intentional
|
||||||
}
|
}
|
||||||
h := sha256.New()
|
h := sha256.New()
|
||||||
h.Write([]byte(instanceName))
|
h.Write([]byte(instanceName))
|
||||||
h.Write([]byte(rc._gi4p))
|
h.Write([]byte(rc._6m))
|
||||||
salt, _ := _qmdk.Load().([]byte)
|
salt, _ := _tjmw.Load().([]byte)
|
||||||
h.Write(salt)
|
h.Write(salt)
|
||||||
return h.Sum(nil)[:16]
|
return h.Sum(nil)[:16]
|
||||||
}
|
}
|
||||||
@@ -343,20 +343,20 @@ func ValidateRouteAccess(rc *RuntimeContext) uint64 {
|
|||||||
return binary.LittleEndian.Uint64(h[:8])
|
return binary.LittleEndian.Uint64(h[:8])
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeriveInstanceToken(_mf41 string, rc *RuntimeContext) string {
|
func DeriveInstanceToken(_kj string, rc *RuntimeContext) string {
|
||||||
if rc == nil || !rc._kjn.Load() {
|
if rc == nil || !rc._e8s.Load() {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
h := sha256.Sum256([]byte(_mf41 + rc._gi4p))
|
h := sha256.Sum256([]byte(_kj + rc._6m))
|
||||||
return _zebs(h[:8])
|
return _0q(h[:8])
|
||||||
}
|
}
|
||||||
|
|
||||||
func _zebs(b []byte) string {
|
func _0q(b []byte) string {
|
||||||
const _eg = "0123456789abcdef"
|
const _zk = "0123456789abcdef"
|
||||||
dst := make([]byte, len(b)*2)
|
dst := make([]byte, len(b)*2)
|
||||||
for i, v := range b {
|
for i, v := range b {
|
||||||
dst[i*2] = _eg[v>>4]
|
dst[i*2] = _zk[v>>4]
|
||||||
dst[i*2+1] = _eg[v&0x0f]
|
dst[i*2+1] = _zk[v&0x0f]
|
||||||
}
|
}
|
||||||
return string(dst)
|
return string(dst)
|
||||||
}
|
}
|
||||||
@@ -365,8 +365,8 @@ func ActivateIntegrity(rc *RuntimeContext) {
|
|||||||
if rc == nil {
|
if rc == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
h := sha256.Sum256([]byte(rc._gi4p + rc._mf41 + "ev0"))
|
h := sha256.Sum256([]byte(rc._6m + rc._kj + "ev0"))
|
||||||
_qmdk.Store(h[:])
|
_tjmw.Store(h[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -374,101 +374,101 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type RuntimeContext struct {
|
type RuntimeContext struct {
|
||||||
_gi4p string
|
_6m string
|
||||||
_lg0 string // GLOBAL_API_KEY from .env — used as token for licensing check
|
_yunx string // GLOBAL_API_KEY from .env — used as token for licensing check
|
||||||
_mf41 string
|
_kj string
|
||||||
_kjn atomic.Bool
|
_e8s atomic.Bool
|
||||||
_wx [32]byte // Derived from activation — required by ValidateContext
|
_ix7 [32]byte // Derived from activation — required by ValidateContext
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
_83j string // Registration URL shown to users before activation
|
_am3d string // Registration URL shown to users before activation
|
||||||
_whv string // Registration token for polling
|
_8r9s string // Registration token for polling
|
||||||
_che string
|
_c85 string
|
||||||
_wy string
|
_jii2 string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RuntimeContext) ContextHash() [32]byte {
|
func (rc *RuntimeContext) ContextHash() [32]byte {
|
||||||
rc.mu.RLock()
|
rc.mu.RLock()
|
||||||
defer rc.mu.RUnlock()
|
defer rc.mu.RUnlock()
|
||||||
return rc._wx
|
return rc._ix7
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RuntimeContext) IsActive() bool {
|
func (rc *RuntimeContext) IsActive() bool {
|
||||||
return rc._kjn.Load()
|
return rc._e8s.Load()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RuntimeContext) RegistrationURL() string {
|
func (rc *RuntimeContext) RegistrationURL() string {
|
||||||
rc.mu.RLock()
|
rc.mu.RLock()
|
||||||
defer rc.mu.RUnlock()
|
defer rc.mu.RUnlock()
|
||||||
return rc._83j
|
return rc._am3d
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RuntimeContext) APIKey() string {
|
func (rc *RuntimeContext) APIKey() string {
|
||||||
rc.mu.RLock()
|
rc.mu.RLock()
|
||||||
defer rc.mu.RUnlock()
|
defer rc.mu.RUnlock()
|
||||||
return rc._gi4p
|
return rc._6m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RuntimeContext) InstanceID() string {
|
func (rc *RuntimeContext) InstanceID() string {
|
||||||
return rc._mf41
|
return rc._kj
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitializeRuntime(_che, _wy, _lg0 string) *RuntimeContext {
|
func InitializeRuntime(_c85, _jii2, _yunx string) *RuntimeContext {
|
||||||
if _che == "" {
|
if _c85 == "" {
|
||||||
_che = "evolution-go"
|
_c85 = "evolution-go"
|
||||||
}
|
}
|
||||||
if _wy == "" {
|
if _jii2 == "" {
|
||||||
_wy = "unknown"
|
_jii2 = "unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
rc := &RuntimeContext{
|
rc := &RuntimeContext{
|
||||||
_che: _che,
|
_c85: _c85,
|
||||||
_wy: _wy,
|
_jii2: _jii2,
|
||||||
_lg0: _lg0,
|
_yunx: _yunx,
|
||||||
}
|
}
|
||||||
|
|
||||||
id, err := _xf7()
|
id, err := _8u0()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("[runtime] failed to initialize instance: %v", err)
|
log.Fatalf("[runtime] failed to initialize instance: %v", err)
|
||||||
}
|
}
|
||||||
rc._mf41 = id
|
rc._kj = id
|
||||||
|
|
||||||
rd, err := _zy()
|
rd, err := _pjgm()
|
||||||
if err == nil && rd.APIKey != "" {
|
if err == nil && rd.APIKey != "" {
|
||||||
rc._gi4p = rd.APIKey
|
rc._6m = rd.APIKey
|
||||||
fmt.Printf(" ✓ License found: %s...%s\n", rd.APIKey[:8], rd.APIKey[len(rd.APIKey)-4:])
|
fmt.Printf(" ✓ License found: %s...%s\n", rd.APIKey[:8], rd.APIKey[len(rd.APIKey)-4:])
|
||||||
|
|
||||||
rc._wx = sha256.Sum256([]byte(rc._gi4p + rc._mf41))
|
rc._ix7 = sha256.Sum256([]byte(rc._6m + rc._kj))
|
||||||
rc._kjn.Store(true)
|
rc._e8s.Store(true)
|
||||||
ActivateIntegrity(rc)
|
ActivateIntegrity(rc)
|
||||||
fmt.Println(" ✓ License activated successfully")
|
fmt.Println(" ✓ License activated successfully")
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := _ty(rc, _wy); err != nil {
|
if err := _zim(rc, _jii2); err != nil {
|
||||||
fmt.Printf(" ⚠ Remote activation notice failed (non-blocking): %v\n", err)
|
fmt.Printf(" ⚠ Remote activation notice failed (non-blocking): %v\n", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
} else if rc._lg0 != "" {
|
} else if rc._yunx != "" {
|
||||||
rc._gi4p = rc._lg0
|
rc._6m = rc._yunx
|
||||||
if err := _ty(rc, _wy); err == nil {
|
if err := _zim(rc, _jii2); err == nil {
|
||||||
_cyg(&RuntimeData{APIKey: rc._lg0, Tier: _che})
|
_fkrv(&RuntimeData{APIKey: rc._yunx, Tier: _c85})
|
||||||
rc._wx = sha256.Sum256([]byte(rc._gi4p + rc._mf41))
|
rc._ix7 = sha256.Sum256([]byte(rc._6m + rc._kj))
|
||||||
rc._kjn.Store(true)
|
rc._e8s.Store(true)
|
||||||
ActivateIntegrity(rc)
|
ActivateIntegrity(rc)
|
||||||
fmt.Printf(" ✓ GLOBAL_API_KEY accepted — license saved and activated\n")
|
fmt.Printf(" ✓ GLOBAL_API_KEY accepted — license saved and activated\n")
|
||||||
} else {
|
} else {
|
||||||
rc._gi4p = ""
|
rc._6m = ""
|
||||||
_fa4()
|
_ps28()
|
||||||
rc._kjn.Store(false)
|
rc._e8s.Store(false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_fa4()
|
_ps28()
|
||||||
rc._kjn.Store(false)
|
rc._e8s.Store(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc
|
return rc
|
||||||
}
|
}
|
||||||
|
|
||||||
func _fa4() {
|
func _ps28() {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println(" ╔══════════════════════════════════════════════════════════╗")
|
fmt.Println(" ╔══════════════════════════════════════════════════════════╗")
|
||||||
fmt.Println(" ║ License Registration Required ║")
|
fmt.Println(" ║ License Registration Required ║")
|
||||||
@@ -480,41 +480,41 @@ func _fa4() {
|
|||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RuntimeContext) _6n(authCodeOrKey, _che string, customerID int) error {
|
func (rc *RuntimeContext) _7jz(authCodeOrKey, _c85 string, customerID int) error {
|
||||||
_gi4p, err := _16i(authCodeOrKey)
|
_6m, err := _ns89(authCodeOrKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("key exchange failed: %w", err)
|
return fmt.Errorf("key exchange failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rc.mu.Lock()
|
rc.mu.Lock()
|
||||||
rc._gi4p = _gi4p
|
rc._6m = _6m
|
||||||
rc._83j = ""
|
rc._am3d = ""
|
||||||
rc._whv = ""
|
rc._8r9s = ""
|
||||||
rc.mu.Unlock()
|
rc.mu.Unlock()
|
||||||
|
|
||||||
if err := _cyg(&RuntimeData{
|
if err := _fkrv(&RuntimeData{
|
||||||
APIKey: _gi4p,
|
APIKey: _6m,
|
||||||
Tier: _che,
|
Tier: _c85,
|
||||||
CustomerID: customerID,
|
CustomerID: customerID,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
fmt.Printf(" ⚠ Warning: could not save license: %v\n", err)
|
fmt.Printf(" ⚠ Warning: could not save license: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := _ty(rc, rc._wy); err != nil {
|
if err := _zim(rc, rc._jii2); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
rc.mu.Lock()
|
rc.mu.Lock()
|
||||||
rc._wx = sha256.Sum256([]byte(rc._gi4p + rc._mf41))
|
rc._ix7 = sha256.Sum256([]byte(rc._6m + rc._kj))
|
||||||
rc.mu.Unlock()
|
rc.mu.Unlock()
|
||||||
rc._kjn.Store(true)
|
rc._e8s.Store(true)
|
||||||
ActivateIntegrity(rc)
|
ActivateIntegrity(rc)
|
||||||
|
|
||||||
fmt.Printf(" ✓ License activated! Key: %s...%s (_che: %s)\n",
|
fmt.Printf(" ✓ License activated! Key: %s...%s (_c85: %s)\n",
|
||||||
_gi4p[:8], _gi4p[len(_gi4p)-4:], _che)
|
_6m[:8], _6m[len(_6m)-4:], _c85)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := _ylf(rc, 0); err != nil {
|
if err := _1g(rc, 0); err != nil {
|
||||||
fmt.Printf(" ⚠ First heartbeat failed: %v\n", err)
|
fmt.Printf(" ⚠ First heartbeat failed: %v\n", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@@ -526,10 +526,10 @@ func ValidateContext(rc *RuntimeContext) (bool, string) {
|
|||||||
if rc == nil {
|
if rc == nil {
|
||||||
return false, ""
|
return false, ""
|
||||||
}
|
}
|
||||||
if !rc._kjn.Load() {
|
if !rc._e8s.Load() {
|
||||||
return false, rc.RegistrationURL()
|
return false, rc.RegistrationURL()
|
||||||
}
|
}
|
||||||
expected := sha256.Sum256([]byte(rc._gi4p + rc._mf41))
|
expected := sha256.Sum256([]byte(rc._6m + rc._kj))
|
||||||
actual := rc.ContextHash()
|
actual := rc.ContextHash()
|
||||||
if expected != actual {
|
if expected != actual {
|
||||||
return false, ""
|
return false, ""
|
||||||
@@ -586,12 +586,12 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
|||||||
|
|
||||||
resp := gin.H{
|
resp := gin.H{
|
||||||
"status": status,
|
"status": status,
|
||||||
"instance_id": rc._mf41,
|
"instance_id": rc._kj,
|
||||||
}
|
}
|
||||||
|
|
||||||
rc.mu.RLock()
|
rc.mu.RLock()
|
||||||
if rc._gi4p != "" {
|
if rc._6m != "" {
|
||||||
resp["api_key"] = rc._gi4p[:8] + "..." + rc._gi4p[len(rc._gi4p)-4:]
|
resp["api_key"] = rc._6m[:8] + "..." + rc._6m[len(rc._6m)-4:]
|
||||||
}
|
}
|
||||||
rc.mu.RUnlock()
|
rc.mu.RUnlock()
|
||||||
|
|
||||||
@@ -608,7 +608,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc.mu.RLock()
|
rc.mu.RLock()
|
||||||
existingURL := rc._83j
|
existingURL := rc._am3d
|
||||||
rc.mu.RUnlock()
|
rc.mu.RUnlock()
|
||||||
|
|
||||||
if existingURL != "" {
|
if existingURL != "" {
|
||||||
@@ -620,15 +620,15 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
payload := map[string]string{
|
payload := map[string]string{
|
||||||
"tier": rc._che,
|
"tier": rc._c85,
|
||||||
"version": rc._wy,
|
"version": rc._jii2,
|
||||||
"instance_id": rc._mf41,
|
"instance_id": rc._kj,
|
||||||
}
|
}
|
||||||
if redirectURI := c.Query("redirect_uri"); redirectURI != "" {
|
if redirectURI := c.Query("redirect_uri"); redirectURI != "" {
|
||||||
payload["redirect_uri"] = redirectURI
|
payload["redirect_uri"] = redirectURI
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := _ef1m("/v1/register/init", payload)
|
resp, err := _8cs0("/v1/register/init", payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadGateway, gin.H{
|
c.JSON(http.StatusBadGateway, gin.H{
|
||||||
"error": "Failed to contact licensing server",
|
"error": "Failed to contact licensing server",
|
||||||
@@ -639,30 +639,30 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
_rsbr := _ch(resp)
|
_b8g := _ngm(resp)
|
||||||
c.JSON(resp.StatusCode, gin.H{
|
c.JSON(resp.StatusCode, gin.H{
|
||||||
"error": "Licensing server error",
|
"error": "Licensing server error",
|
||||||
"details": _rsbr.Error(),
|
"details": _b8g.Error(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var _eb struct {
|
var _i9i struct {
|
||||||
RegisterURL string `json:"register_url"`
|
RegisterURL string `json:"register_url"`
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
}
|
}
|
||||||
json.NewDecoder(resp.Body).Decode(&_eb)
|
json.NewDecoder(resp.Body).Decode(&_i9i)
|
||||||
|
|
||||||
rc.mu.Lock()
|
rc.mu.Lock()
|
||||||
rc._83j = _eb.RegisterURL
|
rc._am3d = _i9i.RegisterURL
|
||||||
rc._whv = _eb.Token
|
rc._8r9s = _i9i.Token
|
||||||
rc.mu.Unlock()
|
rc.mu.Unlock()
|
||||||
|
|
||||||
fmt.Printf(" → Registration URL: %s\n", _eb.RegisterURL)
|
fmt.Printf(" → Registration URL: %s\n", _i9i.RegisterURL)
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"status": "pending",
|
"status": "pending",
|
||||||
"register_url": _eb.RegisterURL,
|
"register_url": _i9i.RegisterURL,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -684,9 +684,9 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
exchangeResp, err := _ef1m("/v1/register/exchange", map[string]string{
|
exchangeResp, err := _8cs0("/v1/register/exchange", map[string]string{
|
||||||
"authorization_code": code,
|
"authorization_code": code,
|
||||||
"instance_id": rc._mf41,
|
"instance_id": rc._kj,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadGateway, gin.H{
|
c.JSON(http.StatusBadGateway, gin.H{
|
||||||
@@ -698,22 +698,22 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
|||||||
defer exchangeResp.Body.Close()
|
defer exchangeResp.Body.Close()
|
||||||
|
|
||||||
if exchangeResp.StatusCode != http.StatusOK {
|
if exchangeResp.StatusCode != http.StatusOK {
|
||||||
_rsbr := _ch(exchangeResp)
|
_b8g := _ngm(exchangeResp)
|
||||||
c.JSON(exchangeResp.StatusCode, gin.H{
|
c.JSON(exchangeResp.StatusCode, gin.H{
|
||||||
"error": "Exchange failed",
|
"error": "Exchange failed",
|
||||||
"details": _rsbr.Error(),
|
"details": _b8g.Error(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var _2p struct {
|
var _jsrz struct {
|
||||||
APIKey string `json:"api_key"`
|
APIKey string `json:"api_key"`
|
||||||
Tier string `json:"tier"`
|
Tier string `json:"tier"`
|
||||||
CustomerID int `json:"customer_id"`
|
CustomerID int `json:"customer_id"`
|
||||||
}
|
}
|
||||||
json.NewDecoder(exchangeResp.Body).Decode(&_2p)
|
json.NewDecoder(exchangeResp.Body).Decode(&_jsrz)
|
||||||
|
|
||||||
if _2p.APIKey == "" {
|
if _jsrz.APIKey == "" {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, gin.H{
|
||||||
"error": "Invalid or expired code",
|
"error": "Invalid or expired code",
|
||||||
"message": "The authorization code is invalid or has expired.",
|
"message": "The authorization code is invalid or has expired.",
|
||||||
@@ -721,7 +721,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := rc._6n(_2p.APIKey, _2p.Tier, _2p.CustomerID); err != nil {
|
if err := rc._7jz(_jsrz.APIKey, _jsrz.Tier, _jsrz.CustomerID); err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
c.JSON(http.StatusInternalServerError, gin.H{
|
||||||
"error": "Activation failed",
|
"error": "Activation failed",
|
||||||
"details": err.Error(),
|
"details": err.Error(),
|
||||||
@@ -751,7 +751,7 @@ func StartHeartbeat(ctx context.Context, rc *RuntimeContext, startTime time.Time
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
uptime := int64(time.Since(startTime).Seconds())
|
uptime := int64(time.Since(startTime).Seconds())
|
||||||
if err := _ylf(rc, uptime); err != nil {
|
if err := _1g(rc, uptime); err != nil {
|
||||||
fmt.Printf(" ⚠ Heartbeat failed (non-blocking): %v\n", err)
|
fmt.Printf(" ⚠ Heartbeat failed (non-blocking): %v\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -760,14 +760,14 @@ func StartHeartbeat(ctx context.Context, rc *RuntimeContext, startTime time.Time
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Shutdown(rc *RuntimeContext) {
|
func Shutdown(rc *RuntimeContext) {
|
||||||
if rc == nil || rc._gi4p == "" {
|
if rc == nil || rc._6m == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_7m53(rc)
|
_zwu2(rc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _njn(code string) (_gi4p string, err error) {
|
func _4j(code string) (_6m string, err error) {
|
||||||
resp, err := _ef1m("/v1/register/exchange", map[string]string{
|
resp, err := _8cs0("/v1/register/exchange", map[string]string{
|
||||||
"authorization_code": code,
|
"authorization_code": code,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -776,84 +776,84 @@ func _njn(code string) (_gi4p string, err error) {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return "", _ch(resp)
|
return "", _ngm(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _2p struct {
|
var _jsrz struct {
|
||||||
APIKey string `json:"api_key"`
|
APIKey string `json:"api_key"`
|
||||||
}
|
}
|
||||||
json.NewDecoder(resp.Body).Decode(&_2p)
|
json.NewDecoder(resp.Body).Decode(&_jsrz)
|
||||||
if _2p.APIKey == "" {
|
if _jsrz.APIKey == "" {
|
||||||
return "", fmt.Errorf("exchange returned empty api_key")
|
return "", fmt.Errorf("exchange returned empty api_key")
|
||||||
}
|
}
|
||||||
return _2p.APIKey, nil
|
return _jsrz.APIKey, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _16i(authCodeOrKey string) (string, error) {
|
func _ns89(authCodeOrKey string) (string, error) {
|
||||||
_gi4p, err := _njn(authCodeOrKey)
|
_6m, err := _4j(authCodeOrKey)
|
||||||
if err == nil && _gi4p != "" {
|
if err == nil && _6m != "" {
|
||||||
return _gi4p, nil
|
return _6m, nil
|
||||||
}
|
}
|
||||||
return authCodeOrKey, nil
|
return authCodeOrKey, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _ty(rc *RuntimeContext, _wy string) error {
|
func _zim(rc *RuntimeContext, _jii2 string) error {
|
||||||
resp, err := _1jm("/v1/activate", map[string]string{
|
resp, err := _6l("/v1/activate", map[string]string{
|
||||||
"instance_id": rc._mf41,
|
"instance_id": rc._kj,
|
||||||
"version": _wy,
|
"version": _jii2,
|
||||||
}, rc._gi4p)
|
}, rc._6m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return _ch(resp)
|
return _ngm(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _2p struct {
|
var _jsrz struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
}
|
}
|
||||||
json.NewDecoder(resp.Body).Decode(&_2p)
|
json.NewDecoder(resp.Body).Decode(&_jsrz)
|
||||||
|
|
||||||
if _2p.Status != "active" {
|
if _jsrz.Status != "active" {
|
||||||
return fmt.Errorf("activation returned status: %s", _2p.Status)
|
return fmt.Errorf("activation returned status: %s", _jsrz.Status)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _ylf(rc *RuntimeContext, uptimeSeconds int64) error {
|
func _1g(rc *RuntimeContext, uptimeSeconds int64) error {
|
||||||
resp, err := _1jm("/v1/heartbeat", map[string]any{
|
resp, err := _6l("/v1/heartbeat", map[string]any{
|
||||||
"instance_id": rc._mf41,
|
"instance_id": rc._kj,
|
||||||
"uptime_seconds": uptimeSeconds,
|
"uptime_seconds": uptimeSeconds,
|
||||||
"version": rc._wy,
|
"version": rc._jii2,
|
||||||
}, rc._gi4p)
|
}, rc._6m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return _ch(resp)
|
return _ngm(resp)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _7m53(rc *RuntimeContext) {
|
func _zwu2(rc *RuntimeContext) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
body, _ := json.Marshal(map[string]string{
|
body, _ := json.Marshal(map[string]string{
|
||||||
"instance_id": rc._mf41,
|
"instance_id": rc._kj,
|
||||||
})
|
})
|
||||||
|
|
||||||
url := _qo() + "/v1/deactivate"
|
url := _040() + "/v1/deactivate"
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(body))
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
req.Header.Set("X-Api-Key", rc._gi4p)
|
req.Header.Set("X-Api-Key", rc._6m)
|
||||||
req.Header.Set("X-Signature", _41(body, rc._gi4p))
|
req.Header.Set("X-Signature", _gc(body, rc._6m))
|
||||||
_dewb.Do(req)
|
_q7h.Do(req)
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user