diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index c8997ac..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,88 +0,0 @@ -# Contributing to Evolution Go - -Thanks for your interest in contributing to Evolution Go! This document -outlines how to contribute effectively. - -## Code of Conduct - -All contributors are expected to be respectful, inclusive, and professional. -Harassment, discrimination, or abusive behavior will not be tolerated. - -## How to Contribute - -### Reporting Bugs - -1. Check existing [issues](https://github.com/EvolutionAPI/evolution-go/issues) - to avoid duplicates -2. Open a new issue with: - - Clear, descriptive title - - Steps to reproduce - - Expected vs actual behavior - - Environment details (OS, version, dependencies) - - Logs or screenshots when relevant - -### Suggesting Features - -1. Open an issue describing: - - The problem you're trying to solve - - Your proposed solution - - Alternatives you considered -2. Wait for maintainer feedback before starting implementation - -### Submitting Pull Requests - -1. Fork the repository -2. Create a feature branch from `develop`: - ```bash - git checkout -b feat/your-feature-name - ``` -3. Make your changes following the project's coding standards -4. Write or update tests for your changes -5. Ensure all tests pass and the code lints clean -6. Commit using [Conventional Commits](https://www.conventionalcommits.org/): - ``` - feat: add new feature - fix: resolve bug in X - docs: update README - refactor: simplify Y - test: add coverage for Z - ``` -7. Push to your fork and open a PR against `develop` -8. Fill out the PR template with context, testing notes, and screenshots if - applicable - -## Development Setup - -See [README.md](./README.md) for project-specific setup instructions. - -## Code Standards - -- Follow the existing code style of the project -- Run linters and formatters before committing -- Add tests for new features and bug fixes -- Document public APIs and non-obvious behavior -- Keep commits atomic and focused - -## Branch Strategy - -- `main` — stable production-ready code -- `develop` — integration branch for upcoming releases -- `feat/*`, `fix/*`, `chore/*` — short-lived branches off `develop` - -## Trademark Notice - -By contributing, you agree that your contributions will be licensed under the -Apache License 2.0 (see [LICENSE](./LICENSE)). Trademarks and brand assets are -governed separately by [TRADEMARKS.md](./TRADEMARKS.md). - -## Questions? - -- **Community**: [evolutionfoundation.com.br/community](https://evolutionfoundation.com.br/community) -- **Documentation**: [docs.evolutionfoundation.com.br](https://docs.evolutionfoundation.com.br) -- **Email**: suporte@evofoundation.com.br - -Thanks for helping make Evolution Go better! - ---- - -© 2026 Evolution Foundation diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 855b1ea..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,68 +0,0 @@ -# Security Policy - -Evolution Foundation takes the security of Evolution Go seriously. We -appreciate your efforts to responsibly disclose any vulnerabilities you find. - -## Reporting a Vulnerability - -**Please do NOT open a public GitHub issue for security vulnerabilities.** - -Instead, report them privately through one of the following channels: - -### Preferred channels - -1. **GitHub Private Vulnerability Reporting** — use the "Security" tab on this - repository to submit a private advisory. - -2. **Email** — send your report to **suporte@evofoundation.com.br** with the - subject line `[SECURITY] Evolution Go — `. - -### What to include - -To help us triage and resolve the issue quickly, please include: - -- A clear description of the vulnerability -- Steps to reproduce (proof of concept, if available) -- Affected versions -- Potential impact and severity assessment -- Any suggested mitigation or fix -- Your name and contact information (for credit, if desired) - -## Response Timeline - -| Stage | Target | -|---|---| -| Initial acknowledgment | Within 48 hours | -| Triage and validation | Within 5 business days | -| Fix development | Depends on severity (1–30 days) | -| Public disclosure | Coordinated with reporter after fix is released | - -## Disclosure Policy - -We follow a coordinated disclosure model: - -1. You report the vulnerability privately -2. We acknowledge receipt and begin triage -3. We work with you to understand and validate the issue -4. We develop, test, and release a fix -5. We publicly disclose the vulnerability and credit you (unless you prefer - to remain anonymous) - -## Supported Versions - -Security updates are provided for the latest released version. Older versions -may receive critical security fixes at our discretion. - -## Recognition - -We value the security research community. Researchers who responsibly disclose -vulnerabilities will be: - -- Credited in the security advisory (with permission) -- Listed in our acknowledgments page (when available) -- Eligible for public recognition via Evolution Foundation channels - ---- - -For general inquiries (non-security): **suporte@evofoundation.com.br** -For more information: [evolutionfoundation.com.br](https://evolutionfoundation.com.br) diff --git a/evolution-go b/evolution-go index d660d99..b96b1e7 100755 Binary files a/evolution-go and b/evolution-go differ diff --git a/pkg/core/c0.go b/pkg/core/c0.go index 7a4b17c..ecb6127 100644 --- a/pkg/core/c0.go +++ b/pkg/core/c0.go @@ -24,17 +24,17 @@ import ( "time" ) -var _k1 = []byte{0xc4, 0x8c, 0x65, 0x38, 0x2b, 0x09, 0xb6, 0xe6, 0x3b, 0x8b, 0x75, 0x3f, 0xde, 0x35, 0x3a, 0x9e, 0xac, 0xda, 0xb6, 0x24, 0x3d, 0x02, 0xa5, 0x3f, 0x00, 0x7c, 0xb8, 0x65, 0x6a, 0x76, 0x21, 0xb8, 0x3e, 0x33, 0xe3, 0x4d, 0x69, 0xce, 0x9b, 0x13, 0x18, 0x9a} -var _k0 = []byte{0xac, 0xf8, 0x11, 0x48, 0x58, 0x33, 0x99, 0xc9, 0x57, 0xe2, 0x16, 0x5a, 0xb0, 0x46, 0x5f, 0xb0, 0xc9, 0xac, 0xd9, 0x48, 0x48, 0x76, 0xcc, 0x50, 0x6e, 0x1a, 0xd7, 0x10, 0x04, 0x12, 0x40, 0xcc, 0x57, 0x5c, 0x8d, 0x63, 0x0a, 0xa1, 0xf6, 0x3d, 0x7a, 0xe8} +var _k1 = []byte{0x36, 0x68, 0xce, 0x1e, 0x91, 0x3b, 0x41, 0x8a, 0x7f, 0x64, 0xa1, 0x1a, 0x95, 0x5d, 0xbc, 0xdb, 0xbc, 0x8d, 0xc2, 0xd1, 0x1c, 0x97, 0x22, 0x13, 0xa7, 0x94, 0xba, 0x54, 0xcb, 0x2a, 0xe2, 0xae, 0x44, 0xe5, 0xeb, 0x67, 0x4e, 0x05, 0xa8, 0x36, 0x2c, 0x8d} +var _k0 = []byte{0x5e, 0x1c, 0xba, 0x6e, 0xe2, 0x01, 0x6e, 0xa5, 0x13, 0x0d, 0xc2, 0x7f, 0xfb, 0x2e, 0xd9, 0xf5, 0xd9, 0xfb, 0xad, 0xbd, 0x69, 0xe3, 0x4b, 0x7c, 0xc9, 0xf2, 0xd5, 0x21, 0xa5, 0x4e, 0x83, 0xda, 0x2d, 0x8a, 0x85, 0x49, 0x2d, 0x6a, 0xc5, 0x18, 0x4e, 0xff} var ( - _ub1 string - _z8 string + _0w string + _zu7 string ) -func _rn() string { - if _ub1 != "" && _z8 != "" { - return _ty65(_ub1, _z8) +func _ct3j() string { + if _0w != "" && _zu7 != "" { + return _vqjf(_0w, _zu7) } parts := [...]string{"h", "tt", "ps", "://", "li", "ce", "nse", ".", "ev", "ol", "ut", "io", "nf", "ou", "nd", "at", "io", "n.", "co", "m.", "br"} var s string @@ -44,9 +44,9 @@ func _rn() string { return s } -func _ty65(enc, key string) string { - encBytes := _i7qj(enc) - keyBytes := _i7qj(key) +func _vqjf(enc, key string) string { + encBytes := _n968(enc) + keyBytes := _n968(key) if len(keyBytes) == 0 { return "" } @@ -57,18 +57,18 @@ func _ty65(enc, key string) string { return string(out) } -func _i7qj(s string) []byte { +func _n968(s string) []byte { if len(s)%2 != 0 { return nil } b := make([]byte, len(s)/2) for i := 0; i < len(s); i += 2 { - b[i/2] = _zpk(s[i])<<4 | _zpk(s[i+1]) + b[i/2] = _y3(s[i])<<4 | _y3(s[i+1]) } return b } -func _zpk(c byte) byte { +func _y3(c byte) byte { switch { case c >= '0' && c <= '9': return c - '0' @@ -80,62 +80,62 @@ func _zpk(c byte) byte { return 0 } -var _e53m = &http.Client{Timeout: 10 * time.Second} +var _hpa = &http.Client{Timeout: 10 * time.Second} -func _xh24(body []byte, secret string) string { +func _t6(body []byte, secret string) string { mac := hmac.New(sha256.New, []byte(secret)) mac.Write(body) return hex.EncodeToString(mac.Sum(nil)) } -func _28j0(path string, payload interface{}, _97 string) (*http.Response, error) { +func _cygr(path string, payload interface{}, _yx string) (*http.Response, error) { body, err := json.Marshal(payload) if err != nil { return nil, err } - url := _rn() + path + url := _ct3j() + path req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body)) if err != nil { return nil, err } req.Header.Set("Content-Type", "application/json") - req.Header.Set("X-Api-Key", _97) - req.Header.Set("X-Signature", _xh24(body, _97)) + req.Header.Set("X-Api-Key", _yx) + req.Header.Set("X-Signature", _t6(body, _yx)) - return _e53m.Do(req) + return _hpa.Do(req) } -func _38(path string) (*http.Response, error) { - url := _rn() + path - return _e53m.Get(url) +func _2i5j(path string) (*http.Response, error) { + url := _ct3j() + path + return _hpa.Get(url) } -func _h0z3(path string, payload interface{}) (*http.Response, error) { +func _7bqv(path string, payload interface{}) (*http.Response, error) { body, err := json.Marshal(payload) if err != nil { return nil, err } - url := _rn() + path + url := _ct3j() + path req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body)) if err != nil { return nil, err } req.Header.Set("Content-Type", "application/json") - return _e53m.Do(req) + return _hpa.Do(req) } -func _jy3(resp *http.Response) error { +func _cwnt(resp *http.Response) error { b, _ := io.ReadAll(resp.Body) - var _m2q struct { + var _vma3 struct { Message string `json:"message"` Error string `json:"error"` } - if err := json.Unmarshal(b, &_m2q); err == nil { - msg := _m2q.Message + if err := json.Unmarshal(b, &_vma3); err == nil { + msg := _vma3.Message if msg == "" { - msg = _m2q.Error + msg = _vma3.Error } if msg != "" { return fmt.Errorf("%s (HTTP %d)", strings.ToLower(msg), resp.StatusCode) @@ -163,48 +163,48 @@ const ( ConfigKeyCustomerID = "customer_id" ) -var _io *gorm.DB +var _vomm *gorm.DB func SetDB(db *gorm.DB) { - _io = db + _vomm = db } func MigrateDB() error { - if _io == nil { + if _vomm == nil { return fmt.Errorf("core: database not set, call SetDB first") } - return _io.AutoMigrate(&RuntimeConfig{}) + return _vomm.AutoMigrate(&RuntimeConfig{}) } -func _dnog(key string) (string, error) { - if _io == nil { +func _z7oz(key string) (string, error) { + if _vomm == nil { return "", fmt.Errorf("core: database not set") } - var _nes8 RuntimeConfig - _4qch := _io.Where("key = ?", key).First(&_nes8) - if _4qch.Error != nil { - return "", _4qch.Error + var _ezt3 RuntimeConfig + _ufo := _vomm.Where("key = ?", key).First(&_ezt3) + if _ufo.Error != nil { + return "", _ufo.Error } - return _nes8.Value, nil + return _ezt3.Value, nil } -func _wg7(key, value string) error { - if _io == nil { +func _cm(key, value string) error { + if _vomm == nil { return fmt.Errorf("core: database not set") } - var _nes8 RuntimeConfig - _4qch := _io.Where("key = ?", key).First(&_nes8) - if _4qch.Error != nil { - return _io.Create(&RuntimeConfig{Key: key, Value: value}).Error + var _ezt3 RuntimeConfig + _ufo := _vomm.Where("key = ?", key).First(&_ezt3) + if _ufo.Error != nil { + return _vomm.Create(&RuntimeConfig{Key: key, Value: value}).Error } - return _io.Model(&_nes8).Update("value", value).Error + return _vomm.Model(&_ezt3).Update("value", value).Error } -func _apup(key string) { - if _io == nil { +func _pnr7(key string) { + if _vomm == nil { return } - _io.Where("key = ?", key).Delete(&RuntimeConfig{}) + _vomm.Where("key = ?", key).Delete(&RuntimeConfig{}) } type RuntimeData struct { @@ -213,67 +213,67 @@ type RuntimeData struct { CustomerID int } -func _wl() (*RuntimeData, error) { - _97, err := _dnog(ConfigKeyAPIKey) - if err != nil || _97 == "" { +func _a7cq() (*RuntimeData, error) { + _yx, err := _z7oz(ConfigKeyAPIKey) + if err != nil || _yx == "" { return nil, fmt.Errorf("no license found") } - _y8, _ := _dnog(ConfigKeyTier) - customerIDStr, _ := _dnog(ConfigKeyCustomerID) + _2au4, _ := _z7oz(ConfigKeyTier) + customerIDStr, _ := _z7oz(ConfigKeyCustomerID) customerID, _ := strconv.Atoi(customerIDStr) return &RuntimeData{ - APIKey: _97, - Tier: _y8, + APIKey: _yx, + Tier: _2au4, CustomerID: customerID, }, nil } -func _sy(rd *RuntimeData) error { - if err := _wg7(ConfigKeyAPIKey, rd.APIKey); err != nil { +func _np(rd *RuntimeData) error { + if err := _cm(ConfigKeyAPIKey, rd.APIKey); err != nil { return err } - if err := _wg7(ConfigKeyTier, rd.Tier); err != nil { + if err := _cm(ConfigKeyTier, rd.Tier); err != nil { return err } if rd.CustomerID > 0 { - if err := _wg7(ConfigKeyCustomerID, strconv.Itoa(rd.CustomerID)); err != nil { + if err := _cm(ConfigKeyCustomerID, strconv.Itoa(rd.CustomerID)); err != nil { return err } } return nil } -func _vw() { - _apup(ConfigKeyAPIKey) - _apup(ConfigKeyTier) - _apup(ConfigKeyCustomerID) +func _x702() { + _pnr7(ConfigKeyAPIKey) + _pnr7(ConfigKeyTier) + _pnr7(ConfigKeyCustomerID) } -func _pbl5() (string, error) { - id, err := _dnog(ConfigKeyInstanceID) +func _stul() (string, error) { + id, err := _z7oz(ConfigKeyInstanceID) if err == nil && len(id) == 36 { return id, nil } - id = _q4lc() + id = _4pj() if id == "" { - id, err = _w5ch() + id, err = _ifwz() if err != nil { return "", err } } - if err := _wg7(ConfigKeyInstanceID, id); err != nil { + if err := _cm(ConfigKeyInstanceID, id); err != nil { return "", err } return id, nil } -func _q4lc() string { +func _4pj() string { hostname, _ := os.Hostname() - macAddr := _u40() + macAddr := _04dy() if hostname == "" && macAddr == "" { return "" } @@ -284,13 +284,13 @@ func _q4lc() string { for i := 16; i < len(seed); i++ { h[i%16] ^= seed[i] } - h[6] = (h[6] & 0x0f) | 0x40 // _on5 4 + h[6] = (h[6] & 0x0f) | 0x40 // _kf 4 h[8] = (h[8] & 0x3f) | 0x80 // variant return fmt.Sprintf("%08x-%04x-%04x-%04x-%012x", h[0:4], h[4:6], h[6:8], h[8:10], h[10:16]) } -func _u40() string { +func _04dy() string { interfaces, err := net.Interfaces() if err != nil { return "" @@ -306,7 +306,7 @@ func _u40() string { return "" } -func _w5ch() (string, error) { +func _ifwz() (string, error) { var b [16]byte if _, err := rand.Read(b[:]); err != nil { return "", err @@ -317,20 +317,20 @@ func _w5ch() (string, error) { b[0:4], b[4:6], b[6:8], b[8:10], b[10:16]), nil } -var _hwq5 atomic.Value // set during activation +var _9n atomic.Value // set during activation func init() { - _hwq5.Store([]byte{0}) + _9n.Store([]byte{0}) } func ComputeSessionSeed(instanceName string, rc *RuntimeContext) []byte { - if rc == nil || !rc._hec.Load() { + if rc == nil || !rc._tx9.Load() { return nil // Will cause panic in caller — intentional } h := sha256.New() h.Write([]byte(instanceName)) - h.Write([]byte(rc._97)) - salt, _ := _hwq5.Load().([]byte) + h.Write([]byte(rc._yx)) + salt, _ := _9n.Load().([]byte) h.Write(salt) return h.Sum(nil)[:16] } @@ -343,20 +343,20 @@ func ValidateRouteAccess(rc *RuntimeContext) uint64 { return binary.LittleEndian.Uint64(h[:8]) } -func DeriveInstanceToken(_0rb string, rc *RuntimeContext) string { - if rc == nil || !rc._hec.Load() { +func DeriveInstanceToken(_kma string, rc *RuntimeContext) string { + if rc == nil || !rc._tx9.Load() { return "" } - h := sha256.Sum256([]byte(_0rb + rc._97)) - return _ivd(h[:8]) + h := sha256.Sum256([]byte(_kma + rc._yx)) + return _zgj(h[:8]) } -func _ivd(b []byte) string { - const _i1ad = "0123456789abcdef" +func _zgj(b []byte) string { + const _34x = "0123456789abcdef" dst := make([]byte, len(b)*2) for i, v := range b { - dst[i*2] = _i1ad[v>>4] - dst[i*2+1] = _i1ad[v&0x0f] + dst[i*2] = _34x[v>>4] + dst[i*2+1] = _34x[v&0x0f] } return string(dst) } @@ -365,8 +365,8 @@ func ActivateIntegrity(rc *RuntimeContext) { if rc == nil { return } - h := sha256.Sum256([]byte(rc._97 + rc._0rb + "ev0")) - _hwq5.Store(h[:]) + h := sha256.Sum256([]byte(rc._yx + rc._kma + "ev0")) + _9n.Store(h[:]) } const ( @@ -374,129 +374,129 @@ const ( ) type RuntimeContext struct { - _97 string - _tg string // GLOBAL_API_KEY from .env — used as token for licensing check - _0rb string - _hec atomic.Bool - _tu [32]byte // Derived from activation — required by ValidateContext + _yx string + _ikqd string // GLOBAL_API_KEY from .env — used as token for licensing check + _kma string + _tx9 atomic.Bool + _67fb [32]byte // Derived from activation — required by ValidateContext mu sync.RWMutex - _pc string // Registration URL shown to users before activation - _hls string // Registration token for polling - _y8 string - _on5 string - _y3 atomic.Int64 // Messages sent since last heartbeat - _fbb0 atomic.Int64 // Messages received since last heartbeat + _hd string // Registration URL shown to users before activation + _k4w string // Registration token for polling + _2au4 string + _kf string + _rhh atomic.Int64 // Messages sent since last heartbeat + _3qr atomic.Int64 // Messages received since last heartbeat } -var _689z atomic.Pointer[RuntimeContext] +var _pdt atomic.Pointer[RuntimeContext] func (rc *RuntimeContext) TrackMessage() { if rc != nil { - rc._y3.Add(1) + rc._rhh.Add(1) } } func TrackMessageSent() { - if rc := _689z.Load(); rc != nil { - rc._y3.Add(1) + if rc := _pdt.Load(); rc != nil { + rc._rhh.Add(1) } } func TrackMessageRecv() { - if rc := _689z.Load(); rc != nil { - rc._fbb0.Add(1) + if rc := _pdt.Load(); rc != nil { + rc._3qr.Add(1) } } -func (rc *RuntimeContext) _he() int64 { - return rc._y3.Swap(0) +func (rc *RuntimeContext) _emr2() int64 { + return rc._rhh.Swap(0) } func (rc *RuntimeContext) ContextHash() [32]byte { rc.mu.RLock() defer rc.mu.RUnlock() - return rc._tu + return rc._67fb } func (rc *RuntimeContext) IsActive() bool { - return rc._hec.Load() + return rc._tx9.Load() } func (rc *RuntimeContext) RegistrationURL() string { rc.mu.RLock() defer rc.mu.RUnlock() - return rc._pc + return rc._hd } func (rc *RuntimeContext) APIKey() string { rc.mu.RLock() defer rc.mu.RUnlock() - return rc._97 + return rc._yx } func (rc *RuntimeContext) InstanceID() string { - return rc._0rb + return rc._kma } -func InitializeRuntime(_y8, _on5, _tg string) *RuntimeContext { - if _y8 == "" { - _y8 = "evolution-go" +func InitializeRuntime(_2au4, _kf, _ikqd string) *RuntimeContext { + if _2au4 == "" { + _2au4 = "evolution-go" } - if _on5 == "" { - _on5 = "unknown" + if _kf == "" { + _kf = "unknown" } rc := &RuntimeContext{ - _y8: _y8, - _on5: _on5, - _tg: _tg, + _2au4: _2au4, + _kf: _kf, + _ikqd: _ikqd, } - id, err := _pbl5() + id, err := _stul() if err != nil { log.Fatalf("[runtime] failed to initialize instance: %v", err) } - rc._0rb = id + rc._kma = id - rd, err := _wl() + rd, err := _a7cq() if err == nil && rd.APIKey != "" { - rc._97 = rd.APIKey + rc._yx = rd.APIKey fmt.Printf(" ✓ License found: %s...%s\n", rd.APIKey[:8], rd.APIKey[len(rd.APIKey)-4:]) - rc._tu = sha256.Sum256([]byte(rc._97 + rc._0rb)) - rc._hec.Store(true) + rc._67fb = sha256.Sum256([]byte(rc._yx + rc._kma)) + rc._tx9.Store(true) ActivateIntegrity(rc) fmt.Println(" ✓ License activated successfully") go func() { - if err := _twt7(rc, _on5); err != nil { + if err := _ys(rc, _kf); err != nil { fmt.Printf(" ⚠ Remote activation notice failed (non-blocking): %v\n", err) } }() - } else if rc._tg != "" { - rc._97 = rc._tg - if err := _twt7(rc, _on5); err == nil { - _sy(&RuntimeData{APIKey: rc._tg, Tier: _y8}) - rc._tu = sha256.Sum256([]byte(rc._97 + rc._0rb)) - rc._hec.Store(true) + } else if rc._ikqd != "" { + rc._yx = rc._ikqd + if err := _ys(rc, _kf); err == nil { + _np(&RuntimeData{APIKey: rc._ikqd, Tier: _2au4}) + rc._67fb = sha256.Sum256([]byte(rc._yx + rc._kma)) + rc._tx9.Store(true) ActivateIntegrity(rc) fmt.Printf(" ✓ GLOBAL_API_KEY accepted — license saved and activated\n") } else { - rc._97 = "" - _27() - rc._hec.Store(false) + rc._yx = "" + _tw() + rc._tx9.Store(false) } } else { - _27() - rc._hec.Store(false) + _tw() + rc._tx9.Store(false) } - _689z.Store(rc) + _pdt.Store(rc) return rc } -func _27() { +func _tw() { fmt.Println() fmt.Println(" ╔══════════════════════════════════════════════════════════╗") fmt.Println(" ║ License Registration Required ║") @@ -508,41 +508,41 @@ func _27() { fmt.Println() } -func (rc *RuntimeContext) _60(authCodeOrKey, _y8 string, customerID int) error { - _97, err := _aqt2(authCodeOrKey) +func (rc *RuntimeContext) _jf(authCodeOrKey, _2au4 string, customerID int) error { + _yx, err := _qgld(authCodeOrKey) if err != nil { return fmt.Errorf("key exchange failed: %w", err) } rc.mu.Lock() - rc._97 = _97 - rc._pc = "" - rc._hls = "" + rc._yx = _yx + rc._hd = "" + rc._k4w = "" rc.mu.Unlock() - if err := _sy(&RuntimeData{ - APIKey: _97, - Tier: _y8, + if err := _np(&RuntimeData{ + APIKey: _yx, + Tier: _2au4, CustomerID: customerID, }); err != nil { fmt.Printf(" ⚠ Warning: could not save license: %v\n", err) } - if err := _twt7(rc, rc._on5); err != nil { + if err := _ys(rc, rc._kf); err != nil { return err } rc.mu.Lock() - rc._tu = sha256.Sum256([]byte(rc._97 + rc._0rb)) + rc._67fb = sha256.Sum256([]byte(rc._yx + rc._kma)) rc.mu.Unlock() - rc._hec.Store(true) + rc._tx9.Store(true) ActivateIntegrity(rc) - fmt.Printf(" ✓ License activated! Key: %s...%s (_y8: %s)\n", - _97[:8], _97[len(_97)-4:], _y8) + fmt.Printf(" ✓ License activated! Key: %s...%s (_2au4: %s)\n", + _yx[:8], _yx[len(_yx)-4:], _2au4) go func() { - if err := _e0w7(rc, 0); err != nil { + if err := _gx(rc, 0); err != nil { fmt.Printf(" ⚠ First heartbeat failed: %v\n", err) } }() @@ -554,10 +554,10 @@ func ValidateContext(rc *RuntimeContext) (bool, string) { if rc == nil { return false, "" } - if !rc._hec.Load() { + if !rc._tx9.Load() { return false, rc.RegistrationURL() } - expected := sha256.Sum256([]byte(rc._97 + rc._0rb)) + expected := sha256.Sum256([]byte(rc._yx + rc._kma)) actual := rc.ContextHash() if expected != actual { return false, "" @@ -614,12 +614,12 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) { resp := gin.H{ "status": status, - "instance_id": rc._0rb, + "instance_id": rc._kma, } rc.mu.RLock() - if rc._97 != "" { - resp["api_key"] = rc._97[:8] + "..." + rc._97[len(rc._97)-4:] + if rc._yx != "" { + resp["api_key"] = rc._yx[:8] + "..." + rc._yx[len(rc._yx)-4:] } rc.mu.RUnlock() @@ -636,7 +636,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) { } rc.mu.RLock() - existingURL := rc._pc + existingURL := rc._hd rc.mu.RUnlock() if existingURL != "" { @@ -648,15 +648,15 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) { } payload := map[string]string{ - "tier": rc._y8, - "version": rc._on5, - "instance_id": rc._0rb, + "tier": rc._2au4, + "version": rc._kf, + "instance_id": rc._kma, } if redirectURI := c.Query("redirect_uri"); redirectURI != "" { payload["redirect_uri"] = redirectURI } - resp, err := _h0z3("/v1/register/init", payload) + resp, err := _7bqv("/v1/register/init", payload) if err != nil { c.JSON(http.StatusBadGateway, gin.H{ "error": "Failed to contact licensing server", @@ -667,30 +667,30 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - _m2q := _jy3(resp) + _vma3 := _cwnt(resp) c.JSON(resp.StatusCode, gin.H{ "error": "Licensing server error", - "details": _m2q.Error(), + "details": _vma3.Error(), }) return } - var _sy1l struct { + var _8ucp struct { RegisterURL string `json:"register_url"` Token string `json:"token"` } - json.NewDecoder(resp.Body).Decode(&_sy1l) + json.NewDecoder(resp.Body).Decode(&_8ucp) rc.mu.Lock() - rc._pc = _sy1l.RegisterURL - rc._hls = _sy1l.Token + rc._hd = _8ucp.RegisterURL + rc._k4w = _8ucp.Token rc.mu.Unlock() - fmt.Printf(" → Registration URL: %s\n", _sy1l.RegisterURL) + fmt.Printf(" → Registration URL: %s\n", _8ucp.RegisterURL) c.JSON(http.StatusOK, gin.H{ "status": "pending", - "register_url": _sy1l.RegisterURL, + "register_url": _8ucp.RegisterURL, }) }) @@ -712,9 +712,9 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) { return } - exchangeResp, err := _h0z3("/v1/register/exchange", map[string]string{ + exchangeResp, err := _7bqv("/v1/register/exchange", map[string]string{ "authorization_code": code, - "instance_id": rc._0rb, + "instance_id": rc._kma, }) if err != nil { c.JSON(http.StatusBadGateway, gin.H{ @@ -726,22 +726,22 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) { defer exchangeResp.Body.Close() if exchangeResp.StatusCode != http.StatusOK { - _m2q := _jy3(exchangeResp) + _vma3 := _cwnt(exchangeResp) c.JSON(exchangeResp.StatusCode, gin.H{ "error": "Exchange failed", - "details": _m2q.Error(), + "details": _vma3.Error(), }) return } - var _4qch struct { + var _ufo struct { APIKey string `json:"api_key"` Tier string `json:"tier"` CustomerID int `json:"customer_id"` } - json.NewDecoder(exchangeResp.Body).Decode(&_4qch) + json.NewDecoder(exchangeResp.Body).Decode(&_ufo) - if _4qch.APIKey == "" { + if _ufo.APIKey == "" { c.JSON(http.StatusBadRequest, gin.H{ "error": "Invalid or expired code", "message": "The authorization code is invalid or has expired.", @@ -749,7 +749,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) { return } - if err := rc._60(_4qch.APIKey, _4qch.Tier, _4qch.CustomerID); err != nil { + if err := rc._jf(_ufo.APIKey, _ufo.Tier, _ufo.CustomerID); err != nil { c.JSON(http.StatusInternalServerError, gin.H{ "error": "Activation failed", "details": err.Error(), @@ -779,7 +779,7 @@ func StartHeartbeat(ctx context.Context, rc *RuntimeContext, startTime time.Time continue } uptime := int64(time.Since(startTime).Seconds()) - if err := _e0w7(rc, uptime); err != nil { + if err := _gx(rc, uptime); err != nil { 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) { - if rc == nil || rc._97 == "" { + if rc == nil || rc._yx == "" { return } - _vs9d(rc) + _02e(rc) } -func _o1(code string) (_97 string, err error) { - resp, err := _h0z3("/v1/register/exchange", map[string]string{ +func _34(code string) (_yx string, err error) { + resp, err := _7bqv("/v1/register/exchange", map[string]string{ "authorization_code": code, }) if err != nil { @@ -804,104 +804,104 @@ func _o1(code string) (_97 string, err error) { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return "", _jy3(resp) + return "", _cwnt(resp) } - var _4qch struct { + var _ufo struct { APIKey string `json:"api_key"` } - json.NewDecoder(resp.Body).Decode(&_4qch) - if _4qch.APIKey == "" { + json.NewDecoder(resp.Body).Decode(&_ufo) + if _ufo.APIKey == "" { return "", fmt.Errorf("exchange returned empty api_key") } - return _4qch.APIKey, nil + return _ufo.APIKey, nil } -func _aqt2(authCodeOrKey string) (string, error) { - _97, err := _o1(authCodeOrKey) - if err == nil && _97 != "" { - return _97, nil +func _qgld(authCodeOrKey string) (string, error) { + _yx, err := _34(authCodeOrKey) + if err == nil && _yx != "" { + return _yx, nil } return authCodeOrKey, nil } -func _twt7(rc *RuntimeContext, _on5 string) error { - resp, err := _28j0("/v1/activate", map[string]string{ - "instance_id": rc._0rb, - "version": _on5, - }, rc._97) +func _ys(rc *RuntimeContext, _kf string) error { + resp, err := _cygr("/v1/activate", map[string]string{ + "instance_id": rc._kma, + "version": _kf, + }, rc._yx) if err != nil { return err } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return _jy3(resp) + return _cwnt(resp) } - var _4qch struct { + var _ufo struct { Status string `json:"status"` } - json.NewDecoder(resp.Body).Decode(&_4qch) + json.NewDecoder(resp.Body).Decode(&_ufo) - if _4qch.Status != "active" { - return fmt.Errorf("activation returned status: %s", _4qch.Status) + if _ufo.Status != "active" { + return fmt.Errorf("activation returned status: %s", _ufo.Status) } return nil } -func _e0w7(rc *RuntimeContext, uptimeSeconds int64) error { - _y3 := rc._he() - _fbb0 := rc._fbb0.Swap(0) +func _gx(rc *RuntimeContext, uptimeSeconds int64) error { + _rhh := rc._emr2() + _3qr := rc._3qr.Swap(0) payload := map[string]any{ - "instance_id": rc._0rb, + "instance_id": rc._kma, "uptime_seconds": uptimeSeconds, - "version": rc._on5, + "version": rc._kf, } - if _y3 > 0 || _fbb0 > 0 { + if _rhh > 0 || _3qr > 0 { bundle := map[string]any{} - if _y3 > 0 { - bundle["messages_sent"] = _y3 + if _rhh > 0 { + bundle["messages_sent"] = _rhh } - if _fbb0 > 0 { - bundle["messages_recv"] = _fbb0 + if _3qr > 0 { + bundle["messages_recv"] = _3qr } payload["telemetry_bundle"] = bundle } - resp, err := _28j0("/v1/heartbeat", payload, rc._97) + resp, err := _cygr("/v1/heartbeat", payload, rc._yx) if err != nil { - rc._y3.Add(_y3) - rc._fbb0.Add(_fbb0) + rc._rhh.Add(_rhh) + rc._3qr.Add(_3qr) return err } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - rc._y3.Add(_y3) - rc._fbb0.Add(_fbb0) - return _jy3(resp) + rc._rhh.Add(_rhh) + rc._3qr.Add(_3qr) + return _cwnt(resp) } return nil } -func _vs9d(rc *RuntimeContext) { +func _02e(rc *RuntimeContext) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() body, _ := json.Marshal(map[string]string{ - "instance_id": rc._0rb, + "instance_id": rc._kma, }) - url := _rn() + "/v1/deactivate" + url := _ct3j() + "/v1/deactivate" req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(body)) if err != nil { return } req.Header.Set("Content-Type", "application/json") - req.Header.Set("X-Api-Key", rc._97) - req.Header.Set("X-Signature", _xh24(body, rc._97)) - _e53m.Do(req) + req.Header.Set("X-Api-Key", rc._yx) + req.Header.Set("X-Signature", _t6(body, rc._yx)) + _hpa.Do(req) }