sync: 0.7.1 from main (ca1956a7559d4e178ed2d61edcfa4cb241804e45)

This commit is contained in:
github-actions[bot] committed 2026-05-06 17:40:31 +00:00
1 parent 2f075f44ba
commit b5a4074523
2 files changed
+230 -230

No files matched your search

BIN
View File
Binary file not shown.
+230 -230
View File
@@ -24,17 +24,17 @@ import (
"time" "time"
) )
var _k1 = []byte{0x59, 0xba, 0xa1, 0x12, 0xc1, 0xc8, 0x80, 0xec, 0x1e, 0xf5, 0xd7, 0x4f, 0xa5, 0xfe, 0x9b, 0xf9, 0x6d, 0x5e, 0x14, 0x69, 0x99, 0x89, 0xa6, 0xe4, 0xef, 0xc5, 0xdc, 0x60, 0xf5, 0x84, 0xcd, 0x06, 0x5b, 0x8a, 0x0d, 0x94, 0xa3, 0x94, 0xb7, 0x34, 0x2c, 0x25} var _k1 = []byte{0x80, 0x41, 0x91, 0x24, 0x6c, 0xf3, 0x66, 0x67, 0x41, 0x5e, 0xde, 0xd2, 0x7d, 0xd9, 0x10, 0x99, 0x3a, 0x99, 0x6f, 0xb9, 0xc6, 0x1d, 0xce, 0xe4, 0x1a, 0x10, 0x5a, 0x5d, 0x16, 0xe7, 0xc8, 0xd2, 0xd0, 0x1f, 0xc8, 0xbb, 0x61, 0x82, 0x7a, 0x4a, 0x28, 0x3a}
var _k0 = []byte{0x31, 0xce, 0xd5, 0x62, 0xb2, 0xf2, 0xaf, 0xc3, 0x72, 0x9c, 0xb4, 0x2a, 0xcb, 0x8d, 0xfe, 0xd7, 0x08, 0x28, 0x7b, 0x05, 0xec, 0xfd, 0xcf, 0x8b, 0x81, 0xa3, 0xb3, 0x15, 0x9b, 0xe0, 0xac, 0x72, 0x32, 0xe5, 0x63, 0xba, 0xc0, 0xfb, 0xda, 0x1a, 0x4e, 0x57} var _k0 = []byte{0xe8, 0x35, 0xe5, 0x54, 0x1f, 0xc9, 0x49, 0x48, 0x2d, 0x37, 0xbd, 0xb7, 0x13, 0xaa, 0x75, 0xb7, 0x5f, 0xef, 0x00, 0xd5, 0xb3, 0x69, 0xa7, 0x8b, 0x74, 0x76, 0x35, 0x28, 0x78, 0x83, 0xa9, 0xa6, 0xb9, 0x70, 0xa6, 0x95, 0x02, 0xed, 0x17, 0x64, 0x4a, 0x48}
var ( var (
_blq string _eo2m string
_ik string _wa string
) )
func _it2l() string { func _hcg() string {
if _blq != "" && _ik != "" { if _eo2m != "" && _wa != "" {
return _zh(_blq, _ik) return _kw3v(_eo2m, _wa)
} }
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 _it2l() string {
return s return s
} }
func _zh(enc, key string) string { func _kw3v(enc, key string) string {
encBytes := _afc(enc) encBytes := _uzum(enc)
keyBytes := _afc(key) keyBytes := _uzum(key)
if len(keyBytes) == 0 { if len(keyBytes) == 0 {
return "" return ""
} }
@@ -57,18 +57,18 @@ func _zh(enc, key string) string {
return string(out) return string(out)
} }
func _afc(s string) []byte { func _uzum(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] = _pl(s[i])<<4 | _pl(s[i+1]) b[i/2] = _3qky(s[i])<<4 | _3qky(s[i+1])
} }
return b return b
} }
func _pl(c byte) byte { func _3qky(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 _pl(c byte) byte {
return 0 return 0
} }
var _j7g = &http.Client{Timeout: 10 * time.Second} var _09 = &http.Client{Timeout: 10 * time.Second}
func _trei(body []byte, secret string) string { func _ry8(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 _iv(path string, payload interface{}, _5i string) (*http.Response, error) { func _6yl(path string, payload interface{}, _h7dl 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 := _it2l() + path url := _hcg() + 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", _5i) req.Header.Set("X-Api-Key", _h7dl)
req.Header.Set("X-Signature", _trei(body, _5i)) req.Header.Set("X-Signature", _ry8(body, _h7dl))
return _j7g.Do(req) return _09.Do(req)
} }
func _92(path string) (*http.Response, error) { func _qxv(path string) (*http.Response, error) {
url := _it2l() + path url := _hcg() + path
return _j7g.Get(url) return _09.Get(url)
} }
func _5lk(path string, payload interface{}) (*http.Response, error) { func _hvc(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 := _it2l() + path url := _hcg() + 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 _j7g.Do(req) return _09.Do(req)
} }
func _r6(resp *http.Response) error { func _zy(resp *http.Response) error {
b, _ := io.ReadAll(resp.Body) b, _ := io.ReadAll(resp.Body)
var _zi0 struct { var _5qha struct {
Message string `json:"message"` Message string `json:"message"`
Error string `json:"error"` Error string `json:"error"`
} }
if err := json.Unmarshal(b, &_zi0); err == nil { if err := json.Unmarshal(b, &_5qha); err == nil {
msg := _zi0.Message msg := _5qha.Message
if msg == "" { if msg == "" {
msg = _zi0.Error msg = _5qha.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 _lme2 *gorm.DB var _cl *gorm.DB
func SetDB(db *gorm.DB) { func SetDB(db *gorm.DB) {
_lme2 = db _cl = db
} }
func MigrateDB() error { func MigrateDB() error {
if _lme2 == nil { if _cl == nil {
return fmt.Errorf("core: database not set, call SetDB first") return fmt.Errorf("core: database not set, call SetDB first")
} }
return _lme2.AutoMigrate(&RuntimeConfig{}) return _cl.AutoMigrate(&RuntimeConfig{})
} }
func _51(key string) (string, error) { func _eui(key string) (string, error) {
if _lme2 == nil { if _cl == nil {
return "", fmt.Errorf("core: database not set") return "", fmt.Errorf("core: database not set")
} }
var _ax RuntimeConfig var _0h RuntimeConfig
_9cn := _lme2.Where("key = ?", key).First(&_ax) _o95o := _cl.Where("key = ?", key).First(&_0h)
if _9cn.Error != nil { if _o95o.Error != nil {
return "", _9cn.Error return "", _o95o.Error
} }
return _ax.Value, nil return _0h.Value, nil
} }
func _wa(key, value string) error { func _2vm0(key, value string) error {
if _lme2 == nil { if _cl == nil {
return fmt.Errorf("core: database not set") return fmt.Errorf("core: database not set")
} }
var _ax RuntimeConfig var _0h RuntimeConfig
_9cn := _lme2.Where("key = ?", key).First(&_ax) _o95o := _cl.Where("key = ?", key).First(&_0h)
if _9cn.Error != nil { if _o95o.Error != nil {
return _lme2.Create(&RuntimeConfig{Key: key, Value: value}).Error return _cl.Create(&RuntimeConfig{Key: key, Value: value}).Error
} }
return _lme2.Model(&_ax).Update("value", value).Error return _cl.Model(&_0h).Update("value", value).Error
} }
func _jdak(key string) { func _gzgx(key string) {
if _lme2 == nil { if _cl == nil {
return return
} }
_lme2.Where("key = ?", key).Delete(&RuntimeConfig{}) _cl.Where("key = ?", key).Delete(&RuntimeConfig{})
} }
type RuntimeData struct { type RuntimeData struct {
@@ -213,67 +213,67 @@ type RuntimeData struct {
CustomerID int CustomerID int
} }
func _he() (*RuntimeData, error) { func _d8() (*RuntimeData, error) {
_5i, err := _51(ConfigKeyAPIKey) _h7dl, err := _eui(ConfigKeyAPIKey)
if err != nil || _5i == "" { if err != nil || _h7dl == "" {
return nil, fmt.Errorf("no license found") return nil, fmt.Errorf("no license found")
} }
_silj, _ := _51(ConfigKeyTier) _9dg, _ := _eui(ConfigKeyTier)
customerIDStr, _ := _51(ConfigKeyCustomerID) customerIDStr, _ := _eui(ConfigKeyCustomerID)
customerID, _ := strconv.Atoi(customerIDStr) customerID, _ := strconv.Atoi(customerIDStr)
return &RuntimeData{ return &RuntimeData{
APIKey: _5i, APIKey: _h7dl,
Tier: _silj, Tier: _9dg,
CustomerID: customerID, CustomerID: customerID,
}, nil }, nil
} }
func _f1s(rd *RuntimeData) error { func _kgx(rd *RuntimeData) error {
if err := _wa(ConfigKeyAPIKey, rd.APIKey); err != nil { if err := _2vm0(ConfigKeyAPIKey, rd.APIKey); err != nil {
return err return err
} }
if err := _wa(ConfigKeyTier, rd.Tier); err != nil { if err := _2vm0(ConfigKeyTier, rd.Tier); err != nil {
return err return err
} }
if rd.CustomerID > 0 { if rd.CustomerID > 0 {
if err := _wa(ConfigKeyCustomerID, strconv.Itoa(rd.CustomerID)); err != nil { if err := _2vm0(ConfigKeyCustomerID, strconv.Itoa(rd.CustomerID)); err != nil {
return err return err
} }
} }
return nil return nil
} }
func _xqiz() { func _nwy5() {
_jdak(ConfigKeyAPIKey) _gzgx(ConfigKeyAPIKey)
_jdak(ConfigKeyTier) _gzgx(ConfigKeyTier)
_jdak(ConfigKeyCustomerID) _gzgx(ConfigKeyCustomerID)
} }
func _0y1() (string, error) { func _o7() (string, error) {
id, err := _51(ConfigKeyInstanceID) id, err := _eui(ConfigKeyInstanceID)
if err == nil && len(id) == 36 { if err == nil && len(id) == 36 {
return id, nil return id, nil
} }
id = _5iz() id = _fpjt()
if id == "" { if id == "" {
id, err = _i86i() id, err = _bgrz()
if err != nil { if err != nil {
return "", err return "", err
} }
} }
if err := _wa(ConfigKeyInstanceID, id); err != nil { if err := _2vm0(ConfigKeyInstanceID, id); err != nil {
return "", err return "", err
} }
return id, nil return id, nil
} }
func _5iz() string { func _fpjt() string {
hostname, _ := os.Hostname() hostname, _ := os.Hostname()
macAddr := _e0v() macAddr := _czg()
if hostname == "" && macAddr == "" { if hostname == "" && macAddr == "" {
return "" return ""
} }
@@ -284,13 +284,13 @@ func _5iz() 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 // _41t 4 h[6] = (h[6] & 0x0f) | 0x40 // _ia 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 _e0v() string { func _czg() string {
interfaces, err := net.Interfaces() interfaces, err := net.Interfaces()
if err != nil { if err != nil {
return "" return ""
@@ -306,7 +306,7 @@ func _e0v() string {
return "" return ""
} }
func _i86i() (string, error) { func _bgrz() (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 _i86i() (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 _qf atomic.Value // set during activation var _fyaa atomic.Value // set during activation
func init() { func init() {
_qf.Store([]byte{0}) _fyaa.Store([]byte{0})
} }
func ComputeSessionSeed(instanceName string, rc *RuntimeContext) []byte { func ComputeSessionSeed(instanceName string, rc *RuntimeContext) []byte {
if rc == nil || !rc._wq.Load() { if rc == nil || !rc._j9.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._5i)) h.Write([]byte(rc._h7dl))
salt, _ := _qf.Load().([]byte) salt, _ := _fyaa.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(_78z string, rc *RuntimeContext) string { func DeriveInstanceToken(_yt string, rc *RuntimeContext) string {
if rc == nil || !rc._wq.Load() { if rc == nil || !rc._j9.Load() {
return "" return ""
} }
h := sha256.Sum256([]byte(_78z + rc._5i)) h := sha256.Sum256([]byte(_yt + rc._h7dl))
return _leb7(h[:8]) return _kvr(h[:8])
} }
func _leb7(b []byte) string { func _kvr(b []byte) string {
const _i2n = "0123456789abcdef" const _bl = "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] = _i2n[v>>4] dst[i*2] = _bl[v>>4]
dst[i*2+1] = _i2n[v&0x0f] dst[i*2+1] = _bl[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._5i + rc._78z + "ev0")) h := sha256.Sum256([]byte(rc._h7dl + rc._yt + "ev0"))
_qf.Store(h[:]) _fyaa.Store(h[:])
} }
const ( const (
@@ -374,129 +374,129 @@ const (
) )
type RuntimeContext struct { type RuntimeContext struct {
_5i string _h7dl string
_k8 string // GLOBAL_API_KEY from .env — used as token for licensing check _p1wx string // GLOBAL_API_KEY from .env — used as token for licensing check
_78z string _yt string
_wq atomic.Bool _j9 atomic.Bool
_77 [32]byte // Derived from activation — required by ValidateContext _e2 [32]byte // Derived from activation — required by ValidateContext
mu sync.RWMutex mu sync.RWMutex
_zkb6 string // Registration URL shown to users before activation _uz string // Registration URL shown to users before activation
_pr string // Registration token for polling _7c string // Registration token for polling
_silj string _9dg string
_41t string _ia string
_xao atomic.Int64 // Messages sent since last heartbeat _ihu atomic.Int64 // Messages sent since last heartbeat
_th5 atomic.Int64 // Messages received since last heartbeat _56 atomic.Int64 // Messages received since last heartbeat
} }
var _4sns atomic.Pointer[RuntimeContext] var _693 atomic.Pointer[RuntimeContext]
func (rc *RuntimeContext) TrackMessage() { func (rc *RuntimeContext) TrackMessage() {
if rc != nil { if rc != nil {
rc._xao.Add(1) rc._ihu.Add(1)
} }
} }
func TrackMessageSent() { func TrackMessageSent() {
if rc := _4sns.Load(); rc != nil { if rc := _693.Load(); rc != nil {
rc._xao.Add(1) rc._ihu.Add(1)
} }
} }
func TrackMessageRecv() { func TrackMessageRecv() {
if rc := _4sns.Load(); rc != nil { if rc := _693.Load(); rc != nil {
rc._th5.Add(1) rc._56.Add(1)
} }
} }
func (rc *RuntimeContext) _b07h() int64 { func (rc *RuntimeContext) _71() int64 {
return rc._xao.Swap(0) return rc._ihu.Swap(0)
} }
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._77 return rc._e2
} }
func (rc *RuntimeContext) IsActive() bool { func (rc *RuntimeContext) IsActive() bool {
return rc._wq.Load() return rc._j9.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._zkb6 return rc._uz
} }
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._5i return rc._h7dl
} }
func (rc *RuntimeContext) InstanceID() string { func (rc *RuntimeContext) InstanceID() string {
return rc._78z return rc._yt
} }
func InitializeRuntime(_silj, _41t, _k8 string) *RuntimeContext { func InitializeRuntime(_9dg, _ia, _p1wx string) *RuntimeContext {
if _silj == "" { if _9dg == "" {
_silj = "evolution-go" _9dg = "evolution-go"
} }
if _41t == "" { if _ia == "" {
_41t = "unknown" _ia = "unknown"
} }
rc := &RuntimeContext{ rc := &RuntimeContext{
_silj: _silj, _9dg: _9dg,
_41t: _41t, _ia: _ia,
_k8: _k8, _p1wx: _p1wx,
} }
id, err := _0y1() id, err := _o7()
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._78z = id rc._yt = id
rd, err := _he() rd, err := _d8()
if err == nil && rd.APIKey != "" { if err == nil && rd.APIKey != "" {
rc._5i = rd.APIKey rc._h7dl = 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._77 = sha256.Sum256([]byte(rc._5i + rc._78z)) rc._e2 = sha256.Sum256([]byte(rc._h7dl + rc._yt))
rc._wq.Store(true) rc._j9.Store(true)
ActivateIntegrity(rc) ActivateIntegrity(rc)
fmt.Println(" ✓ License activated successfully") fmt.Println(" ✓ License activated successfully")
go func() { go func() {
if err := _yxbc(rc, _41t); err != nil { if err := _jw(rc, _ia); 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._k8 != "" { } else if rc._p1wx != "" {
rc._5i = rc._k8 rc._h7dl = rc._p1wx
if err := _yxbc(rc, _41t); err == nil { if err := _jw(rc, _ia); err == nil {
_f1s(&RuntimeData{APIKey: rc._k8, Tier: _silj}) _kgx(&RuntimeData{APIKey: rc._p1wx, Tier: _9dg})
rc._77 = sha256.Sum256([]byte(rc._5i + rc._78z)) rc._e2 = sha256.Sum256([]byte(rc._h7dl + rc._yt))
rc._wq.Store(true) rc._j9.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._5i = "" rc._h7dl = ""
_oac2() _3tss()
rc._wq.Store(false) rc._j9.Store(false)
} }
} else { } else {
_oac2() _3tss()
rc._wq.Store(false) rc._j9.Store(false)
} }
_4sns.Store(rc) _693.Store(rc)
return rc return rc
} }
func _oac2() { func _3tss() {
fmt.Println() fmt.Println()
fmt.Println(" ╔══════════════════════════════════════════════════════════╗") fmt.Println(" ╔══════════════════════════════════════════════════════════╗")
fmt.Println(" ║ License Registration Required ║") fmt.Println(" ║ License Registration Required ║")
@@ -508,41 +508,41 @@ func _oac2() {
fmt.Println() fmt.Println()
} }
func (rc *RuntimeContext) _3yll(authCodeOrKey, _silj string, customerID int) error { func (rc *RuntimeContext) _301e(authCodeOrKey, _9dg string, customerID int) error {
_5i, err := _sa72(authCodeOrKey) _h7dl, err := _u9(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._5i = _5i rc._h7dl = _h7dl
rc._zkb6 = "" rc._uz = ""
rc._pr = "" rc._7c = ""
rc.mu.Unlock() rc.mu.Unlock()
if err := _f1s(&RuntimeData{ if err := _kgx(&RuntimeData{
APIKey: _5i, APIKey: _h7dl,
Tier: _silj, Tier: _9dg,
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 := _yxbc(rc, rc._41t); err != nil { if err := _jw(rc, rc._ia); err != nil {
return err return err
} }
rc.mu.Lock() rc.mu.Lock()
rc._77 = sha256.Sum256([]byte(rc._5i + rc._78z)) rc._e2 = sha256.Sum256([]byte(rc._h7dl + rc._yt))
rc.mu.Unlock() rc.mu.Unlock()
rc._wq.Store(true) rc._j9.Store(true)
ActivateIntegrity(rc) ActivateIntegrity(rc)
fmt.Printf(" ✓ License activated! Key: %s...%s (_silj: %s)\n", fmt.Printf(" ✓ License activated! Key: %s...%s (_9dg: %s)\n",
_5i[:8], _5i[len(_5i)-4:], _silj) _h7dl[:8], _h7dl[len(_h7dl)-4:], _9dg)
go func() { go func() {
if err := _jc3d(rc, 0); err != nil { if err := _ln(rc, 0); err != nil {
fmt.Printf(" ⚠ First heartbeat failed: %v\n", err) fmt.Printf(" ⚠ First heartbeat failed: %v\n", err)
} }
}() }()
@@ -554,10 +554,10 @@ func ValidateContext(rc *RuntimeContext) (bool, string) {
if rc == nil { if rc == nil {
return false, "" return false, ""
} }
if !rc._wq.Load() { if !rc._j9.Load() {
return false, rc.RegistrationURL() return false, rc.RegistrationURL()
} }
expected := sha256.Sum256([]byte(rc._5i + rc._78z)) expected := sha256.Sum256([]byte(rc._h7dl + rc._yt))
actual := rc.ContextHash() actual := rc.ContextHash()
if expected != actual { if expected != actual {
return false, "" return false, ""
@@ -614,12 +614,12 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
resp := gin.H{ resp := gin.H{
"status": status, "status": status,
"instance_id": rc._78z, "instance_id": rc._yt,
} }
rc.mu.RLock() rc.mu.RLock()
if rc._5i != "" { if rc._h7dl != "" {
resp["api_key"] = rc._5i[:8] + "..." + rc._5i[len(rc._5i)-4:] resp["api_key"] = rc._h7dl[:8] + "..." + rc._h7dl[len(rc._h7dl)-4:]
} }
rc.mu.RUnlock() rc.mu.RUnlock()
@@ -636,7 +636,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
} }
rc.mu.RLock() rc.mu.RLock()
existingURL := rc._zkb6 existingURL := rc._uz
rc.mu.RUnlock() rc.mu.RUnlock()
if existingURL != "" { if existingURL != "" {
@@ -648,15 +648,15 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
} }
payload := map[string]string{ payload := map[string]string{
"tier": rc._silj, "tier": rc._9dg,
"version": rc._41t, "version": rc._ia,
"instance_id": rc._78z, "instance_id": rc._yt,
} }
if redirectURI := c.Query("redirect_uri"); redirectURI != "" { if redirectURI := c.Query("redirect_uri"); redirectURI != "" {
payload["redirect_uri"] = redirectURI payload["redirect_uri"] = redirectURI
} }
resp, err := _5lk("/v1/register/init", payload) resp, err := _hvc("/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",
@@ -667,30 +667,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 {
_zi0 := _r6(resp) _5qha := _zy(resp)
c.JSON(resp.StatusCode, gin.H{ c.JSON(resp.StatusCode, gin.H{
"error": "Licensing server error", "error": "Licensing server error",
"details": _zi0.Error(), "details": _5qha.Error(),
}) })
return return
} }
var _czi3 struct { var _uh struct {
RegisterURL string `json:"register_url"` RegisterURL string `json:"register_url"`
Token string `json:"token"` Token string `json:"token"`
} }
json.NewDecoder(resp.Body).Decode(&_czi3) json.NewDecoder(resp.Body).Decode(&_uh)
rc.mu.Lock() rc.mu.Lock()
rc._zkb6 = _czi3.RegisterURL rc._uz = _uh.RegisterURL
rc._pr = _czi3.Token rc._7c = _uh.Token
rc.mu.Unlock() rc.mu.Unlock()
fmt.Printf(" → Registration URL: %s\n", _czi3.RegisterURL) fmt.Printf(" → Registration URL: %s\n", _uh.RegisterURL)
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"status": "pending", "status": "pending",
"register_url": _czi3.RegisterURL, "register_url": _uh.RegisterURL,
}) })
}) })
@@ -712,9 +712,9 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
return return
} }
exchangeResp, err := _5lk("/v1/register/exchange", map[string]string{ exchangeResp, err := _hvc("/v1/register/exchange", map[string]string{
"authorization_code": code, "authorization_code": code,
"instance_id": rc._78z, "instance_id": rc._yt,
}) })
if err != nil { if err != nil {
c.JSON(http.StatusBadGateway, gin.H{ c.JSON(http.StatusBadGateway, gin.H{
@@ -726,22 +726,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 {
_zi0 := _r6(exchangeResp) _5qha := _zy(exchangeResp)
c.JSON(exchangeResp.StatusCode, gin.H{ c.JSON(exchangeResp.StatusCode, gin.H{
"error": "Exchange failed", "error": "Exchange failed",
"details": _zi0.Error(), "details": _5qha.Error(),
}) })
return return
} }
var _9cn struct { var _o95o 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(&_9cn) json.NewDecoder(exchangeResp.Body).Decode(&_o95o)
if _9cn.APIKey == "" { if _o95o.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.",
@@ -749,7 +749,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
return return
} }
if err := rc._3yll(_9cn.APIKey, _9cn.Tier, _9cn.CustomerID); err != nil { if err := rc._301e(_o95o.APIKey, _o95o.Tier, _o95o.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(),
@@ -779,7 +779,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 := _jc3d(rc, uptime); err != nil { if err := _ln(rc, uptime); err != nil {
fmt.Printf(" ⚠ Heartbeat failed (non-blocking): %v\n", err) fmt.Printf(" ⚠ Heartbeat failed (non-blocking): %v\n", err)
} }
} }
@@ -788,14 +788,14 @@ func StartHeartbeat(ctx context.Context, rc *RuntimeContext, startTime time.Time
} }
func Shutdown(rc *RuntimeContext) { func Shutdown(rc *RuntimeContext) {
if rc == nil || rc._5i == "" { if rc == nil || rc._h7dl == "" {
return return
} }
_qd(rc) _x6qc(rc)
} }
func _sioq(code string) (_5i string, err error) { func _hl6v(code string) (_h7dl string, err error) {
resp, err := _5lk("/v1/register/exchange", map[string]string{ resp, err := _hvc("/v1/register/exchange", map[string]string{
"authorization_code": code, "authorization_code": code,
}) })
if err != nil { if err != nil {
@@ -804,104 +804,104 @@ func _sioq(code string) (_5i string, err error) {
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return "", _r6(resp) return "", _zy(resp)
} }
var _9cn struct { var _o95o struct {
APIKey string `json:"api_key"` APIKey string `json:"api_key"`
} }
json.NewDecoder(resp.Body).Decode(&_9cn) json.NewDecoder(resp.Body).Decode(&_o95o)
if _9cn.APIKey == "" { if _o95o.APIKey == "" {
return "", fmt.Errorf("exchange returned empty api_key") return "", fmt.Errorf("exchange returned empty api_key")
} }
return _9cn.APIKey, nil return _o95o.APIKey, nil
} }
func _sa72(authCodeOrKey string) (string, error) { func _u9(authCodeOrKey string) (string, error) {
_5i, err := _sioq(authCodeOrKey) _h7dl, err := _hl6v(authCodeOrKey)
if err == nil && _5i != "" { if err == nil && _h7dl != "" {
return _5i, nil return _h7dl, nil
} }
return authCodeOrKey, nil return authCodeOrKey, nil
} }
func _yxbc(rc *RuntimeContext, _41t string) error { func _jw(rc *RuntimeContext, _ia string) error {
resp, err := _iv("/v1/activate", map[string]string{ resp, err := _6yl("/v1/activate", map[string]string{
"instance_id": rc._78z, "instance_id": rc._yt,
"version": _41t, "version": _ia,
}, rc._5i) }, rc._h7dl)
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 _r6(resp) return _zy(resp)
} }
var _9cn struct { var _o95o struct {
Status string `json:"status"` Status string `json:"status"`
} }
json.NewDecoder(resp.Body).Decode(&_9cn) json.NewDecoder(resp.Body).Decode(&_o95o)
if _9cn.Status != "active" { if _o95o.Status != "active" {
return fmt.Errorf("activation returned status: %s", _9cn.Status) return fmt.Errorf("activation returned status: %s", _o95o.Status)
} }
return nil return nil
} }
func _jc3d(rc *RuntimeContext, uptimeSeconds int64) error { func _ln(rc *RuntimeContext, uptimeSeconds int64) error {
_xao := rc._b07h() _ihu := rc._71()
_th5 := rc._th5.Swap(0) _56 := rc._56.Swap(0)
payload := map[string]any{ payload := map[string]any{
"instance_id": rc._78z, "instance_id": rc._yt,
"uptime_seconds": uptimeSeconds, "uptime_seconds": uptimeSeconds,
"version": rc._41t, "version": rc._ia,
} }
if _xao > 0 || _th5 > 0 { if _ihu > 0 || _56 > 0 {
bundle := map[string]any{} bundle := map[string]any{}
if _xao > 0 { if _ihu > 0 {
bundle["messages_sent"] = _xao bundle["messages_sent"] = _ihu
} }
if _th5 > 0 { if _56 > 0 {
bundle["messages_recv"] = _th5 bundle["messages_recv"] = _56
} }
payload["telemetry_bundle"] = bundle payload["telemetry_bundle"] = bundle
} }
resp, err := _iv("/v1/heartbeat", payload, rc._5i) resp, err := _6yl("/v1/heartbeat", payload, rc._h7dl)
if err != nil { if err != nil {
rc._xao.Add(_xao) rc._ihu.Add(_ihu)
rc._th5.Add(_th5) rc._56.Add(_56)
return err return err
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
rc._xao.Add(_xao) rc._ihu.Add(_ihu)
rc._th5.Add(_th5) rc._56.Add(_56)
return _r6(resp) return _zy(resp)
} }
return nil return nil
} }
func _qd(rc *RuntimeContext) { func _x6qc(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._78z, "instance_id": rc._yt,
}) })
url := _it2l() + "/v1/deactivate" url := _hcg() + "/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._5i) req.Header.Set("X-Api-Key", rc._h7dl)
req.Header.Set("X-Signature", _trei(body, rc._5i)) req.Header.Set("X-Signature", _ry8(body, rc._h7dl))
_j7g.Do(req) _09.Do(req)
} }