Skip to content

Evolution API / Evolution Go is an open-source WhatsApp integration API

sync: 0.6.1 from main (b5abe7465d4c5e70c055b9015416f95d4b434221)

github-actions[bot]182a7190538e
diff --git a/Dockerfile b/Dockerfile
index 8ad0e7a..4c0c7d6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -27,6 +27,7 @@ WORKDIR /app
COPY --from=build /build/server .
COPY --from=build /build/manager/dist ./manager/dist
+COPY --from=build /build/VERSION ./VERSION
ENV TZ=America/Sao_Paulo
diff --git a/cmd/evolution-go/main.go b/cmd/evolution-go/main.go
index 95e7dee..ddc760e 100644
--- a/cmd/evolution-go/main.go
+++ b/cmd/evolution-go/main.go
@@ -68,13 +68,18 @@ import (
var devMode = flag.Bool("dev", false, "Enable development mode")
-var version = readVersion()
-
-func readVersion() string {
- if v, err := os.ReadFile("VERSION"); err == nil {
- return strings.TrimSpace(string(v))
+var version = "0.0.0"
+
+func init() {
+ // ldflags -X main.version= sets this at compile time.
+ // If not set (or still default), try reading from VERSION file.
+ if version == "0.0.0" {
+ if v, err := os.ReadFile("VERSION"); err == nil {
+ if trimmed := strings.TrimSpace(string(v)); trimmed != "" {
+ version = trimmed
+ }
+ }
}
- return "0.0.0"
}
func setupRouter(db *gorm.DB, authDB *sql.DB, sqliteDB *sql.DB, config *config.Config, conn *amqp.Connection, exPath string, runtimeCtx *core.RuntimeContext) *gin.Engine {
diff --git a/evolution-go b/evolution-go
index 4e376f7..8fbb1f9 100755
Binary files a/evolution-go and b/evolution-go differ
diff --git a/pkg/core/c0.go b/pkg/core/c0.go
index 61026b1..e93caa1 100644
--- a/pkg/core/c0.go
+++ b/pkg/core/c0.go
@@ -24,17 +24,17 @@ import (
"time"
)
-var _k1 = []byte{0x58, 0x18, 0x90, 0x2d, 0xba, 0x75, 0x41, 0xad, 0x68, 0xc3, 0xb6, 0x01, 0xed, 0x7d, 0x1d, 0x44, 0x07, 0xd3, 0x59, 0xc6, 0x61, 0x50, 0x62, 0x94, 0x8f, 0x7b, 0xa2, 0xb0, 0xa6, 0x97, 0xfe, 0x91, 0x0c, 0xdf, 0xf4, 0x99, 0x71, 0x54, 0xe9, 0x1b, 0x70, 0xf2}
-var _k0 = []byte{0x30, 0x6c, 0xe4, 0x5d, 0xc9, 0x4f, 0x6e, 0x82, 0x04, 0xaa, 0xd5, 0x64, 0x83, 0x0e, 0x78, 0x6a, 0x62, 0xa5, 0x36, 0xaa, 0x14, 0x24, 0x0b, 0xfb, 0xe1, 0x1d, 0xcd, 0xc5, 0xc8, 0xf3, 0x9f, 0xe5, 0x65, 0xb0, 0x9a, 0xb7, 0x12, 0x3b, 0x84, 0x35, 0x12, 0x80}
+var _k1 = []byte{0x92, 0x8a, 0x16, 0xa6, 0xfe, 0xe4, 0x09, 0xeb, 0xf6, 0x25, 0xd6, 0xf3, 0x94, 0x0f, 0x76, 0xef, 0x38, 0x68, 0xe0, 0x52, 0x4e, 0xca, 0x54, 0x25, 0x4b, 0x93, 0x52, 0xc6, 0x5a, 0x59, 0x4e, 0x64, 0xa7, 0xce, 0x48, 0x22, 0x7f, 0x04, 0x3c, 0x59, 0x0e, 0x3b}
+var _k0 = []byte{0xfa, 0xfe, 0x62, 0xd6, 0x8d, 0xde, 0x26, 0xc4, 0x9a, 0x4c, 0xb5, 0x96, 0xfa, 0x7c, 0x13, 0xc1, 0x5d, 0x1e, 0x8f, 0x3e, 0x3b, 0xbe, 0x3d, 0x4a, 0x25, 0xf5, 0x3d, 0xb3, 0x34, 0x3d, 0x2f, 0x10, 0xce, 0xa1, 0x26, 0x0c, 0x1c, 0x6b, 0x51, 0x77, 0x6c, 0x49}
var (
- _hb5 string
- _s3kc string
+ _w3s9 string
+ _jl7 string
)
-func _53() string {
- if _hb5 != "" && _s3kc != "" {
- return _nc(_hb5, _s3kc)
+func _rmo() string {
+ if _w3s9 != "" && _jl7 != "" {
+ return _4drn(_w3s9, _jl7)
}
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 _53() string {
return s
}
-func _nc(enc, key string) string {
- encBytes := _jcv(enc)
- keyBytes := _jcv(key)
+func _4drn(enc, key string) string {
+ encBytes := _iz6(enc)
+ keyBytes := _iz6(key)
if len(keyBytes) == 0 {
return ""
}
@@ -57,18 +57,18 @@ func _nc(enc, key string) string {
return string(out)
}
-func _jcv(s string) []byte {
+func _iz6(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] = _vcc(s[i])<<4 | _vcc(s[i+1])
+ b[i/2] = _xtts(s[i])<<4 | _xtts(s[i+1])
}
return b
}
-func _vcc(c byte) byte {
+func _xtts(c byte) byte {
switch {
case c >= '0' && c <= '9':
return c - '0'
@@ -80,62 +80,62 @@ func _vcc(c byte) byte {
return 0
}
-var _wof6 = &http.Client{Timeout: 10 * time.Second}
+var _ls61 = &http.Client{Timeout: 10 * time.Second}
-func _h33h(body []byte, secret string) string {
+func _t5d(body []byte, secret string) string {
mac := hmac.New(sha256.New, []byte(secret))
mac.Write(body)
return hex.EncodeToString(mac.Sum(nil))
}
-func _cr(path string, payload interface{}, _34 string) (*http.Response, error) {
+func _rkb(path string, payload interface{}, _jpwr string) (*http.Response, error) {
body, err := json.Marshal(payload)
if err != nil {
return nil, err
}
- url := _53() + path
+ url := _rmo() + 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", _34)
- req.Header.Set("X-Signature", _h33h(body, _34))
+ req.Header.Set("X-Api-Key", _jpwr)
+ req.Header.Set("X-Signature", _t5d(body, _jpwr))
- return _wof6.Do(req)
+ return _ls61.Do(req)
}
-func _ml(path string) (*http.Response, error) {
- url := _53() + path
- return _wof6.Get(url)
+func _qfhm(path string) (*http.Response, error) {
+ url := _rmo() + path
+ return _ls61.Get(url)
}
-func _i0(path string, payload interface{}) (*http.Response, error) {
+func _pzi6(path string, payload interface{}) (*http.Response, error) {
body, err := json.Marshal(payload)
if err != nil {
return nil, err
}
- url := _53() + path
+ url := _rmo() + 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 _wof6.Do(req)
+ return _ls61.Do(req)
}
-func _lo(resp *http.Response) error {
+func _2l4(resp *http.Response) error {
b, _ := io.ReadAll(resp.Body)
- var _286 struct {
+ var _28 struct {
Message string `json:"message"`
Error string `json:"error"`
}
- if err := json.Unmarshal(b, &_286); err == nil {
- msg := _286.Message
+ if err := json.Unmarshal(b, &_28); err == nil {
+ msg := _28.Message
if msg == "" {
- msg = _286.Error
+ msg = _28.Error
}
if msg != "" {
return fmt.Errorf("%s (HTTP %d)", strings.ToLower(msg), resp.StatusCode)
@@ -163,48 +163,48 @@ const (
ConfigKeyCustomerID = "customer_id"
)
-var _uj *gorm.DB
+var _4k *gorm.DB
func SetDB(db *gorm.DB) {
- _uj = db
+ _4k = db
}
func MigrateDB() error {
- if _uj == nil {
+ if _4k == nil {
return fmt.Errorf("core: database not set, call SetDB first")
}
- return _uj.AutoMigrate(&RuntimeConfig{})
+ return _4k.AutoMigrate(&RuntimeConfig{})
}
-func _vm5(key string) (string, error) {
- if _uj == nil {
+func _di(key string) (string, error) {
+ if _4k == nil {
return "", fmt.Errorf("core: database not set")
}
- var _vi5 RuntimeConfig
- _78g := _uj.Where("key = ?", key).First(&_vi5)
- if _78g.Error != nil {
- return "", _78g.Error
+ var _lac RuntimeConfig
+ _x1 := _4k.Where("key = ?", key).First(&_lac)
+ if _x1.Error != nil {
+ return "", _x1.Error
}
- return _vi5.Value, nil
+ return _lac.Value, nil
}
-func _scrw(key, value string) error {
- if _uj == nil {
+func _o35(key, value string) error {
+ if _4k == nil {
return fmt.Errorf("core: database not set")
}
- var _vi5 RuntimeConfig
- _78g := _uj.Where("key = ?", key).First(&_vi5)
- if _78g.Error != nil {
- return _uj.Create(&RuntimeConfig{Key: key, Value: value}).Error
+ var _lac RuntimeConfig
+ _x1 := _4k.Where("key = ?", key).First(&_lac)
+ if _x1.Error != nil {
+ return _4k.Create(&RuntimeConfig{Key: key, Value: value}).Error
}
- return _uj.Model(&_vi5).Update("value", value).Error
+ return _4k.Model(&_lac).Update("value", value).Error
}
-func _979q(key string) {
- if _uj == nil {
+func _nre(key string) {
+ if _4k == nil {
return
}
- _uj.Where("key = ?", key).Delete(&RuntimeConfig{})
+ _4k.Where("key = ?", key).Delete(&RuntimeConfig{})
}
type RuntimeData struct {
@@ -213,67 +213,67 @@ type RuntimeData struct {
CustomerID int
}
-func _7x() (*RuntimeData, error) {
- _34, err := _vm5(ConfigKeyAPIKey)
- if err != nil || _34 == "" {
+func _8ftv() (*RuntimeData, error) {
+ _jpwr, err := _di(ConfigKeyAPIKey)
+ if err != nil || _jpwr == "" {
return nil, fmt.Errorf("no license found")
}
- _7j2, _ := _vm5(ConfigKeyTier)
- customerIDStr, _ := _vm5(ConfigKeyCustomerID)
+ _y6, _ := _di(ConfigKeyTier)
+ customerIDStr, _ := _di(ConfigKeyCustomerID)
customerID, _ := strconv.Atoi(customerIDStr)
return &RuntimeData{
- APIKey: _34,
- Tier: _7j2,
+ APIKey: _jpwr,
+ Tier: _y6,
CustomerID: customerID,
}, nil
}
-func _yi4m(rd *RuntimeData) error {
- if err := _scrw(ConfigKeyAPIKey, rd.APIKey); err != nil {
+func _nk7y(rd *RuntimeData) error {
+ if err := _o35(ConfigKeyAPIKey, rd.APIKey); err != nil {
return err
}
- if err := _scrw(ConfigKeyTier, rd.Tier); err != nil {
+ if err := _o35(ConfigKeyTier, rd.Tier); err != nil {
return err
}
if rd.CustomerID > 0 {
- if err := _scrw(ConfigKeyCustomerID, strconv.Itoa(rd.CustomerID)); err != nil {
+ if err := _o35(ConfigKeyCustomerID, strconv.Itoa(rd.CustomerID)); err != nil {
return err
}
}
return nil
}
-func _98g() {
- _979q(ConfigKeyAPIKey)
- _979q(ConfigKeyTier)
- _979q(ConfigKeyCustomerID)
+func _9s() {
+ _nre(ConfigKeyAPIKey)
+ _nre(ConfigKeyTier)
+ _nre(ConfigKeyCustomerID)
}
-func _h6vl() (string, error) {
- id, err := _vm5(ConfigKeyInstanceID)
+func _viat() (string, error) {
+ id, err := _di(ConfigKeyInstanceID)
if err == nil && len(id) == 36 {
return id, nil
}
- id = _by()
+ id = _ead()
if id == "" {
- id, err = _xre()
+ id, err = _hxo()
if err != nil {
return "", err
}
}
- if err := _scrw(ConfigKeyInstanceID, id); err != nil {
+ if err := _o35(ConfigKeyInstanceID, id); err != nil {
return "", err
}
return id, nil
}
-func _by() string {
+func _ead() string {
hostname, _ := os.Hostname()
- macAddr := _qe5()
+ macAddr := _g9n9()
if hostname == "" && macAddr == "" {
return ""
}
@@ -284,13 +284,13 @@ func _by() string {
for i := 16; i < len(seed); i++ {
h[i%16] ^= seed[i]
}
- h[6] = (h[6] & 0x0f) | 0x40 // _bwg 4
+ h[6] = (h[6] & 0x0f) | 0x40 // _h7 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 _qe5() string {
+func _g9n9() string {
interfaces, err := net.Interfaces()
if err != nil {
return ""
@@ -306,7 +306,7 @@ func _qe5() string {
return ""
}
-func _xre() (string, error) {
+func _hxo() (string, error) {
var b [16]byte
if _, err := rand.Read(b[:]); err != nil {
return "", err
@@ -317,20 +317,20 @@ func _xre() (string, error) {
b[0:4], b[4:6], b[6:8], b[8:10], b[10:16]), nil
}
-var _qr5 atomic.Value // set during activation
+var _l3rh atomic.Value // set during activation
func init() {
- _qr5.Store([]byte{0})
+ _l3rh.Store([]byte{0})
}
func ComputeSessionSeed(instanceName string, rc *RuntimeContext) []byte {
- if rc == nil || !rc._dcf.Load() {
+ if rc == nil || !rc._xk65.Load() {
return nil // Will cause panic in caller — intentional
}
h := sha256.New()
h.Write([]byte(instanceName))
- h.Write([]byte(rc._34))
- salt, _ := _qr5.Load().([]byte)
+ h.Write([]byte(rc._jpwr))
+ salt, _ := _l3rh.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(_tpx0 string, rc *RuntimeContext) string {
- if rc == nil || !rc._dcf.Load() {
+func DeriveInstanceToken(_645 string, rc *RuntimeContext) string {
+ if rc == nil || !rc._xk65.Load() {
return ""
}
- h := sha256.Sum256([]byte(_tpx0 + rc._34))
- return _aj(h[:8])
+ h := sha256.Sum256([]byte(_645 + rc._jpwr))
+ return _yls(h[:8])
}
-func _aj(b []byte) string {
- const _oww0 = "0123456789abcdef"
+func _yls(b []byte) string {
+ const _5swh = "0123456789abcdef"
dst := make([]byte, len(b)*2)
for i, v := range b {
- dst[i*2] = _oww0[v>>4]
- dst[i*2+1] = _oww0[v&0x0f]
+ dst[i*2] = _5swh[v>>4]
+ dst[i*2+1] = _5swh[v&0x0f]
}
return string(dst)
}
@@ -365,8 +365,8 @@ func ActivateIntegrity(rc *RuntimeContext) {
if rc == nil {
return
}
- h := sha256.Sum256([]byte(rc._34 + rc._tpx0 + "ev0"))
- _qr5.Store(h[:])
+ h := sha256.Sum256([]byte(rc._jpwr + rc._645 + "ev0"))
+ _l3rh.Store(h[:])
}
const (
@@ -374,101 +374,101 @@ const (
)
type RuntimeContext struct {
- _34 string
- _t0 string // GLOBAL_API_KEY from .env — used as token for licensing check
- _tpx0 string
- _dcf atomic.Bool
- _tq [32]byte // Derived from activation — required by ValidateContext
+ _jpwr string
+ _444 string // GLOBAL_API_KEY from .env — used as token for licensing check
+ _645 string
+ _xk65 atomic.Bool
+ _uw [32]byte // Derived from activation — required by ValidateContext
mu sync.RWMutex
- _xbaq string // Registration URL shown to users before activation
- _8w9u string // Registration token for polling
- _7j2 string
- _bwg string
+ _yf6 string // Registration URL shown to users before activation
+ _s09 string // Registration token for polling
+ _y6 string
+ _h7 string
}
func (rc *RuntimeContext) ContextHash() [32]byte {
rc.mu.RLock()
defer rc.mu.RUnlock()
- return rc._tq
+ return rc._uw
}
func (rc *RuntimeContext) IsActive() bool {
- return rc._dcf.Load()
+ return rc._xk65.Load()
}
func (rc *RuntimeContext) RegistrationURL() string {
rc.mu.RLock()
defer rc.mu.RUnlock()
- return rc._xbaq
+ return rc._yf6
}
func (rc *RuntimeContext) APIKey() string {
rc.mu.RLock()
defer rc.mu.RUnlock()
- return rc._34
+ return rc._jpwr
}
func (rc *RuntimeContext) InstanceID() string {
- return rc._tpx0
+ return rc._645
}
-func InitializeRuntime(_7j2, _bwg, _t0 string) *RuntimeContext {
- if _7j2 == "" {
- _7j2 = "evolution-go"
+func InitializeRuntime(_y6, _h7, _444 string) *RuntimeContext {
+ if _y6 == "" {
+ _y6 = "evolution-go"
}
- if _bwg == "" {
- _bwg = "unknown"
+ if _h7 == "" {
+ _h7 = "unknown"
}
rc := &RuntimeContext{
- _7j2: _7j2,
- _bwg: _bwg,
- _t0: _t0,
+ _y6: _y6,
+ _h7: _h7,
+ _444: _444,
}
- id, err := _h6vl()
+ id, err := _viat()
if err != nil {
log.Fatalf("[runtime] failed to initialize instance: %v", err)
}
- rc._tpx0 = id
+ rc._645 = id
- rd, err := _7x()
+ rd, err := _8ftv()
if err == nil && rd.APIKey != "" {
- rc._34 = rd.APIKey
+ rc._jpwr = rd.APIKey
fmt.Printf(" ✓ License found: %s...%s\n", rd.APIKey[:8], rd.APIKey[len(rd.APIKey)-4:])
- rc._tq = sha256.Sum256([]byte(rc._34 + rc._tpx0))
- rc._dcf.Store(true)
+ rc._uw = sha256.Sum256([]byte(rc._jpwr + rc._645))
+ rc._xk65.Store(true)
ActivateIntegrity(rc)
fmt.Println(" ✓ License activated successfully")
go func() {
- if err := _iljt(rc, _bwg); err != nil {
+ if err := _2a2d(rc, _h7); err != nil {
fmt.Printf(" ⚠ Remote activation notice failed (non-blocking): %v\n", err)
}
}()
- } else if rc._t0 != "" {
- rc._34 = rc._t0
- if err := _iljt(rc, _bwg); err == nil {
- _yi4m(&RuntimeData{APIKey: rc._t0, Tier: _7j2})
- rc._tq = sha256.Sum256([]byte(rc._34 + rc._tpx0))
- rc._dcf.Store(true)
+ } else if rc._444 != "" {
+ rc._jpwr = rc._444
+ if err := _2a2d(rc, _h7); err == nil {
+ _nk7y(&RuntimeData{APIKey: rc._444, Tier: _y6})
+ rc._uw = sha256.Sum256([]byte(rc._jpwr + rc._645))
+ rc._xk65.Store(true)
ActivateIntegrity(rc)
fmt.Printf(" ✓ GLOBAL_API_KEY accepted — license saved and activated\n")
} else {
- rc._34 = ""
- _v9()
- rc._dcf.Store(false)
+ rc._jpwr = ""
+ _p3()
+ rc._xk65.Store(false)
}
} else {
- _v9()
- rc._dcf.Store(false)
+ _p3()
+ rc._xk65.Store(false)
}
return rc
}
-func _v9() {
+func _p3() {
fmt.Println()
fmt.Println(" ╔══════════════════════════════════════════════════════════╗")
fmt.Println(" ║ License Registration Required ║")
@@ -480,41 +480,41 @@ func _v9() {
fmt.Println()
}
-func (rc *RuntimeContext) _cqd(authCodeOrKey, _7j2 string, customerID int) error {
- _34, err := _on(authCodeOrKey)
+func (rc *RuntimeContext) _fbk(authCodeOrKey, _y6 string, customerID int) error {
+ _jpwr, err := _kc1(authCodeOrKey)
if err != nil {
return fmt.Errorf("key exchange failed: %w", err)
}
rc.mu.Lock()
- rc._34 = _34
- rc._xbaq = ""
- rc._8w9u = ""
+ rc._jpwr = _jpwr
+ rc._yf6 = ""
+ rc._s09 = ""
rc.mu.Unlock()
- if err := _yi4m(&RuntimeData{
- APIKey: _34,
- Tier: _7j2,
+ if err := _nk7y(&RuntimeData{
+ APIKey: _jpwr,
+ Tier: _y6,
CustomerID: customerID,
}); err != nil {
fmt.Printf(" ⚠ Warning: could not save license: %v\n", err)
}
- if err := _iljt(rc, rc._bwg); err != nil {
+ if err := _2a2d(rc, rc._h7); err != nil {
return err
}
rc.mu.Lock()
- rc._tq = sha256.Sum256([]byte(rc._34 + rc._tpx0))
+ rc._uw = sha256.Sum256([]byte(rc._jpwr + rc._645))
rc.mu.Unlock()
- rc._dcf.Store(true)
+ rc._xk65.Store(true)
ActivateIntegrity(rc)
- fmt.Printf(" ✓ License activated! Key: %s...%s (_7j2: %s)\n",
- _34[:8], _34[len(_34)-4:], _7j2)
+ fmt.Printf(" ✓ License activated! Key: %s...%s (_y6: %s)\n",
+ _jpwr[:8], _jpwr[len(_jpwr)-4:], _y6)
go func() {
- if err := _727r(rc, 0); err != nil {
+ if err := _b1h(rc, 0); err != nil {
fmt.Printf(" ⚠ First heartbeat failed: %v\n", err)
}
}()
@@ -526,10 +526,10 @@ func ValidateContext(rc *RuntimeContext) (bool, string) {
if rc == nil {
return false, ""
}
- if !rc._dcf.Load() {
+ if !rc._xk65.Load() {
return false, rc.RegistrationURL()
}
- expected := sha256.Sum256([]byte(rc._34 + rc._tpx0))
+ expected := sha256.Sum256([]byte(rc._jpwr + rc._645))
actual := rc.ContextHash()
if expected != actual {
return false, ""
@@ -586,12 +586,12 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
resp := gin.H{
"status": status,
- "instance_id": rc._tpx0,
+ "instance_id": rc._645,
}
rc.mu.RLock()
- if rc._34 != "" {
- resp["api_key"] = rc._34[:8] + "..." + rc._34[len(rc._34)-4:]
+ if rc._jpwr != "" {
+ resp["api_key"] = rc._jpwr[:8] + "..." + rc._jpwr[len(rc._jpwr)-4:]
}
rc.mu.RUnlock()
@@ -608,7 +608,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
}
rc.mu.RLock()
- existingURL := rc._xbaq
+ existingURL := rc._yf6
rc.mu.RUnlock()
if existingURL != "" {
@@ -620,15 +620,15 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
}
payload := map[string]string{
- "tier": rc._7j2,
- "version": rc._bwg,
- "instance_id": rc._tpx0,
+ "tier": rc._y6,
+ "version": rc._h7,
+ "instance_id": rc._645,
}
if redirectURI := c.Query("redirect_uri"); redirectURI != "" {
payload["redirect_uri"] = redirectURI
}
- resp, err := _i0("/v1/register/init", payload)
+ resp, err := _pzi6("/v1/register/init", payload)
if err != nil {
c.JSON(http.StatusBadGateway, gin.H{
"error": "Failed to contact licensing server",
@@ -639,30 +639,30 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
- _286 := _lo(resp)
+ _28 := _2l4(resp)
c.JSON(resp.StatusCode, gin.H{
"error": "Licensing server error",
- "details": _286.Error(),
+ "details": _28.Error(),
})
return
}
- var _0ijb struct {
+ var _fy4y struct {
RegisterURL string `json:"register_url"`
Token string `json:"token"`
}
- json.NewDecoder(resp.Body).Decode(&_0ijb)
+ json.NewDecoder(resp.Body).Decode(&_fy4y)
rc.mu.Lock()
- rc._xbaq = _0ijb.RegisterURL
- rc._8w9u = _0ijb.Token
+ rc._yf6 = _fy4y.RegisterURL
+ rc._s09 = _fy4y.Token
rc.mu.Unlock()
- fmt.Printf(" → Registration URL: %s\n", _0ijb.RegisterURL)
+ fmt.Printf(" → Registration URL: %s\n", _fy4y.RegisterURL)
c.JSON(http.StatusOK, gin.H{
"status": "pending",
- "register_url": _0ijb.RegisterURL,
+ "register_url": _fy4y.RegisterURL,
})
})
@@ -684,9 +684,9 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
return
}
- exchangeResp, err := _i0("/v1/register/exchange", map[string]string{
+ exchangeResp, err := _pzi6("/v1/register/exchange", map[string]string{
"authorization_code": code,
- "instance_id": rc._tpx0,
+ "instance_id": rc._645,
})
if err != nil {
c.JSON(http.StatusBadGateway, gin.H{
@@ -698,22 +698,22 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
defer exchangeResp.Body.Close()
if exchangeResp.StatusCode != http.StatusOK {
- _286 := _lo(exchangeResp)
+ _28 := _2l4(exchangeResp)
c.JSON(exchangeResp.StatusCode, gin.H{
"error": "Exchange failed",
- "details": _286.Error(),
+ "details": _28.Error(),
})
return
}
- var _78g struct {
+ var _x1 struct {
APIKey string `json:"api_key"`
Tier string `json:"tier"`
CustomerID int `json:"customer_id"`
}
- json.NewDecoder(exchangeResp.Body).Decode(&_78g)
+ json.NewDecoder(exchangeResp.Body).Decode(&_x1)
- if _78g.APIKey == "" {
+ if _x1.APIKey == "" {
c.JSON(http.StatusBadRequest, gin.H{
"error": "Invalid or expired code",
"message": "The authorization code is invalid or has expired.",
@@ -721,7 +721,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
return
}
- if err := rc._cqd(_78g.APIKey, _78g.Tier, _78g.CustomerID); err != nil {
+ if err := rc._fbk(_x1.APIKey, _x1.Tier, _x1.CustomerID); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"error": "Activation failed",
"details": err.Error(),
@@ -751,7 +751,7 @@ func StartHeartbeat(ctx context.Context, rc *RuntimeContext, startTime time.Time
continue
}
uptime := int64(time.Since(startTime).Seconds())
- if err := _727r(rc, uptime); err != nil {
+ if err := _b1h(rc, uptime); err != nil {
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) {
- if rc == nil || rc._34 == "" {
+ if rc == nil || rc._jpwr == "" {
return
}
- _4dua(rc)
+ _uht(rc)
}
-func _gxkr(code string) (_34 string, err error) {
- resp, err := _i0("/v1/register/exchange", map[string]string{
+func _kms(code string) (_jpwr string, err error) {
+ resp, err := _pzi6("/v1/register/exchange", map[string]string{
"authorization_code": code,
})
if err != nil {
@@ -776,84 +776,84 @@ func _gxkr(code string) (_34 string, err error) {
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
- return "", _lo(resp)
+ return "", _2l4(resp)
}
- var _78g struct {
+ var _x1 struct {
APIKey string `json:"api_key"`
}
- json.NewDecoder(resp.Body).Decode(&_78g)
- if _78g.APIKey == "" {
+ json.NewDecoder(resp.Body).Decode(&_x1)
+ if _x1.APIKey == "" {
return "", fmt.Errorf("exchange returned empty api_key")
}
- return _78g.APIKey, nil
+ return _x1.APIKey, nil
}
-func _on(authCodeOrKey string) (string, error) {
- _34, err := _gxkr(authCodeOrKey)
- if err == nil && _34 != "" {
- return _34, nil
+func _kc1(authCodeOrKey string) (string, error) {
+ _jpwr, err := _kms(authCodeOrKey)
+ if err == nil && _jpwr != "" {
+ return _jpwr, nil
}
return authCodeOrKey, nil
}
-func _iljt(rc *RuntimeContext, _bwg string) error {
- resp, err := _cr("/v1/activate", map[string]string{
- "instance_id": rc._tpx0,
- "version": _bwg,
- }, rc._34)
+func _2a2d(rc *RuntimeContext, _h7 string) error {
+ resp, err := _rkb("/v1/activate", map[string]string{
+ "instance_id": rc._645,
+ "version": _h7,
+ }, rc._jpwr)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
- return _lo(resp)
+ return _2l4(resp)
}
- var _78g struct {
+ var _x1 struct {
Status string `json:"status"`
}
- json.NewDecoder(resp.Body).Decode(&_78g)
+ json.NewDecoder(resp.Body).Decode(&_x1)
- if _78g.Status != "active" {
- return fmt.Errorf("activation returned status: %s", _78g.Status)
+ if _x1.Status != "active" {
+ return fmt.Errorf("activation returned status: %s", _x1.Status)
}
return nil
}
-func _727r(rc *RuntimeContext, uptimeSeconds int64) error {
- resp, err := _cr("/v1/heartbeat", map[string]any{
- "instance_id": rc._tpx0,
+func _b1h(rc *RuntimeContext, uptimeSeconds int64) error {
+ resp, err := _rkb("/v1/heartbeat", map[string]any{
+ "instance_id": rc._645,
"uptime_seconds": uptimeSeconds,
- "version": rc._bwg,
- }, rc._34)
+ "version": rc._h7,
+ }, rc._jpwr)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
- return _lo(resp)
+ return _2l4(resp)
}
return nil
}
-func _4dua(rc *RuntimeContext) {
+func _uht(rc *RuntimeContext) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
body, _ := json.Marshal(map[string]string{
- "instance_id": rc._tpx0,
+ "instance_id": rc._645,
})
- url := _53() + "/v1/deactivate"
+ url := _rmo() + "/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._34)
- req.Header.Set("X-Signature", _h33h(body, rc._34))
- _wof6.Do(req)
+ req.Header.Set("X-Api-Key", rc._jpwr)
+ req.Header.Set("X-Signature", _t5d(body, rc._jpwr))
+ _ls61.Do(req)
}