sync: 0.6.1 from main (165801be5912844fe0cdeb598c386751d3cf15c3)
This commit is contained in:
1 parent
877eef7f07
commit
e0613fbeb0
10 files changed
+348
-280
No files matched your search
+214
-213
@@ -24,14 +24,17 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var _k1 = []byte{0xe8, 0x1d, 0x6b, 0x81, 0x27, 0xa5, 0x5e, 0x63, 0x7a, 0xfd, 0xa7, 0x47, 0x6b, 0x9c, 0xde, 0xa0, 0xa0, 0x05, 0xe9, 0x8f, 0x58, 0x17, 0xac, 0x43, 0xcd, 0xb4, 0x35, 0x97, 0x02, 0x10, 0x27, 0x55, 0x1c, 0x28, 0x58, 0x4b, 0x0d, 0x24, 0x64, 0x60, 0x7e, 0x2a}
|
||||
var _k0 = []byte{0x80, 0x69, 0x1f, 0xf1, 0x54, 0x9f, 0x71, 0x4c, 0x16, 0x94, 0xc4, 0x22, 0x05, 0xef, 0xbb, 0x8e, 0xc5, 0x73, 0x86, 0xe3, 0x2d, 0x63, 0xc5, 0x2c, 0xa3, 0xd2, 0x5a, 0xe2, 0x6c, 0x74, 0x46, 0x21, 0x75, 0x47, 0x36, 0x65, 0x6e, 0x4b, 0x09, 0x4e, 0x1c, 0x58}
|
||||
|
||||
var (
|
||||
encodedEP string
|
||||
xorKey string
|
||||
_83 string
|
||||
_xazo string
|
||||
)
|
||||
|
||||
func _d0() string {
|
||||
if encodedEP != "" && xorKey != "" {
|
||||
return decodeXOR(encodedEP, xorKey)
|
||||
func _40hs() string {
|
||||
if _83 != "" && _xazo != "" {
|
||||
return _zh(_83, _xazo)
|
||||
}
|
||||
parts := [...]string{"h", "tt", "ps", "://", "li", "ce", "nse", ".", "ev", "ol", "ut", "io", "nf", "ou", "nd", "at", "io", "n.", "co", "m.", "br"}
|
||||
var s string
|
||||
@@ -41,9 +44,9 @@ func _d0() string {
|
||||
return s
|
||||
}
|
||||
|
||||
func decodeXOR(enc, key string) string {
|
||||
encBytes := hexDec(enc)
|
||||
keyBytes := hexDec(key)
|
||||
func _zh(enc, key string) string {
|
||||
encBytes := _5b7(enc)
|
||||
keyBytes := _5b7(key)
|
||||
if len(keyBytes) == 0 {
|
||||
return ""
|
||||
}
|
||||
@@ -54,18 +57,18 @@ func decodeXOR(enc, key string) string {
|
||||
return string(out)
|
||||
}
|
||||
|
||||
func hexDec(s string) []byte {
|
||||
func _5b7(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] = hexVal(s[i])<<4 | hexVal(s[i+1])
|
||||
b[i/2] = _vtc(s[i])<<4 | _vtc(s[i+1])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func hexVal(c byte) byte {
|
||||
func _vtc(c byte) byte {
|
||||
switch {
|
||||
case c >= '0' && c <= '9':
|
||||
return c - '0'
|
||||
@@ -77,62 +80,62 @@ func hexVal(c byte) byte {
|
||||
return 0
|
||||
}
|
||||
|
||||
var _h0 = &http.Client{Timeout: 10 * time.Second}
|
||||
var _ml9 = &http.Client{Timeout: 10 * time.Second}
|
||||
|
||||
func _sg(body []byte, secret string) string {
|
||||
func _pq(body []byte, secret string) string {
|
||||
mac := hmac.New(sha256.New, []byte(secret))
|
||||
mac.Write(body)
|
||||
return hex.EncodeToString(mac.Sum(nil))
|
||||
}
|
||||
|
||||
func _ps(path string, payload interface{}, _a0 string) (*http.Response, error) {
|
||||
func _c14s(path string, payload interface{}, _d1e9 string) (*http.Response, error) {
|
||||
body, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := _d0() + path
|
||||
url := _40hs() + 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", _a0)
|
||||
req.Header.Set("X-Signature", _sg(body, _a0))
|
||||
req.Header.Set("X-Api-Key", _d1e9)
|
||||
req.Header.Set("X-Signature", _pq(body, _d1e9))
|
||||
|
||||
return _h0.Do(req)
|
||||
return _ml9.Do(req)
|
||||
}
|
||||
|
||||
func _gu(path string) (*http.Response, error) {
|
||||
url := _d0() + path
|
||||
return _h0.Get(url)
|
||||
func _46(path string) (*http.Response, error) {
|
||||
url := _40hs() + path
|
||||
return _ml9.Get(url)
|
||||
}
|
||||
|
||||
func _pu(path string, payload interface{}) (*http.Response, error) {
|
||||
func _0r(path string, payload interface{}) (*http.Response, error) {
|
||||
body, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := _d0() + path
|
||||
url := _40hs() + 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 _h0.Do(req)
|
||||
return _ml9.Do(req)
|
||||
}
|
||||
|
||||
func _re(resp *http.Response) error {
|
||||
func _36l2(resp *http.Response) error {
|
||||
b, _ := io.ReadAll(resp.Body)
|
||||
var errBody struct {
|
||||
var _f3mf struct {
|
||||
Message string `json:"message"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
if err := json.Unmarshal(b, &errBody); err == nil {
|
||||
msg := errBody.Message
|
||||
if err := json.Unmarshal(b, &_f3mf); err == nil {
|
||||
msg := _f3mf.Message
|
||||
if msg == "" {
|
||||
msg = errBody.Error
|
||||
msg = _f3mf.Error
|
||||
}
|
||||
if msg != "" {
|
||||
return fmt.Errorf("%s (HTTP %d)", strings.ToLower(msg), resp.StatusCode)
|
||||
@@ -154,123 +157,123 @@ func (RuntimeConfig) TableName() string {
|
||||
}
|
||||
|
||||
const (
|
||||
_ck0 = "instance_id"
|
||||
_ck1 = "api_key"
|
||||
_ck2 = "_a7"
|
||||
_ck3 = "customer_id"
|
||||
ConfigKeyInstanceID = "instance_id"
|
||||
ConfigKeyAPIKey = "api_key"
|
||||
ConfigKeyTier = "_i7xh"
|
||||
ConfigKeyCustomerID = "customer_id"
|
||||
)
|
||||
|
||||
var _db0 *gorm.DB
|
||||
var _to *gorm.DB
|
||||
|
||||
func SetDB(db *gorm.DB) {
|
||||
_db0 = db
|
||||
_to = db
|
||||
}
|
||||
|
||||
func MigrateDB() error {
|
||||
if _db0 == nil {
|
||||
if _to == nil {
|
||||
return fmt.Errorf("core: database not set, call SetDB first")
|
||||
}
|
||||
return _db0.AutoMigrate(&RuntimeConfig{})
|
||||
return _to.AutoMigrate(&RuntimeConfig{})
|
||||
}
|
||||
|
||||
func _gc(key string) (string, error) {
|
||||
if _db0 == nil {
|
||||
func _o07s(key string) (string, error) {
|
||||
if _to == nil {
|
||||
return "", fmt.Errorf("core: database not set")
|
||||
}
|
||||
var cfg RuntimeConfig
|
||||
result := _db0.Where("key = ?", key).First(&cfg)
|
||||
if result.Error != nil {
|
||||
return "", result.Error
|
||||
var _4k RuntimeConfig
|
||||
_2q := _to.Where("key = ?", key).First(&_4k)
|
||||
if _2q.Error != nil {
|
||||
return "", _2q.Error
|
||||
}
|
||||
return cfg.Value, nil
|
||||
return _4k.Value, nil
|
||||
}
|
||||
|
||||
func _sc(key, value string) error {
|
||||
if _db0 == nil {
|
||||
func _y7(key, value string) error {
|
||||
if _to == nil {
|
||||
return fmt.Errorf("core: database not set")
|
||||
}
|
||||
var cfg RuntimeConfig
|
||||
result := _db0.Where("key = ?", key).First(&cfg)
|
||||
if result.Error != nil {
|
||||
return _db0.Create(&RuntimeConfig{Key: key, Value: value}).Error
|
||||
var _4k RuntimeConfig
|
||||
_2q := _to.Where("key = ?", key).First(&_4k)
|
||||
if _2q.Error != nil {
|
||||
return _to.Create(&RuntimeConfig{Key: key, Value: value}).Error
|
||||
}
|
||||
return _db0.Model(&cfg).Update("value", value).Error
|
||||
return _to.Model(&_4k).Update("value", value).Error
|
||||
}
|
||||
|
||||
func _dc(key string) {
|
||||
if _db0 == nil {
|
||||
func _4k5p(key string) {
|
||||
if _to == nil {
|
||||
return
|
||||
}
|
||||
_db0.Where("key = ?", key).Delete(&RuntimeConfig{})
|
||||
_to.Where("key = ?", key).Delete(&RuntimeConfig{})
|
||||
}
|
||||
|
||||
type _rtd struct {
|
||||
type RuntimeData struct {
|
||||
APIKey string
|
||||
Tier string
|
||||
CustomerID int
|
||||
}
|
||||
|
||||
func _lrd() (*_rtd, error) {
|
||||
_a0, err := _gc(_ck1)
|
||||
if err != nil || _a0 == "" {
|
||||
func _rjz7() (*RuntimeData, error) {
|
||||
_d1e9, err := _o07s(ConfigKeyAPIKey)
|
||||
if err != nil || _d1e9 == "" {
|
||||
return nil, fmt.Errorf("no license found")
|
||||
}
|
||||
|
||||
_a7, _ := _gc(_ck2)
|
||||
customerIDStr, _ := _gc(_ck3)
|
||||
_i7xh, _ := _o07s(ConfigKeyTier)
|
||||
customerIDStr, _ := _o07s(ConfigKeyCustomerID)
|
||||
customerID, _ := strconv.Atoi(customerIDStr)
|
||||
|
||||
return &_rtd{
|
||||
APIKey: _a0,
|
||||
Tier: _a7,
|
||||
return &RuntimeData{
|
||||
APIKey: _d1e9,
|
||||
Tier: _i7xh,
|
||||
CustomerID: customerID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func _srd(rd *_rtd) error {
|
||||
if err := _sc(_ck1, rd.APIKey); err != nil {
|
||||
func _pi(rd *RuntimeData) error {
|
||||
if err := _y7(ConfigKeyAPIKey, rd.APIKey); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := _sc(_ck2, rd.Tier); err != nil {
|
||||
if err := _y7(ConfigKeyTier, rd.Tier); err != nil {
|
||||
return err
|
||||
}
|
||||
if rd.CustomerID > 0 {
|
||||
if err := _sc(_ck3, strconv.Itoa(rd.CustomerID)); err != nil {
|
||||
if err := _y7(ConfigKeyCustomerID, strconv.Itoa(rd.CustomerID)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func _rrd() {
|
||||
_dc(_ck1)
|
||||
_dc(_ck2)
|
||||
_dc(_ck3)
|
||||
func _jul3() {
|
||||
_4k5p(ConfigKeyAPIKey)
|
||||
_4k5p(ConfigKeyTier)
|
||||
_4k5p(ConfigKeyCustomerID)
|
||||
}
|
||||
|
||||
func _lid() (string, error) {
|
||||
id, err := _gc(_ck0)
|
||||
func _sj() (string, error) {
|
||||
id, err := _o07s(ConfigKeyInstanceID)
|
||||
if err == nil && len(id) == 36 {
|
||||
return id, nil
|
||||
}
|
||||
|
||||
id = _ghi()
|
||||
id = _g1()
|
||||
if id == "" {
|
||||
id, err = _uuid()
|
||||
id, err = _bmj4()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
if err := _sc(_ck0, id); err != nil {
|
||||
if err := _y7(ConfigKeyInstanceID, id); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func _ghi() string {
|
||||
func _g1() string {
|
||||
hostname, _ := os.Hostname()
|
||||
macAddr := _gpm()
|
||||
macAddr := _3yc()
|
||||
if hostname == "" && macAddr == "" {
|
||||
return ""
|
||||
}
|
||||
@@ -281,13 +284,13 @@ func _ghi() string {
|
||||
for i := 16; i < len(seed); i++ {
|
||||
h[i%16] ^= seed[i]
|
||||
}
|
||||
h[6] = (h[6] & 0x0f) | 0x40 // _a8 4
|
||||
h[6] = (h[6] & 0x0f) | 0x40 // _1s8g 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 _gpm() string {
|
||||
func _3yc() string {
|
||||
interfaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
return ""
|
||||
@@ -303,7 +306,7 @@ func _gpm() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func _uuid() (string, error) {
|
||||
func _bmj4() (string, error) {
|
||||
var b [16]byte
|
||||
if _, err := rand.Read(b[:]); err != nil {
|
||||
return "", err
|
||||
@@ -314,21 +317,20 @@ func _uuid() (string, error) {
|
||||
b[0:4], b[4:6], b[6:8], b[8:10], b[10:16]), nil
|
||||
}
|
||||
|
||||
|
||||
var _s0 atomic.Value // set during activation
|
||||
var _5m atomic.Value // set during activation
|
||||
|
||||
func init() {
|
||||
_s0.Store([]byte{0})
|
||||
_5m.Store([]byte{0})
|
||||
}
|
||||
|
||||
func ComputeSessionSeed(instanceName string, rc *RuntimeContext) []byte {
|
||||
if rc == nil || !rc._a2.Load() {
|
||||
if rc == nil || !rc._oq5.Load() {
|
||||
return nil // Will cause panic in caller — intentional
|
||||
}
|
||||
h := sha256.New()
|
||||
h.Write([]byte(instanceName))
|
||||
h.Write([]byte(rc._a0))
|
||||
salt, _ := _s0.Load().([]byte)
|
||||
h.Write([]byte(rc._d1e9))
|
||||
salt, _ := _5m.Load().([]byte)
|
||||
h.Write(salt)
|
||||
return h.Sum(nil)[:16]
|
||||
}
|
||||
@@ -341,20 +343,20 @@ func ValidateRouteAccess(rc *RuntimeContext) uint64 {
|
||||
return binary.LittleEndian.Uint64(h[:8])
|
||||
}
|
||||
|
||||
func DeriveInstanceToken(_a1 string, rc *RuntimeContext) string {
|
||||
if rc == nil || !rc._a2.Load() {
|
||||
func DeriveInstanceToken(_gj string, rc *RuntimeContext) string {
|
||||
if rc == nil || !rc._oq5.Load() {
|
||||
return ""
|
||||
}
|
||||
h := sha256.Sum256([]byte(_a1 + rc._a0))
|
||||
return _he(h[:8])
|
||||
h := sha256.Sum256([]byte(_gj + rc._d1e9))
|
||||
return _tuvw(h[:8])
|
||||
}
|
||||
|
||||
func _he(b []byte) string {
|
||||
const hextable = "0123456789abcdef"
|
||||
func _tuvw(b []byte) string {
|
||||
const _s53 = "0123456789abcdef"
|
||||
dst := make([]byte, len(b)*2)
|
||||
for i, v := range b {
|
||||
dst[i*2] = hextable[v>>4]
|
||||
dst[i*2+1] = hextable[v&0x0f]
|
||||
dst[i*2] = _s53[v>>4]
|
||||
dst[i*2+1] = _s53[v&0x0f]
|
||||
}
|
||||
return string(dst)
|
||||
}
|
||||
@@ -363,85 +365,85 @@ func ActivateIntegrity(rc *RuntimeContext) {
|
||||
if rc == nil {
|
||||
return
|
||||
}
|
||||
h := sha256.Sum256([]byte(rc._a0 + rc._a1 + "ev0"))
|
||||
_s0.Store(h[:])
|
||||
h := sha256.Sum256([]byte(rc._d1e9 + rc._gj + "ev0"))
|
||||
_5m.Store(h[:])
|
||||
}
|
||||
|
||||
const (
|
||||
_p2 = 30 * time.Minute
|
||||
hbInterval = 30 * time.Minute
|
||||
)
|
||||
|
||||
type RuntimeContext struct {
|
||||
_a0 string
|
||||
_a9 string // GLOBAL_API_KEY from .env — used as token for licensing check
|
||||
_a1 string
|
||||
_a2 atomic.Bool
|
||||
_a3 [32]byte // Derived from activation — required by ValidateContext
|
||||
_d1e9 string
|
||||
_96f2 string // GLOBAL_API_KEY from .env — used as token for licensing check
|
||||
_gj string
|
||||
_oq5 atomic.Bool
|
||||
_z1uh [32]byte // Derived from activation — required by ValidateContext
|
||||
mu sync.RWMutex
|
||||
_a5 string // Registration URL shown to users before activation
|
||||
_a6 string // Registration token for polling
|
||||
_a7 string
|
||||
_a8 string
|
||||
_34r string // Registration URL shown to users before activation
|
||||
_8344 string // Registration token for polling
|
||||
_i7xh string
|
||||
_1s8g string
|
||||
}
|
||||
|
||||
func (rc *RuntimeContext) ContextHash() [32]byte {
|
||||
rc.mu.RLock()
|
||||
defer rc.mu.RUnlock()
|
||||
return rc._a3
|
||||
return rc._z1uh
|
||||
}
|
||||
|
||||
func (rc *RuntimeContext) IsActive() bool {
|
||||
return rc._a2.Load()
|
||||
return rc._oq5.Load()
|
||||
}
|
||||
|
||||
func (rc *RuntimeContext) RegistrationURL() string {
|
||||
rc.mu.RLock()
|
||||
defer rc.mu.RUnlock()
|
||||
return rc._a5
|
||||
return rc._34r
|
||||
}
|
||||
|
||||
func (rc *RuntimeContext) APIKey() string {
|
||||
rc.mu.RLock()
|
||||
defer rc.mu.RUnlock()
|
||||
return rc._a0
|
||||
return rc._d1e9
|
||||
}
|
||||
|
||||
func (rc *RuntimeContext) InstanceID() string {
|
||||
return rc._a1
|
||||
return rc._gj
|
||||
}
|
||||
|
||||
func InitializeRuntime(_a7, _a8, _a9 string) *RuntimeContext {
|
||||
if _a7 == "" {
|
||||
_a7 = "evolution-go"
|
||||
func InitializeRuntime(_i7xh, _1s8g, _96f2 string) *RuntimeContext {
|
||||
if _i7xh == "" {
|
||||
_i7xh = "evolution-go"
|
||||
}
|
||||
if _a8 == "" {
|
||||
_a8 = "unknown"
|
||||
if _1s8g == "" {
|
||||
_1s8g = "unknown"
|
||||
}
|
||||
|
||||
rc := &RuntimeContext{
|
||||
_a7: _a7,
|
||||
_a8: _a8,
|
||||
_a9: _a9,
|
||||
_i7xh: _i7xh,
|
||||
_1s8g: _1s8g,
|
||||
_96f2: _96f2,
|
||||
}
|
||||
|
||||
id, err := _lid()
|
||||
id, err := _sj()
|
||||
if err != nil {
|
||||
log.Fatalf("[runtime] failed to initialize instance: %v", err)
|
||||
}
|
||||
rc._a1 = id
|
||||
rc._gj = id
|
||||
|
||||
rd, err := _lrd()
|
||||
rd, err := _rjz7()
|
||||
if err == nil && rd.APIKey != "" {
|
||||
rc._a0 = rd.APIKey
|
||||
rc._d1e9 = rd.APIKey
|
||||
fmt.Printf(" ✓ License found: %s...%s\n", rd.APIKey[:8], rd.APIKey[len(rd.APIKey)-4:])
|
||||
|
||||
rc._a3 = sha256.Sum256([]byte(rc._a0 + rc._a1))
|
||||
rc._a2.Store(true)
|
||||
rc._z1uh = sha256.Sum256([]byte(rc._d1e9 + rc._gj))
|
||||
rc._oq5.Store(true)
|
||||
ActivateIntegrity(rc)
|
||||
fmt.Println(" ✓ License activated successfully")
|
||||
|
||||
go func() {
|
||||
if err := _ai(rc, _a8); err != nil {
|
||||
if err := _5tmd(rc, _1s8g); err != nil {
|
||||
fmt.Printf(" ⚠ Remote activation notice failed (non-blocking): %v\n", err)
|
||||
}
|
||||
}()
|
||||
@@ -455,47 +457,47 @@ func InitializeRuntime(_a7, _a8, _a9 string) *RuntimeContext {
|
||||
fmt.Println(" API endpoints will return 503 until license is activated.")
|
||||
fmt.Println(" Use GET /license/register to get the registration URL.")
|
||||
fmt.Println()
|
||||
rc._a2.Store(false)
|
||||
rc._oq5.Store(false)
|
||||
}
|
||||
|
||||
return rc
|
||||
}
|
||||
|
||||
func (rc *RuntimeContext) _ca(authCodeOrKey, _a7 string, customerID int) error {
|
||||
_a0, err := _rk(authCodeOrKey)
|
||||
func (rc *RuntimeContext) _2r(authCodeOrKey, _i7xh string, customerID int) error {
|
||||
_d1e9, err := _rbx(authCodeOrKey)
|
||||
if err != nil {
|
||||
return fmt.Errorf("key exchange failed: %w", err)
|
||||
}
|
||||
|
||||
rc.mu.Lock()
|
||||
rc._a0 = _a0
|
||||
rc._a5 = ""
|
||||
rc._a6 = ""
|
||||
rc._d1e9 = _d1e9
|
||||
rc._34r = ""
|
||||
rc._8344 = ""
|
||||
rc.mu.Unlock()
|
||||
|
||||
if err := _srd(&_rtd{
|
||||
APIKey: _a0,
|
||||
Tier: _a7,
|
||||
if err := _pi(&RuntimeData{
|
||||
APIKey: _d1e9,
|
||||
Tier: _i7xh,
|
||||
CustomerID: customerID,
|
||||
}); err != nil {
|
||||
fmt.Printf(" ⚠ Warning: could not save license: %v\n", err)
|
||||
}
|
||||
|
||||
if err := _ai(rc, rc._a8); err != nil {
|
||||
if err := _5tmd(rc, rc._1s8g); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rc.mu.Lock()
|
||||
rc._a3 = sha256.Sum256([]byte(rc._a0 + rc._a1))
|
||||
rc._z1uh = sha256.Sum256([]byte(rc._d1e9 + rc._gj))
|
||||
rc.mu.Unlock()
|
||||
rc._a2.Store(true)
|
||||
rc._oq5.Store(true)
|
||||
ActivateIntegrity(rc)
|
||||
|
||||
fmt.Printf(" ✓ License activated! Key: %s...%s (_a7: %s)\n",
|
||||
_a0[:8], _a0[len(_a0)-4:], _a7)
|
||||
fmt.Printf(" ✓ License activated! Key: %s...%s (_i7xh: %s)\n",
|
||||
_d1e9[:8], _d1e9[len(_d1e9)-4:], _i7xh)
|
||||
|
||||
go func() {
|
||||
if err := _hb(rc, 0); err != nil {
|
||||
if err := _yry(rc, 0); err != nil {
|
||||
fmt.Printf(" ⚠ First heartbeat failed: %v\n", err)
|
||||
}
|
||||
}()
|
||||
@@ -507,10 +509,10 @@ func ValidateContext(rc *RuntimeContext) (bool, string) {
|
||||
if rc == nil {
|
||||
return false, ""
|
||||
}
|
||||
if !rc._a2.Load() {
|
||||
if !rc._oq5.Load() {
|
||||
return false, rc.RegistrationURL()
|
||||
}
|
||||
expected := sha256.Sum256([]byte(rc._a0 + rc._a1))
|
||||
expected := sha256.Sum256([]byte(rc._d1e9 + rc._gj))
|
||||
actual := rc.ContextHash()
|
||||
if expected != actual {
|
||||
return false, ""
|
||||
@@ -558,17 +560,17 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
||||
lic.GET("/status", func(c *gin.Context) {
|
||||
status := "inactive"
|
||||
if rc.IsActive() {
|
||||
status = "_a2"
|
||||
status = "_oq5"
|
||||
}
|
||||
|
||||
resp := gin.H{
|
||||
"status": status,
|
||||
"instance_id": rc._a1,
|
||||
"instance_id": rc._gj,
|
||||
}
|
||||
|
||||
rc.mu.RLock()
|
||||
if rc._a0 != "" {
|
||||
resp["api_key"] = rc._a0[:8] + "..." + rc._a0[len(rc._a0)-4:]
|
||||
if rc._d1e9 != "" {
|
||||
resp["api_key"] = rc._d1e9[:8] + "..." + rc._d1e9[len(rc._d1e9)-4:]
|
||||
}
|
||||
rc.mu.RUnlock()
|
||||
|
||||
@@ -578,14 +580,14 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
||||
lic.GET("/register", func(c *gin.Context) {
|
||||
if rc.IsActive() {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "_a2",
|
||||
"message": "License is already _a2",
|
||||
"status": "_oq5",
|
||||
"message": "License is already _oq5",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
rc.mu.RLock()
|
||||
existingURL := rc._a5
|
||||
existingURL := rc._34r
|
||||
rc.mu.RUnlock()
|
||||
|
||||
if existingURL != "" {
|
||||
@@ -597,15 +599,15 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
||||
}
|
||||
|
||||
payload := map[string]string{
|
||||
"_a7": rc._a7,
|
||||
"_a8": rc._a8,
|
||||
"instance_id": rc._a1,
|
||||
"_i7xh": rc._i7xh,
|
||||
"_1s8g": rc._1s8g,
|
||||
"instance_id": rc._gj,
|
||||
}
|
||||
if redirectURI := c.Query("redirect_uri"); redirectURI != "" {
|
||||
payload["redirect_uri"] = redirectURI
|
||||
}
|
||||
|
||||
resp, err := _pu("/v1/register/init", payload)
|
||||
resp, err := _0r("/v1/register/init", payload)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadGateway, gin.H{
|
||||
"error": "Failed to contact licensing server",
|
||||
@@ -616,38 +618,38 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
errBody := _re(resp)
|
||||
_f3mf := _36l2(resp)
|
||||
c.JSON(resp.StatusCode, gin.H{
|
||||
"error": "Licensing server error",
|
||||
"details": errBody.Error(),
|
||||
"details": _f3mf.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var initResult struct {
|
||||
var _0rb struct {
|
||||
RegisterURL string `json:"register_url"`
|
||||
Token string `json:"token"`
|
||||
}
|
||||
json.NewDecoder(resp.Body).Decode(&initResult)
|
||||
json.NewDecoder(resp.Body).Decode(&_0rb)
|
||||
|
||||
rc.mu.Lock()
|
||||
rc._a5 = initResult.RegisterURL
|
||||
rc._a6 = initResult.Token
|
||||
rc._34r = _0rb.RegisterURL
|
||||
rc._8344 = _0rb.Token
|
||||
rc.mu.Unlock()
|
||||
|
||||
fmt.Printf(" → Registration URL: %s\n", initResult.RegisterURL)
|
||||
fmt.Printf(" → Registration URL: %s\n", _0rb.RegisterURL)
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "pending",
|
||||
"register_url": initResult.RegisterURL,
|
||||
"register_url": _0rb.RegisterURL,
|
||||
})
|
||||
})
|
||||
|
||||
lic.GET("/activate", func(c *gin.Context) {
|
||||
if rc.IsActive() {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "_a2",
|
||||
"message": "License is already _a2",
|
||||
"status": "_oq5",
|
||||
"message": "License is already _oq5",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -661,9 +663,9 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
||||
return
|
||||
}
|
||||
|
||||
exchangeResp, err := _pu("/v1/register/exchange", map[string]string{
|
||||
exchangeResp, err := _0r("/v1/register/exchange", map[string]string{
|
||||
"authorization_code": code,
|
||||
"instance_id": rc._a1,
|
||||
"instance_id": rc._gj,
|
||||
})
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadGateway, gin.H{
|
||||
@@ -675,22 +677,22 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
||||
defer exchangeResp.Body.Close()
|
||||
|
||||
if exchangeResp.StatusCode != http.StatusOK {
|
||||
errBody := _re(exchangeResp)
|
||||
_f3mf := _36l2(exchangeResp)
|
||||
c.JSON(exchangeResp.StatusCode, gin.H{
|
||||
"error": "Exchange failed",
|
||||
"details": errBody.Error(),
|
||||
"details": _f3mf.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var result struct {
|
||||
var _2q struct {
|
||||
APIKey string `json:"api_key"`
|
||||
Tier string `json:"_a7"`
|
||||
Tier string `json:"_i7xh"`
|
||||
CustomerID int `json:"customer_id"`
|
||||
}
|
||||
json.NewDecoder(exchangeResp.Body).Decode(&result)
|
||||
json.NewDecoder(exchangeResp.Body).Decode(&_2q)
|
||||
|
||||
if result.APIKey == "" {
|
||||
if _2q.APIKey == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"error": "Invalid or expired code",
|
||||
"message": "The authorization code is invalid or has expired.",
|
||||
@@ -698,7 +700,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := rc._ca(result.APIKey, result.Tier, result.CustomerID); err != nil {
|
||||
if err := rc._2r(_2q.APIKey, _2q.Tier, _2q.CustomerID); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": "Activation failed",
|
||||
"details": err.Error(),
|
||||
@@ -707,7 +709,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "_a2",
|
||||
"status": "_oq5",
|
||||
"message": "License activated successfully!",
|
||||
})
|
||||
})
|
||||
@@ -716,7 +718,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
|
||||
|
||||
func StartHeartbeat(ctx context.Context, rc *RuntimeContext, startTime time.Time) {
|
||||
go func() {
|
||||
ticker := time.NewTicker(_p2)
|
||||
ticker := time.NewTicker(hbInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
@@ -728,7 +730,7 @@ func StartHeartbeat(ctx context.Context, rc *RuntimeContext, startTime time.Time
|
||||
continue
|
||||
}
|
||||
uptime := int64(time.Since(startTime).Seconds())
|
||||
if err := _hb(rc, uptime); err != nil {
|
||||
if err := _yry(rc, uptime); err != nil {
|
||||
fmt.Printf(" ⚠ Heartbeat failed (non-blocking): %v\n", err)
|
||||
}
|
||||
}
|
||||
@@ -737,15 +739,14 @@ func StartHeartbeat(ctx context.Context, rc *RuntimeContext, startTime time.Time
|
||||
}
|
||||
|
||||
func Shutdown(rc *RuntimeContext) {
|
||||
if rc == nil || rc._a0 == "" {
|
||||
if rc == nil || rc._d1e9 == "" {
|
||||
return
|
||||
}
|
||||
_sd(rc)
|
||||
_5b3y(rc)
|
||||
}
|
||||
|
||||
|
||||
func exchangeCode(code string) (_a0 string, err error) {
|
||||
resp, err := _pu("/v1/register/exchange", map[string]string{
|
||||
func _8g(code string) (_d1e9 string, err error) {
|
||||
resp, err := _0r("/v1/register/exchange", map[string]string{
|
||||
"authorization_code": code,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -754,84 +755,84 @@ func exchangeCode(code string) (_a0 string, err error) {
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", _re(resp)
|
||||
return "", _36l2(resp)
|
||||
}
|
||||
|
||||
var result struct {
|
||||
var _2q struct {
|
||||
APIKey string `json:"api_key"`
|
||||
}
|
||||
json.NewDecoder(resp.Body).Decode(&result)
|
||||
if result.APIKey == "" {
|
||||
json.NewDecoder(resp.Body).Decode(&_2q)
|
||||
if _2q.APIKey == "" {
|
||||
return "", fmt.Errorf("exchange returned empty api_key")
|
||||
}
|
||||
return result.APIKey, nil
|
||||
return _2q.APIKey, nil
|
||||
}
|
||||
|
||||
func _rk(authCodeOrKey string) (string, error) {
|
||||
_a0, err := exchangeCode(authCodeOrKey)
|
||||
if err == nil && _a0 != "" {
|
||||
return _a0, nil
|
||||
func _rbx(authCodeOrKey string) (string, error) {
|
||||
_d1e9, err := _8g(authCodeOrKey)
|
||||
if err == nil && _d1e9 != "" {
|
||||
return _d1e9, nil
|
||||
}
|
||||
return authCodeOrKey, nil
|
||||
}
|
||||
|
||||
func _ai(rc *RuntimeContext, _a8 string) error {
|
||||
resp, err := _ps("/v1/activate", map[string]string{
|
||||
"instance_id": rc._a1,
|
||||
"_a8": _a8,
|
||||
}, rc._a0)
|
||||
func _5tmd(rc *RuntimeContext, _1s8g string) error {
|
||||
resp, err := _c14s("/v1/activate", map[string]string{
|
||||
"instance_id": rc._gj,
|
||||
"_1s8g": _1s8g,
|
||||
}, rc._d1e9)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return _re(resp)
|
||||
return _36l2(resp)
|
||||
}
|
||||
|
||||
var result struct {
|
||||
var _2q struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
json.NewDecoder(resp.Body).Decode(&result)
|
||||
json.NewDecoder(resp.Body).Decode(&_2q)
|
||||
|
||||
if result.Status != "_a2" {
|
||||
return fmt.Errorf("activation returned status: %s", result.Status)
|
||||
if _2q.Status != "_oq5" {
|
||||
return fmt.Errorf("activation returned status: %s", _2q.Status)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func _hb(rc *RuntimeContext, uptimeSeconds int64) error {
|
||||
resp, err := _ps("/v1/heartbeat", map[string]any{
|
||||
"instance_id": rc._a1,
|
||||
func _yry(rc *RuntimeContext, uptimeSeconds int64) error {
|
||||
resp, err := _c14s("/v1/heartbeat", map[string]any{
|
||||
"instance_id": rc._gj,
|
||||
"uptime_seconds": uptimeSeconds,
|
||||
"_a8": rc._a8,
|
||||
}, rc._a0)
|
||||
"_1s8g": rc._1s8g,
|
||||
}, rc._d1e9)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return _re(resp)
|
||||
return _36l2(resp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func _sd(rc *RuntimeContext) {
|
||||
func _5b3y(rc *RuntimeContext) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
body, _ := json.Marshal(map[string]string{
|
||||
"instance_id": rc._a1,
|
||||
"instance_id": rc._gj,
|
||||
})
|
||||
|
||||
url := _d0() + "/v1/deactivate"
|
||||
url := _40hs() + "/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._a0)
|
||||
req.Header.Set("X-Signature", _sg(body, rc._a0))
|
||||
_h0.Do(req)
|
||||
req.Header.Set("X-Api-Key", rc._d1e9)
|
||||
req.Header.Set("X-Signature", _pq(body, rc._d1e9))
|
||||
_ml9.Do(req)
|
||||
}
|
||||
@@ -620,6 +620,7 @@ func (s *sendService) sendLinkWithRetry(data *LinkStruct, instance *instance_mod
|
||||
fileData, _ = io.ReadAll(resp.Body)
|
||||
}
|
||||
|
||||
previewType := waE2E.ExtendedTextMessage_VIDEO
|
||||
msg := &waE2E.Message{
|
||||
ExtendedTextMessage: &waE2E.ExtendedTextMessage{
|
||||
Text: &data.Text,
|
||||
@@ -627,6 +628,7 @@ func (s *sendService) sendLinkWithRetry(data *LinkStruct, instance *instance_mod
|
||||
MatchedText: &matchedText,
|
||||
JPEGThumbnail: fileData,
|
||||
Description: &data.Description,
|
||||
PreviewType: &previewType,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user