2022-09-02 11:46:53 +00:00

12 lines
39 KiB
Go

//
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// This is a commercial product and requires a license to operate.
// A trial license can be obtained at https://unidoc.io
//
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
//
// Use of this source code is governed by the UniDoc End User License Agreement
// terms that can be accessed at https://unidoc.io/eula/
package license ;import (_de "bytes";_a "compress/gzip";_f "crypto";_ca "crypto/aes";_gg "crypto/cipher";_df "crypto/hmac";_dde "crypto/rand";_fa "crypto/rsa";_ggc "crypto/sha256";_b "crypto/sha512";_cc "crypto/x509";_cd "encoding/base64";_dd "encoding/binary";_ga "encoding/hex";_ed "encoding/json";_eg "encoding/pem";_ac "errors";_gf "fmt";_ae "github.com/unidoc/unioffice/common";_gd "github.com/unidoc/unioffice/common/logger";_e "io";_d "io/ioutil";_ad "log";_ee "net";_af "net/http";_eb "os";_fe "path/filepath";_g "regexp";_fg "sort";_gc "strings";_cf "sync";_deg "time";);func _gefa (_dcd ,_fba string )string {_cfg :=[]byte (_dcd );_bfag :=_df .New (_ggc .New ,_cfg );_bfag .Write ([]byte (_fba ));return _cd .StdEncoding .EncodeToString (_bfag .Sum (nil ));};func _ffae (_baf string ,_gad string ,_dda bool )error {if _agfd ==nil {return _ac .New ("\u006e\u006f\u0020\u006c\u0069\u0063\u0065\u006e\u0073e\u0020\u006b\u0065\u0079");};if !_agfd ._ceb ||len (_agfd ._cdg )==0{return nil ;};if len (_baf )==0&&!_dda {return _ac .New ("\u0064\u006f\u0063\u004b\u0065\u0079\u0020\u006e\u006ft\u0020\u0073\u0065\u0074");};_ffa .Lock ();defer _ffa .Unlock ();if _ggcg ==nil {_ggcg =map[string ]struct{}{};};if _beb ==nil {_beb =map[string ]int {};};_adb :=0;_ ,_ccgg :=_ggcg [_baf ];if !_ccgg {_ggcg [_baf ]=struct{}{};_adb ++;};if _adb ==0{return nil ;};_beb [_gad ]++;_bgbd :=_deg .Now ();_fab ,_gbf :=_ada .loadState (_agfd ._cdg );if _gbf !=nil {_gd .Log .Error ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_gbf );return _gbf ;};if _fab .Usage ==nil {_fab .Usage =map[string ]int {};};for _gee ,_caag :=range _beb {_fab .Usage [_gee ]+=_caag ;};_beb =nil ;const _gbd =24*_deg .Hour ;const _gbg =3*24*_deg .Hour ;if len (_fab .Instance )==0||_bgbd .Sub (_fab .LastReported )> _gbd ||(_fab .LimitDocs &&_fab .RemainingDocs <=_fab .Docs +int64 (_adb ))||_dda {_gebg ,_bff :=_eb .Hostname ();if _bff !=nil {return _bff ;};_acaf :=_fab .Docs ;_adfb ,_egag ,_bff :=_dgf ();if _bff !=nil {_gd .Log .Debug ("\u0055\u006e\u0061b\u006c\u0065\u0020\u0074o\u0020\u0067\u0065\u0074\u0020\u006c\u006fc\u0061\u006c\u0020\u0061\u0064\u0064\u0072\u0065\u0073\u0073\u003a\u0020\u0025\u0073",_bff .Error ());_adfb =append (_adfb ,"\u0069n\u0066\u006f\u0072\u006da\u0074\u0069\u006f\u006e\u0020n\u006ft\u0020a\u0076\u0061\u0069\u006c\u0061\u0062\u006ce");_egag =append (_egag ,"\u0069n\u0066\u006f\u0072\u006da\u0074\u0069\u006f\u006e\u0020n\u006ft\u0020a\u0076\u0061\u0069\u006c\u0061\u0062\u006ce");}else {_fg .Strings (_egag );_fg .Strings (_adfb );_cca ,_cdc :=_ade ();if _cdc !=nil {return _cdc ;};_agf :=false ;for _ ,_dede :=range _egag {if _dede ==_cca .String (){_agf =true ;};};if !_agf {_egag =append (_egag ,_cca .String ());};};_gfc :=_cec ();_gfc ._bee =_agfd ._cdg ;_acaf +=int64 (_adb );_gde :=meteredUsageCheckinForm {Instance :_fab .Instance ,Next :_fab .Next ,UsageNumber :int (_acaf ),NumFailed :_fab .NumErrors ,Hostname :_gebg ,LocalIP :_gc .Join (_egag ,"\u002c\u0020"),MacAddress :_gc .Join (_adfb ,"\u002c\u0020"),Package :"\u0075n\u0069\u006f\u0066\u0066\u0069\u0063e",PackageVersion :_ae .Version ,Usage :_fab .Usage ,IsPersistentCache :_agfd ._eef ,Timestamp :_bgbd .Unix ()};if len (_adfb )==0{_gde .MacAddress ="\u006e\u006f\u006e\u0065";};_dfba :=int64 (0);_bdc :=_fab .NumErrors ;_fcf :=_bgbd ;_ggdc :=0;_cfa :=_fab .LimitDocs ;_efbb ,_bff :=_gfc .checkinUsage (_gde );if _bff !=nil {if _bgbd .Sub (_fab .LastReported )> _gbg {if !_efbb .Success {return _ac .New (_efbb .Message );};return _ac .New ("\u0074\u006f\u006f\u0020\u006c\u006f\u006e\u0067\u0020\u0073\u0069\u006e\u0063\u0065\u0020\u006c\u0061\u0073\u0074\u0020\u0073\u0075\u0063\u0063e\u0073\u0073\u0066\u0075\u006c \u0063\u0068e\u0063\u006b\u0069\u006e");};_dfba =_acaf ;_bdc ++;_fcf =_fab .LastReported ;}else {_cfa =_efbb .LimitDocs ;_ggdc =_efbb .RemainingDocs ;_bdc =0;};if len (_efbb .Instance )==0{_efbb .Instance =_gde .Instance ;};if len (_efbb .Next )==0{_efbb .Next =_gde .Next ;};_bff =_ada .updateState (_gfc ._bee ,_efbb .Instance ,_efbb .Next ,int (_dfba ),_cfa ,_ggdc ,int (_bdc ),_fcf ,nil );if _bff !=nil {return _bff ;};if !_efbb .Success {return _gf .Errorf ("\u0065r\u0072\u006f\u0072\u003a\u0020\u0025s",_efbb .Message );};}else {_gbf =_ada .updateState (_agfd ._cdg ,_fab .Instance ,_fab .Next ,int (_fab .Docs )+_adb ,_fab .LimitDocs ,int (_fab .RemainingDocs ),int (_fab .NumErrors ),_fab .LastReported ,_fab .Usage );if _gbf !=nil {return _gbf ;};};return nil ;};var _beb map[string ]int ;var _agfd =MakeUnlicensedKey ();func (_eff LegacyLicense )Verify (pubKey *_fa .PublicKey )error {_abbe :=_eff ;_abbe .Signature ="";_aad :=_de .Buffer {};_ded :=_ed .NewEncoder (&_aad );if _defd :=_ded .Encode (_abbe );_defd !=nil {return _defd ;};_ffe ,_dab :=_ga .DecodeString (_eff .Signature );if _dab !=nil {return _dab ;};_cdf :=_ggc .Sum256 (_aad .Bytes ());_dab =_fa .VerifyPKCS1v15 (pubKey ,_f .SHA256 ,_cdf [:],_ffe );return _dab ;};const _ecf ="\u0033\u0030\u0035\u0063\u0033\u0030\u0030\u00640\u0036\u0030\u0039\u0032\u0061\u0038\u00364\u0038\u0038\u0036\u0066\u0037\u0030d\u0030\u0031\u0030\u0031\u0030\u00310\u0035\u0030\u0030\u0030\u0033\u0034\u0062\u0030\u0030\u0033\u0030\u00348\u0030\u0032\u0034\u0031\u0030\u0030\u0062\u0038\u0037\u0065\u0061\u0066\u0062\u0036\u0063\u0030\u0037\u0034\u0039\u0039\u0065\u0062\u00397\u0063\u0063\u0039\u0064\u0033\u0035\u0036\u0035\u0065\u0063\u00663\u0031\u0036\u0038\u0031\u0039\u0036\u0033\u0030\u0031\u0039\u0030\u0037c\u0038\u0034\u0031\u0061\u0064\u0064c6\u0036\u0035\u0030\u0038\u0036\u0062\u0062\u0033\u0065\u0064\u0038\u0065\u0062\u0031\u0032\u0064\u0039\u0064\u0061\u0032\u0036\u0063\u0061\u0066\u0061\u0039\u0036\u00345\u0030\u00314\u0036\u0064\u0061\u0038\u0062\u0064\u0030\u0063c\u0066\u0031\u0035\u0035\u0066\u0063a\u0063\u0063\u00368\u0036\u0039\u0035\u0035\u0065\u0066\u0030\u0033\u0030\u0032\u0066\u0061\u0034\u0034\u0061\u0061\u0033\u0065\u0063\u0038\u0039\u0034\u0031\u0037\u0062\u0030\u0032\u0030\u0033\u0030\u0031\u0030\u0030\u0030\u0031";func _ade ()(_ee .IP ,error ){_eabg ,_fcff :=_ee .Dial ("\u0075\u0064\u0070","\u0038\u002e\u0038\u002e\u0038\u002e\u0038\u003a\u0038\u0030");if _fcff !=nil {return nil ,_fcff ;};defer _eabg .Close ();_gbfc :=_eabg .LocalAddr ().(*_ee .UDPAddr );return _gbfc .IP ,nil ;};const (_caa ="\u002d\u002d\u002d--\u0042\u0045\u0047\u0049\u004e\u0020\u0055\u004e\u0049D\u004fC\u0020L\u0049C\u0045\u004e\u0053\u0045\u0020\u004b\u0045\u0059\u002d\u002d\u002d\u002d\u002d";_gdd ="\u002d\u002d\u002d\u002d\u002d\u0045\u004e\u0044\u0020\u0055\u004e\u0049\u0044\u004f\u0043 \u004cI\u0043\u0045\u004e\u0053\u0045\u0020\u004b\u0045\u0059\u002d\u002d\u002d\u002d\u002d";);func _bga (_gcf *_af .Response )([]byte ,error ){var _eabc []byte ;_fee ,_fgeg :=_debg (_gcf );if _fgeg !=nil {return _eabc ,_fgeg ;};return _d .ReadAll (_fee );};type meteredStatusForm struct{};const (LicenseTierUnlicensed ="\u0075\u006e\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0064";LicenseTierCommunity ="\u0063o\u006d\u006d\u0075\u006e\u0069\u0074y";LicenseTierIndividual ="\u0069\u006e\u0064\u0069\u0076\u0069\u0064\u0075\u0061\u006c";LicenseTierBusiness ="\u0062\u0075\u0073\u0069\u006e\u0065\u0073\u0073";);type stateLoader interface{loadState (_efad string )(reportState ,error );updateState (_ege ,_agc ,_ffd string ,_bdf int ,_fge bool ,_cgb int ,_eefd int ,_aadd _deg .Time ,_aga map[string ]int )error ;};func SetLicenseKey (content string ,customerName string )error {if _geg {return nil ;};_daba ,_ced :=_afc (content );if _ced !=nil {_gd .Log .Error ("\u004c\u0069c\u0065\u006e\u0073\u0065\u0020\u0063\u006f\u0064\u0065\u0020\u0064\u0065\u0063\u006f\u0064\u0065\u0020\u0065\u0072\u0072\u006f\u0072: \u0025\u0076",_ced );return _ced ;};if !_gc .EqualFold (_daba .CustomerName ,customerName ){_gd .Log .Error ("L\u0069ce\u006es\u0065 \u0063\u006f\u0064\u0065\u0020i\u0073\u0073\u0075e\u0020\u002d\u0020\u0043\u0075s\u0074\u006f\u006de\u0072\u0020\u006e\u0061\u006d\u0065\u0020\u006d\u0069\u0073\u006da\u0074\u0063\u0068, e\u0078\u0070\u0065\u0063\u0074\u0065d\u0020\u0027\u0025\u0073\u0027\u002c\u0020\u0062\u0075\u0074\u0020\u0067o\u0074 \u0027\u0025\u0073\u0027",customerName ,_daba .CustomerName );return _gf .Errorf ("\u0063\u0075\u0073\u0074\u006fm\u0065\u0072\u0020\u006e\u0061\u006d\u0065\u0020\u006d\u0069\u0073\u006d\u0061t\u0063\u0068\u002c\u0020\u0065\u0078\u0070\u0065\u0063\u0074\u0065\u0064\u0020\u0027\u0025\u0073\u0027\u002c\u0020\u0062\u0075\u0074\u0020\u0067\u006f\u0074\u0020\u0027\u0025\u0073'",customerName ,_daba .CustomerName );};_ced =_daba .Validate ();if _ced !=nil {_gd .Log .Error ("\u004c\u0069\u0063\u0065\u006e\u0073e\u0020\u0063\u006f\u0064\u0065\u0020\u0076\u0061\u006c\u0069\u0064\u0061\u0074i\u006f\u006e\u0020\u0065\u0072\u0072\u006fr\u003a\u0020\u0025\u0076",_ced );return _ced ;};_agfd =&_daba ;return nil ;};type meteredStatusResp struct{Valid bool `json:"valid"`;OrgCredits int64 `json:"org_credits"`;OrgUsed int64 `json:"org_used"`;OrgRemaining int64 `json:"org_remaining"`;};func MakeUnlicensedKey ()*LicenseKey {_ggd :=LicenseKey {};_ggd .CustomerName ="\u0055\u006e\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0064";_ggd .Tier =LicenseTierUnlicensed ;_ggd .CreatedAt =_deg .Now ().UTC ();_ggd .CreatedAtInt =_ggd .CreatedAt .Unix ();return &_ggd ;};type meteredClient struct{_efb string ;_bee string ;_gafe *_af .Client ;};type LegacyLicenseType byte ;func (_fgf *LicenseKey )isExpired ()bool {return _fgf .getExpiryDateToCompare ().After (_fgf .ExpiresAt )};var _ffa =&_cf .Mutex {};const _defb ="\u0055\u004e\u0049OF\u0046\u0049\u0043\u0045\u005f\u0043\u0055\u0053\u0054\u004f\u004d\u0045\u0052\u005f\u004e\u0041\u004d\u0045";func init (){_gdf ,_ead :=_ga .DecodeString (_ecf );if _ead !=nil {_ad .Fatalf ("e\u0072\u0072\u006f\u0072 r\u0065a\u0064\u0069\u006e\u0067\u0020k\u0065\u0079\u003a\u0020\u0025\u0073",_ead );};_ccg ,_ead :=_cc .ParsePKIXPublicKey (_gdf );if _ead !=nil {_ad .Fatalf ("e\u0072\u0072\u006f\u0072 r\u0065a\u0064\u0069\u006e\u0067\u0020k\u0065\u0079\u003a\u0020\u0025\u0073",_ead );};_aa =_ccg .(*_fa .PublicKey );};var _aa *_fa .PublicKey ;func SetMeteredKeyPersistentCache (val bool ){_agfd ._eef =val };type defaultStateHolder struct{};func _aee (_bb string ,_cfc string )([]byte ,error ){var (_fga int ;_ge string ;);for _ ,_ge =range []string {"\u000a\u002b\u000a","\u000d\u000a\u002b\r\u000a","\u0020\u002b\u0020"}{if _fga =_gc .Index (_cfc ,_ge );_fga !=-1{break ;};};if _fga ==-1{return nil ,_gf .Errorf ("\u0069\u006e\u0076al\u0069\u0064\u0020\u0069\u006e\u0070\u0075\u0074\u002c \u0073i\u0067n\u0061t\u0075\u0072\u0065\u0020\u0073\u0065\u0070\u0061\u0072\u0061\u0074\u006f\u0072");};_dfb :=_cfc [:_fga ];_da :=_fga +len (_ge );_dg :=_cfc [_da :];if _dfb ==""||_dg ==""{return nil ,_gf .Errorf ("\u0069n\u0076\u0061l\u0069\u0064\u0020\u0069n\u0070\u0075\u0074,\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020or\u0069\u0067\u0069n\u0061\u006c \u006f\u0072\u0020\u0073\u0069\u0067n\u0061\u0074u\u0072\u0065");};_adc ,_gaf :=_cd .StdEncoding .DecodeString (_dfb );if _gaf !=nil {return nil ,_gf .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0070\u0075\u0074\u0020\u006f\u0072\u0069\u0067\u0069\u006ea\u006c");};_ec ,_gaf :=_cd .StdEncoding .DecodeString (_dg );if _gaf !=nil {return nil ,_gf .Errorf ("\u0069\u006e\u0076al\u0069\u0064\u0020\u0069\u006e\u0070\u0075\u0074\u0020\u0073\u0069\u0067\u006e\u0061\u0074\u0075\u0072\u0065");};_fea ,_ :=_eg .Decode ([]byte (_bb ));if _fea ==nil {return nil ,_gf .Errorf ("\u0050\u0075\u0062\u004b\u0065\u0079\u0020\u0066\u0061\u0069\u006c\u0065\u0064");};_dbg ,_gaf :=_cc .ParsePKIXPublicKey (_fea .Bytes );if _gaf !=nil {return nil ,_gaf ;};_adcc :=_dbg .(*_fa .PublicKey );if _adcc ==nil {return nil ,_gf .Errorf ("\u0050u\u0062\u004b\u0065\u0079\u0020\u0063\u006f\u006e\u0076\u0065\u0072s\u0069\u006f\u006e\u0020\u0066\u0061\u0069\u006c\u0065\u0064");};_ebd :=_b .New ();_ebd .Write (_adc );_gaa :=_ebd .Sum (nil );_gaf =_fa .VerifyPKCS1v15 (_adcc ,_f .SHA512 ,_gaa ,_ec );if _gaf !=nil {return nil ,_gaf ;};return _adc ,nil ;};func _dbd (_ceda ,_ffaee []byte )([]byte ,error ){_debd ,_dgb :=_ca .NewCipher (_ceda );if _dgb !=nil {return nil ,_dgb ;};_gafb :=make ([]byte ,_ca .BlockSize +len (_ffaee ));_ecc :=_gafb [:_ca .BlockSize ];if _ ,_bec :=_e .ReadFull (_dde .Reader ,_ecc );_bec !=nil {return nil ,_bec ;};_bde :=_gg .NewCFBEncrypter (_debd ,_ecc );_bde .XORKeyStream (_gafb [_ca .BlockSize :],_ffaee );_ede :=make ([]byte ,_cd .URLEncoding .EncodedLen (len (_gafb )));_cd .URLEncoding .Encode (_ede ,_gafb );return _ede ,nil ;};type meteredUsageCheckinResp struct{Instance string `json:"inst"`;Next string `json:"next"`;Success bool `json:"success"`;Message string `json:"message"`;RemainingDocs int `json:"rd"`;LimitDocs bool `json:"ld"`;};func (_fc *LicenseKey )TypeToString ()string {if _fc ._ceb {return "M\u0065t\u0065\u0072\u0065\u0064\u0020\u0073\u0075\u0062s\u0063\u0072\u0069\u0070ti\u006f\u006e";};if _fc .Tier ==LicenseTierUnlicensed {return "\u0055\u006e\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0064";};if _fc .Tier ==LicenseTierCommunity {return "\u0041\u0047PL\u0076\u0033\u0020O\u0070\u0065\u006e\u0020Sou\u0072ce\u0020\u0043\u006f\u006d\u006d\u0075\u006eit\u0079\u0020\u004c\u0069\u0063\u0065\u006es\u0065";};if _fc .Tier ==LicenseTierIndividual ||_fc .Tier =="\u0069\u006e\u0064i\u0065"{return "\u0043\u006f\u006dm\u0065\u0072\u0063\u0069a\u006c\u0020\u004c\u0069\u0063\u0065\u006es\u0065\u0020\u002d\u0020\u0049\u006e\u0064\u0069\u0076\u0069\u0064\u0075\u0061\u006c";};return "\u0043\u006fm\u006d\u0065\u0072\u0063\u0069\u0061\u006c\u0020\u004c\u0069\u0063\u0065\u006e\u0073\u0065\u0020\u002d\u0020\u0042\u0075\u0073\u0069ne\u0073\u0073";};func (_geb defaultStateHolder )loadState (_ffb string )(reportState ,error ){_cdad :=_agd ();if len (_cdad )==0{return reportState {},_ac .New ("\u0068\u006fm\u0065\u0020\u0064i\u0072\u0020\u006e\u006f\u0074\u0020\u0073\u0065\u0074");};_bgb :=_fe .Join (_cdad ,"\u002eu\u006e\u0069\u0064\u006f\u0063");_geff :=_eb .MkdirAll (_bgb ,0777);if _geff !=nil {return reportState {},_geff ;};if len (_ffb )< 20{return reportState {},_ac .New ("i\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006b\u0065\u0079");};_gac :=[]byte (_ffb );_bedd :=_b .Sum512_256 (_gac [:20]);_aaa :=_ga .EncodeToString (_bedd [:]);_ecg :=_fe .Join (_bgb ,_aaa );_adcg ,_geff :=_d .ReadFile (_ecg );if _geff !=nil {if _eb .IsNotExist (_geff ){return reportState {},nil ;};_gd .Log .Error ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_geff );return reportState {},_ac .New ("\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0061");};const _fec ="\u0068\u00619\u004e\u004b\u0038]\u0052\u0062\u004c\u002a\u006d\u0034\u004c\u004b\u0057";_adcg ,_geff =_ddb ([]byte (_fec ),_adcg );if _geff !=nil {return reportState {},_geff ;};var _edb reportState ;_geff =_ed .Unmarshal (_adcg ,&_edb );if _geff !=nil {_gd .Log .Error ("\u0045\u0052\u0052OR\u003a\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0061\u003a\u0020\u0025\u0076",_geff );return reportState {},_ac .New ("\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0061");};return _edb ,nil ;};type LicenseKey struct{LicenseId string `json:"license_id"`;CustomerId string `json:"customer_id"`;CustomerName string `json:"customer_name"`;Tier string `json:"tier"`;CreatedAt _deg .Time `json:"-"`;CreatedAtInt int64 `json:"created_at"`;ExpiresAt _deg .Time `json:"-"`;ExpiresAtInt int64 `json:"expires_at"`;CreatedBy string `json:"created_by"`;CreatorName string `json:"creator_name"`;CreatorEmail string `json:"creator_email"`;UniPDF bool `json:"unipdf"`;UniOffice bool `json:"unioffice"`;UniHTML bool `json:"unihtml"`;Trial bool `json:"trial"`;_ceb bool ;_cdg string ;_eef bool ;};const _fgac ="\u0055\u004e\u0049\u004fFF\u0049\u0043\u0045\u005f\u004c\u0049\u0043\u0045\u004e\u0053\u0045\u005f\u0050\u0041T\u0048";func _dgf ()([]string ,[]string ,error ){_dba ,_gag :=_ee .Interfaces ();if _gag !=nil {return nil ,nil ,_gag ;};var _cb []string ;var _ffea []string ;for _ ,_defc :=range _dba {if _defc .Flags &_ee .FlagUp ==0||_de .Equal (_defc .HardwareAddr ,nil ){continue ;};_ebc ,_dc :=_defc .Addrs ();if _dc !=nil {return nil ,nil ,_dc ;};_eceb :=0;for _ ,_cfb :=range _ebc {var _gcc _ee .IP ;switch _afg :=_cfb .(type ){case *_ee .IPNet :_gcc =_afg .IP ;case *_ee .IPAddr :_gcc =_afg .IP ;};if _gcc .IsLoopback (){continue ;};if _gcc .To4 ()==nil {continue ;};_ffea =append (_ffea ,_gcc .String ());_eceb ++;};_fcgf :=_defc .HardwareAddr .String ();if _fcgf !=""&&_eceb > 0{_cb =append (_cb ,_fcgf );};};return _cb ,_ffea ,nil ;};func _afc (_ce string )(LicenseKey ,error ){var _dac LicenseKey ;_ffg ,_dag :=_bae (_caa ,_gdd ,_ce );if _dag !=nil {return _dac ,_dag ;};_fff ,_dag :=_aee (_egd ,_ffg );if _dag !=nil {return _dac ,_dag ;};_dag =_ed .Unmarshal (_fff ,&_dac );if _dag !=nil {return _dac ,_dag ;};_dac .CreatedAt =_deg .Unix (_dac .CreatedAtInt ,0);if _dac .ExpiresAtInt > 0{_dad :=_deg .Unix (_dac .ExpiresAtInt ,0);_dac .ExpiresAt =_dad ;};return _dac ,nil ;};func Track (docKey string ,useKey string )error {return _ffae (docKey ,useKey ,!_agfd ._eef )};func SetLegacyLicenseKey (s string )error {_cbf :=_g .MustCompile ("\u005c\u0073");s =_cbf .ReplaceAllString (s ,"");var _dace _e .Reader ;_dace =_gc .NewReader (s );_dace =_cd .NewDecoder (_cd .RawURLEncoding ,_dace );_dace ,_afa :=_a .NewReader (_dace );if _afa !=nil {return _afa ;};_cdfe :=_ed .NewDecoder (_dace );_eeda :=&LegacyLicense {};if _dedg :=_cdfe .Decode (_eeda );_dedg !=nil {return _dedg ;};if _bdd :=_eeda .Verify (_aa );_bdd !=nil {return _ac .New ("\u006c\u0069\u0063en\u0073\u0065\u0020\u0076\u0061\u006c\u0069\u0064\u0061\u0074\u0069\u006e\u0020\u0065\u0072\u0072\u006f\u0072");};if _eeda .Expiration .Before (_ae .ReleasedAt ){return _ac .New ("\u006ci\u0063e\u006e\u0073\u0065\u0020\u0065\u0078\u0070\u0069\u0072\u0065\u0064");};_caaa :=_deg .Now ().UTC ();_agg :=LicenseKey {};_agg .CreatedAt =_caaa ;_agg .CustomerId ="\u004c\u0065\u0067\u0061\u0063\u0079";_agg .CustomerName =_eeda .Name ;_agg .Tier =LicenseTierBusiness ;_agg .ExpiresAt =_eeda .Expiration ;_agg .CreatorName ="\u0055\u006e\u0069\u0044\u006f\u0063\u0020\u0073\u0075p\u0070\u006f\u0072\u0074";_agg .CreatorEmail ="\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0040\u0075\u006e\u0069\u0064o\u0063\u002e\u0069\u006f";_agg .UniOffice =true ;_agfd =&_agg ;return nil ;};func _debg (_fdg *_af .Response )(_e .ReadCloser ,error ){var _aadg error ;var _caca _e .ReadCloser ;switch _gc .ToLower (_fdg .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067")){case "\u0067\u007a\u0069\u0070":_caca ,_aadg =_a .NewReader (_fdg .Body );if _aadg !=nil {return _caca ,_aadg ;};defer _caca .Close ();default:_caca =_fdg .Body ;};return _caca ,nil ;};type LegacyLicense struct{Name string ;Signature string `json:",omitempty"`;Expiration _deg .Time ;LicenseType LegacyLicenseType ;};var _bag =_deg .Date (2019,6,6,0,0,0,0,_deg .UTC );func (_bg *LicenseKey )ToString ()string {if _bg ._ceb {return "M\u0065t\u0065\u0072\u0065\u0064\u0020\u0073\u0075\u0062s\u0063\u0072\u0069\u0070ti\u006f\u006e";};_cg :=_gf .Sprintf ("\u004ci\u0063e\u006e\u0073\u0065\u0020\u0049\u0064\u003a\u0020\u0025\u0073\u000a",_bg .LicenseId );_cg +=_gf .Sprintf ("\u0043\u0075s\u0074\u006f\u006de\u0072\u0020\u0049\u0064\u003a\u0020\u0025\u0073\u000a",_bg .CustomerId );_cg +=_gf .Sprintf ("\u0043u\u0073t\u006f\u006d\u0065\u0072\u0020N\u0061\u006de\u003a\u0020\u0025\u0073\u000a",_bg .CustomerName );_cg +=_gf .Sprintf ("\u0054i\u0065\u0072\u003a\u0020\u0025\u0073\n",_bg .Tier );_cg +=_gf .Sprintf ("\u0043r\u0065a\u0074\u0065\u0064\u0020\u0041\u0074\u003a\u0020\u0025\u0073\u000a",_ae .UtcTimeFormat (_bg .CreatedAt ));if _bg .ExpiresAt .IsZero (){_cg +="\u0045x\u0070i\u0072\u0065\u0073\u0020\u0041t\u003a\u0020N\u0065\u0076\u0065\u0072\u000a";}else {_cg +=_gf .Sprintf ("\u0045x\u0070i\u0072\u0065\u0073\u0020\u0041\u0074\u003a\u0020\u0025\u0073\u000a",_ae .UtcTimeFormat (_bg .ExpiresAt ));};_cg +=_gf .Sprintf ("\u0043\u0072\u0065\u0061\u0074\u006f\u0072\u003a\u0020\u0025\u0073\u0020<\u0025\u0073\u003e\u000a",_bg .CreatorName ,_bg .CreatorEmail );return _cg ;};func _agd ()string {_dagf :=_eb .Getenv ("\u0048\u004f\u004d\u0045");if len (_dagf )==0{_dagf ,_ =_eb .UserHomeDir ();};return _dagf ;};func GetLicenseKey ()*LicenseKey {if _agfd ==nil {return nil ;};_gfd :=*_agfd ;return &_gfd ;};func TrackUse (useKey string ){if _agfd ==nil {return ;};if !_agfd ._ceb ||len (_agfd ._cdg )==0{return ;};if len (useKey )==0{return ;};_ffa .Lock ();defer _ffa .Unlock ();if _beb ==nil {_beb =map[string ]int {};};_beb [useKey ]++;};func GenRefId (prefix string )(string ,error ){var _dcb _de .Buffer ;_dcb .WriteString (prefix );_edga :=make ([]byte ,8+16);_bad :=_deg .Now ().UTC ().UnixNano ();_dd .BigEndian .PutUint64 (_edga ,uint64 (_bad ));_ ,_eca :=_dde .Read (_edga [8:]);if _eca !=nil {return "",_eca ;};_dcb .WriteString (_ga .EncodeToString (_edga ));return _dcb .String (),nil ;};const _egd ="\u000a\u002d\u002d\u002d\u002d\u002d\u0042\u0045\u0047\u0049\u004e \u0050\u0055\u0042\u004c\u0049\u0043\u0020\u004b\u0045Y\u002d\u002d\u002d\u002d\u002d\u000a\u004d\u0049I\u0042\u0049\u006a\u0041NB\u0067\u006b\u0071\u0068\u006b\u0069G\u0039\u0077\u0030\u0042\u0041\u0051\u0045\u0046A\u0041\u004f\u0043\u0041\u0051\u0038\u0041\u004d\u0049\u0049\u0042\u0043\u0067\u004b\u0043\u0041\u0051\u0045A\u006dF\u0055\u0069\u0079\u0064\u0037\u0062\u0035\u0058\u006a\u0070\u006b\u0050\u0035\u0052\u0061\u0070\u0034\u0077\u000a\u0044\u0063\u0031d\u0079\u007a\u0049\u0051\u0034\u004c\u0065\u006b\u0078\u0072\u0076\u0079\u0074\u006e\u0045\u004d\u0070\u004e\u0055\u0062\u006f\u0036i\u0041\u0037\u0034\u0056\u0038\u0072\u0075\u005a\u004f\u0076\u0072\u0053\u0063\u0073\u0066\u0032\u0051\u0065\u004e9\u002f\u0071r\u0055\u0047\u0038\u0071\u0045\u0062\u0055\u0057\u0064\u006f\u0045\u0059\u0071+\u000a\u006f\u0074\u0046\u004e\u0041\u0046N\u0078\u006c\u0047\u0062\u0078\u0062\u0044\u0048\u0063\u0064\u0047\u0056\u0061\u004d\u0030\u004f\u0058\u0064\u0058g\u0044y\u004c5\u0061\u0049\u0045\u0061\u0067\u004c\u0030\u0063\u0035\u0070\u0077\u006a\u0049\u0064\u0050G\u0049\u006e\u0034\u0036\u0066\u0037\u0038\u0065\u004d\u004a\u002b\u004a\u006b\u0064\u0063\u0070\u0044\n\u0044\u004a\u0061\u0071\u0059\u0058d\u0072\u007a5\u004b\u0065\u0073\u0068\u006aS\u0069\u0049\u0061\u0061\u0037\u006d\u0065\u006e\u0042\u0049\u0041\u0058\u0053\u0034\u0055\u0046\u0078N\u0066H\u0068\u004e\u0030\u0048\u0043\u0059\u005a\u0059\u0071\u0051\u0047\u0037\u0062K+\u0073\u0035\u0072R\u0048\u006f\u006e\u0079\u0064\u004eW\u0045\u0047\u000a\u0048\u0038M\u0079\u0076\u00722\u0070\u0079\u0061\u0032K\u0072\u004d\u0075m\u0066\u006d\u0041\u0078\u0055\u0042\u0036\u0066\u0065\u006e\u0043\u002f4\u004f\u0030\u0057\u00728\u0067\u0066\u0050\u004f\u0055\u0038R\u0069\u0074\u006d\u0062\u0044\u0076\u0051\u0050\u0049\u0052\u0058\u004fL\u0034\u0076\u0054B\u0072\u0042\u0064\u0062a\u0041\u000a9\u006e\u0077\u004e\u0050\u002b\u0069\u002f\u002f\u0032\u0030\u004d\u00542\u0062\u0078\u006d\u0065\u0057\u0042\u002b\u0067\u0070\u0063\u0045\u0068G\u0070\u0058\u005a7\u0033\u0033\u0061\u007a\u0051\u0078\u0072\u0043\u0033\u004a\u0034\u0076\u0033C\u005a\u006d\u0045\u004eS\u0074\u0044\u004b\u002f\u004b\u0044\u0053\u0050\u004b\u0055\u0047\u0066\u00756\u000a\u0066\u0077I\u0044\u0041\u0051\u0041\u0042\u000a\u002d\u002d\u002d\u002d\u002dE\u004e\u0044\u0020\u0050\u0055\u0042\u004c\u0049\u0043 \u004b\u0045Y\u002d\u002d\u002d\u002d\u002d\n";type reportState struct{Instance string `json:"inst"`;Next string `json:"n"`;Docs int64 `json:"d"`;NumErrors int64 `json:"e"`;LimitDocs bool `json:"ld"`;RemainingDocs int64 `json:"rd"`;LastReported _deg .Time `json:"lr"`;LastWritten _deg .Time `json:"lw"`;Usage map[string ]int `json:"u"`;};func _ef (_def string ,_db []byte )(string ,error ){_ba ,_ :=_eg .Decode ([]byte (_def ));if _ba ==nil {return "",_gf .Errorf ("\u0050\u0072\u0069\u0076\u004b\u0065\u0079\u0020\u0066a\u0069\u006c\u0065\u0064");};_bc ,_be :=_cc .ParsePKCS1PrivateKey (_ba .Bytes );if _be !=nil {return "",_be ;};_bd :=_b .New ();_bd .Write (_db );_ff :=_bd .Sum (nil );_eed ,_be :=_fa .SignPKCS1v15 (_dde .Reader ,_bc ,_f .SHA512 ,_ff );if _be !=nil {return "",_be ;};_cac :=_cd .StdEncoding .EncodeToString (_db );_cac +="\u000a\u002b\u000a";_cac +=_cd .StdEncoding .EncodeToString (_eed );return _cac ,nil ;};var _ccc =_deg .Date (2020,1,1,0,0,0,0,_deg .UTC );func _fefg (_cdb []byte )(_e .Reader ,error ){_dage :=new (_de .Buffer );_fed :=_a .NewWriter (_dage );_fed .Write (_cdb );_dec :=_fed .Close ();if _dec !=nil {return nil ,_dec ;};return _dage ,nil ;};type meteredUsageCheckinForm struct{Instance string `json:"inst"`;Next string `json:"next"`;UsageNumber int `json:"usage_number"`;NumFailed int64 `json:"num_failed"`;Hostname string `json:"hostname"`;LocalIP string `json:"local_ip"`;MacAddress string `json:"mac_address"`;Package string `json:"package"`;PackageVersion string `json:"package_version"`;Usage map[string ]int `json:"u"`;IsPersistentCache bool `json:"is_persistent_cache"`;Timestamp int64 `json:"timestamp"`;};func (_afe *LicenseKey )Validate ()error {if _afe ._ceb {return nil ;};if len (_afe .LicenseId )< 10{return _gf .Errorf ("i\u006e\u0076\u0061\u006c\u0069\u0064 \u006c\u0069\u0063\u0065\u006e\u0073\u0065\u003a\u0020L\u0069\u0063\u0065n\u0073e\u0020\u0049\u0064");};if len (_afe .CustomerId )< 10{return _gf .Errorf ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065:\u0020C\u0075\u0073\u0074\u006f\u006d\u0065\u0072 \u0049\u0064");};if len (_afe .CustomerName )< 1{return _gf .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0069c\u0065\u006e\u0073\u0065\u003a\u0020\u0043u\u0073\u0074\u006f\u006d\u0065\u0072\u0020\u004e\u0061\u006d\u0065");};if _ab .After (_afe .CreatedAt ){return _gf .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u003a\u0020\u0043\u0072\u0065\u0061\u0074\u0065\u0064 \u0041\u0074\u0020\u0069\u0073 \u0069\u006ev\u0061\u006c\u0069\u0064");};if _afe .ExpiresAt .IsZero (){_dee :=_afe .CreatedAt .AddDate (1,0,0);if _ccc .After (_dee ){_dee =_ccc ;};_afe .ExpiresAt =_dee ;};if _afe .CreatedAt .After (_afe .ExpiresAt ){return _gf .Errorf ("i\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u003a\u0020\u0043\u0072\u0065\u0061\u0074\u0065\u0064\u0020\u0041\u0074 \u0063a\u006e\u006e\u006f\u0074 \u0062\u0065 \u0047\u0072\u0065\u0061\u0074\u0065\u0072\u0020\u0074\u0068\u0061\u006e\u0020\u0045\u0078\u0070\u0069\u0072\u0065\u0073\u0020\u0041\u0074");};if _afe .isExpired (){return _gf .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020l\u0069\u0063\u0065ns\u0065\u003a\u0020\u0054\u0068\u0065 \u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0020\u0068\u0061\u0073\u0020\u0061\u006c\u0072e\u0061\u0064\u0079\u0020\u0065\u0078\u0070\u0069r\u0065\u0064");};if len (_afe .CreatorName )< 1{return _gf .Errorf ("\u0069\u006ev\u0061\u006c\u0069\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u003a\u0020\u0043\u0072\u0065\u0061\u0074\u006f\u0072\u0020na\u006d\u0065");};if len (_afe .CreatorEmail )< 1{return _gf .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0069c\u0065\u006e\u0073\u0065\u003a\u0020\u0043r\u0065\u0061\u0074\u006f\u0072\u0020\u0065\u006d\u0061\u0069\u006c");};if _afe .CreatedAt .After (_bag ){if !_afe .UniOffice {return _gf .Errorf ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073e\u003a\u0020\u0054\u0068\u0069\u0073\u0020\u0055\u006e\u0069\u0044\u006f\u0063\u0020\u006b\u0065\u0079\u0020i\u0073\u0020\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0066\u006f\u0072\u0020\u0055\u006e\u0069\u004f\u0066\u0066\u0069\u0063\u0065");};};return nil ;};func (_bed *LicenseKey )IsLicensed ()bool {if _bed ==nil {return false ;};return _bed .Tier !=LicenseTierUnlicensed ||_bed ._ceb ;};var _ggcg map[string ]struct{};func SetMeteredKey (apiKey string )error {if len (apiKey )==0{_gd .Log .Error ("\u004d\u0065\u0074\u0065\u0072e\u0064\u0020\u004c\u0069\u0063\u0065\u006e\u0073\u0065\u0020\u0041\u0050\u0049 \u004b\u0065\u0079\u0020\u006d\u0075\u0073\u0074\u0020\u006e\u006f\u0074\u0020\u0062\u0065\u0020\u0065\u006d\u0070\u0074\u0079");_gd .Log .Error ("\u002d\u0020\u0047\u0072\u0061\u0062\u0020\u006f\u006e\u0065\u0020\u0069\u006e\u0020\u0074h\u0065\u0020\u0046\u0072\u0065\u0065\u0020\u0054\u0069\u0065\u0072\u0020\u0061t\u0020\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0063\u006c\u006fud\u002e\u0075\u006e\u0069\u0064\u006f\u0063\u002e\u0069\u006f");return _gf .Errorf ("\u006de\u0074\u0065\u0072e\u0064\u0020\u006ci\u0063en\u0073\u0065\u0020\u0061\u0070\u0069\u0020k\u0065\u0079\u0020\u006d\u0075\u0073\u0074\u0020\u006e\u006f\u0074\u0020\u0062\u0065\u0020\u0065\u006d\u0070\u0074\u0079\u003a\u0020\u0063\u0072\u0065\u0061\u0074\u0065 o\u006ee\u0020\u0061\u0074\u0020\u0068\u0074t\u0070\u0073\u003a\u002f\u002fc\u006c\u006f\u0075\u0064\u002e\u0075\u006e\u0069\u0064\u006f\u0063.\u0069\u006f");};if _agfd !=nil &&(_agfd ._ceb ||_agfd .Tier !=LicenseTierUnlicensed ){_gd .Log .Error ("\u0045\u0052\u0052\u004f\u0052:\u0020\u0043\u0061\u006e\u006eo\u0074 \u0073\u0065\u0074\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0020\u006b\u0065\u0079\u0020\u0074\u0077\u0069c\u0065\u0020\u002d\u0020\u0053\u0068\u006f\u0075\u006c\u0064\u0020\u006a\u0075\u0073\u0074\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0069z\u0065\u0020\u006f\u006e\u0063\u0065");return _ac .New ("\u006c\u0069\u0063en\u0073\u0065\u0020\u006b\u0065\u0079\u0020\u0061\u006c\u0072\u0065\u0061\u0064\u0079\u0020\u0073\u0065\u0074");};_edc :=_cec ();_edc ._bee =apiKey ;_efa ,_gfa :=_edc .getStatus ();if _gfa !=nil {return _gfa ;};if !_efa .Valid {return _ac .New ("\u006b\u0065\u0079\u0020\u006e\u006f\u0074\u0020\u0076\u0061\u006c\u0069\u0064");};_aca :=&LicenseKey {_ceb :true ,_cdg :apiKey ,_eef :true };_agfd =_aca ;return nil ;};var _ab =_deg .Date (2010,1,1,0,0,0,0,_deg .UTC );func _bae (_fd string ,_ag string ,_ece string )(string ,error ){_gff :=_gc .Index (_ece ,_fd );if _gff ==-1{return "",_gf .Errorf ("\u0068\u0065a\u0064\u0065\u0072 \u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064");};_aed :=_gc .Index (_ece ,_ag );if _aed ==-1{return "",_gf .Errorf ("\u0066\u006fo\u0074\u0065\u0072 \u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064");};_fac :=_gff +len (_fd )+1;return _ece [_fac :_aed -1],nil ;};func init (){_baec :=_eb .Getenv (_fgac );_dagb :=_eb .Getenv (_defb );if len (_baec )==0||len (_dagb )==0{return ;};_fabc ,_acg :=_d .ReadFile (_baec );if _acg !=nil {_gd .Log .Error ("\u0055\u006eab\u006c\u0065\u0020t\u006f\u0020\u0072\u0065ad \u006cic\u0065\u006e\u0073\u0065\u0020\u0063\u006fde\u0020\u0066\u0069\u006c\u0065\u003a\u0020%\u0076",_acg );return ;};_acg =SetLicenseKey (string (_fabc ),_dagb );if _acg !=nil {_gd .Log .Error ("\u0055\u006e\u0061b\u006c\u0065\u0020\u0074o\u0020\u006c\u006f\u0061\u0064\u0020\u006ci\u0063\u0065\u006e\u0073\u0065\u0020\u0063\u006f\u0064\u0065\u003a\u0020\u0025\u0076",_acg );return ;};};func _ddb (_cce ,_cadc []byte )([]byte ,error ){_bdaad :=make ([]byte ,_cd .URLEncoding .DecodedLen (len (_cadc )));_adbe ,_edg :=_cd .URLEncoding .Decode (_bdaad ,_cadc );if _edg !=nil {return nil ,_edg ;};_bdaad =_bdaad [:_adbe ];_abd ,_edg :=_ca .NewCipher (_cce );if _edg !=nil {return nil ,_edg ;};if len (_bdaad )< _ca .BlockSize {return nil ,_ac .New ("c\u0069p\u0068\u0065\u0072\u0074\u0065\u0078\u0074\u0020t\u006f\u006f\u0020\u0073ho\u0072\u0074");};_fbf :=_bdaad [:_ca .BlockSize ];_bdaad =_bdaad [_ca .BlockSize :];_cfdg :=_gg .NewCFBDecrypter (_abd ,_fbf );_cfdg .XORKeyStream (_bdaad ,_bdaad );return _bdaad ,nil ;};func (_fda *LicenseKey )getExpiryDateToCompare ()_deg .Time {if _fda .Trial {return _deg .Now ().UTC ();};return _ae .ReleasedAt ;};func GetMeteredState ()(MeteredStatus ,error ){if _agfd ==nil {return MeteredStatus {},_ac .New ("\u006c\u0069\u0063\u0065ns\u0065\u0020\u006b\u0065\u0079\u0020\u006e\u006f\u0074\u0020\u0073\u0065\u0074");};if !_agfd ._ceb ||len (_agfd ._cdg )==0{return MeteredStatus {},_ac .New ("\u0061p\u0069 \u006b\u0065\u0079\u0020\u006e\u006f\u0074\u0020\u0073\u0065\u0074");};_cfd ,_faf :=_ada .loadState (_agfd ._cdg );if _faf !=nil {_gd .Log .Error ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_faf );return MeteredStatus {},_faf ;};if _cfd .Docs > 0{_bdaa :=_ffae ("","",true );if _bdaa !=nil {return MeteredStatus {},_bdaa ;};};_ffa .Lock ();defer _ffa .Unlock ();_bea :=_cec ();_bea ._bee =_agfd ._cdg ;_ffc ,_faf :=_bea .getStatus ();if _faf !=nil {return MeteredStatus {},_faf ;};if !_ffc .Valid {return MeteredStatus {},_ac .New ("\u006b\u0065\u0079\u0020\u006e\u006f\u0074\u0020\u0076\u0061\u006c\u0069\u0064");};_ebe :=MeteredStatus {OK :true ,Credits :_ffc .OrgCredits ,Used :_ffc .OrgUsed };return _ebe ,nil ;};func (_eae *meteredClient )getStatus ()(meteredStatusResp ,error ){var _aae meteredStatusResp ;_edf :=_eae ._efb +"\u002fm\u0065t\u0065\u0072\u0065\u0064\u002f\u0073\u0074\u0061\u0074\u0075\u0073";var _fef meteredStatusForm ;_cde ,_gdg :=_ed .Marshal (_fef );if _gdg !=nil {return _aae ,_gdg ;};_cacd ,_gdg :=_fefg (_cde );if _gdg !=nil {return _aae ,_gdg ;};_caf ,_gdg :=_af .NewRequest ("\u0050\u004f\u0053\u0054",_edf ,_cacd );if _gdg !=nil {return _aae ,_gdg ;};_caf .Header .Add ("\u0043\u006f\u006et\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065","\u0061\u0070p\u006c\u0069\u0063a\u0074\u0069\u006f\u006e\u002f\u006a\u0073\u006f\u006e");_caf .Header .Add ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0067\u007a\u0069\u0070");_caf .Header .Add ("\u0041c\u0063e\u0070\u0074\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0067\u007a\u0069\u0070");_caf .Header .Add ("\u0058-\u0041\u0050\u0049\u002d\u004b\u0045Y",_eae ._bee );_bce ,_gdg :=_eae ._gafe .Do (_caf );if _gdg !=nil {return _aae ,_gdg ;};defer _bce .Body .Close ();if _bce .StatusCode !=200{return _aae ,_gf .Errorf ("\u0066\u0061i\u006c\u0065\u0064\u0020t\u006f\u0020c\u0068\u0065\u0063\u006b\u0069\u006e\u002c\u0020s\u0074\u0061\u0074\u0075\u0073\u0020\u0063\u006f\u0064\u0065\u0020\u0069s\u003a\u0020\u0025\u0064",_bce .StatusCode );};_cgd ,_gdg :=_bga (_bce );if _gdg !=nil {return _aae ,_gdg ;};_gdg =_ed .Unmarshal (_cgd ,&_aae );if _gdg !=nil {return _aae ,_gdg ;};return _aae ,nil ;};var _ada stateLoader =defaultStateHolder {};type MeteredStatus struct{OK bool ;Credits int64 ;Used int64 ;};func (_gef defaultStateHolder )updateState (_ddd ,_gb ,_dacf string ,_gab int ,_bfae bool ,_bfb int ,_ceg int ,_gcd _deg .Time ,_ggcb map[string ]int )error {_ddde :=_agd ();if len (_ddde )==0{return _ac .New ("\u0068\u006fm\u0065\u0020\u0064i\u0072\u0020\u006e\u006f\u0074\u0020\u0073\u0065\u0074");};_ega :=_fe .Join (_ddde ,"\u002eu\u006e\u0069\u0064\u006f\u0063");_gdfa :=_eb .MkdirAll (_ega ,0777);if _gdfa !=nil {return _gdfa ;};if len (_ddd )< 20{return _ac .New ("i\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006b\u0065\u0079");};_bfc :=[]byte (_ddd );_dgd :=_b .Sum512_256 (_bfc [:20]);_aac :=_ga .EncodeToString (_dgd [:]);_fcg :=_fe .Join (_ega ,_aac );var _fcd reportState ;_fcd .Docs =int64 (_gab );_fcd .NumErrors =int64 (_ceg );_fcd .LimitDocs =_bfae ;_fcd .RemainingDocs =int64 (_bfb );_fcd .LastWritten =_deg .Now ().UTC ();_fcd .LastReported =_gcd ;_fcd .Instance =_gb ;_fcd .Next =_dacf ;_fcd .Usage =_ggcb ;_adf ,_gdfa :=_ed .Marshal (_fcd );if _gdfa !=nil {return _gdfa ;};const _accg ="\u0068\u00619\u004e\u004b\u0038]\u0052\u0062\u004c\u002a\u006d\u0034\u004c\u004b\u0057";_adf ,_gdfa =_dbd ([]byte (_accg ),_adf );if _gdfa !=nil {return _gdfa ;};_gdfa =_d .WriteFile (_fcg ,_adf ,0600);if _gdfa !=nil {return _gdfa ;};return nil ;};func (_deb *meteredClient )checkinUsage (_bbb meteredUsageCheckinForm )(meteredUsageCheckinResp ,error ){_bbb .Package ="\u0075n\u0069\u006f\u0066\u0066\u0069\u0063e";_bbb .PackageVersion =_ae .Version ;var _bda meteredUsageCheckinResp ;_cad :=_deb ._efb +"\u002f\u006d\u0065\u0074er\u0065\u0064\u002f\u0075\u0073\u0061\u0067\u0065\u005f\u0063\u0068\u0065\u0063\u006bi\u006e";_cda ,_cag :=_ed .Marshal (_bbb );if _cag !=nil {return _bda ,_cag ;};_fbe ,_cag :=_fefg (_cda );if _cag !=nil {return _bda ,_cag ;};_eab ,_cag :=_af .NewRequest ("\u0050\u004f\u0053\u0054",_cad ,_fbe );if _cag !=nil {return _bda ,_cag ;};_eab .Header .Add ("\u0043\u006f\u006et\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065","\u0061\u0070p\u006c\u0069\u0063a\u0074\u0069\u006f\u006e\u002f\u006a\u0073\u006f\u006e");_eab .Header .Add ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0067\u007a\u0069\u0070");_eab .Header .Add ("\u0041c\u0063e\u0070\u0074\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0067\u007a\u0069\u0070");_eab .Header .Add ("\u0058-\u0041\u0050\u0049\u002d\u004b\u0045Y",_deb ._bee );_abg ,_cag :=_deb ._gafe .Do (_eab );if _cag !=nil {_gd .Log .Error ("\u0049n\u0076\u0061\u006c\u0069d\u0020\u0068\u0074\u0074\u0070 \u0072e\u0073p\u006f\u006e\u0073\u0065\u003a\u0020\u0025v",_cag );return _bda ,_cag ;};defer _abg .Body .Close ();if _abg .StatusCode !=200{_bfa ,_gec :=_bga (_abg );if _gec !=nil {return _bda ,_gec ;};_gec =_ed .Unmarshal (_bfa ,&_bda );if _gec !=nil {return _bda ,_gec ;};return _bda ,_gf .Errorf ("\u0066\u0061i\u006c\u0065\u0064\u0020t\u006f\u0020c\u0068\u0065\u0063\u006b\u0069\u006e\u002c\u0020s\u0074\u0061\u0074\u0075\u0073\u0020\u0063\u006f\u0064\u0065\u0020\u0069s\u003a\u0020\u0025\u0064",_abg .StatusCode );};_feag :=_abg .Header .Get ("\u0058\u002d\u0055\u0043\u002d\u0053\u0069\u0067\u006ea\u0074\u0075\u0072\u0065");_fdf :=_gefa (_bbb .MacAddress ,string (_cda ));if _fdf !=_feag {_gd .Log .Error ("I\u006e\u0076\u0061l\u0069\u0064\u0020\u0072\u0065\u0073\u0070\u006f\u006e\u0073\u0065\u0020\u0073\u0069\u0067\u006e\u0061\u0074\u0075\u0072\u0065\u002c\u0020\u0073\u0065t\u0020\u0074\u0068e\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0020\u0073\u0065\u0072\u0076e\u0072\u0020\u0074\u006f \u0068\u0074\u0074\u0070s\u003a\u002f\u002f\u0063\u006c\u006f\u0075\u0064\u002e\u0075\u006e\u0069\u0064\u006f\u0063\u002e\u0069o\u002f\u0061\u0070\u0069");return _bda ,_ac .New ("\u0066\u0061\u0069l\u0065\u0064\u0020\u0074\u006f\u0020\u0063\u0068\u0065\u0063\u006b\u0069\u006e\u002c\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0073\u0065\u0072\u0076\u0065\u0072 \u0072\u0065\u0073\u0070\u006f\u006e\u0073\u0065");};_gdgf ,_cag :=_bga (_abg );if _cag !=nil {return _bda ,_cag ;};_cag =_ed .Unmarshal (_gdgf ,&_bda );if _cag !=nil {return _bda ,_cag ;};return _bda ,nil ;};func _cec ()*meteredClient {_bagd :=meteredClient {_efb :"h\u0074\u0074\u0070\u0073\u003a\u002f/\u0063\u006c\u006f\u0075\u0064\u002e\u0075\u006e\u0069d\u006f\u0063\u002ei\u006f/\u0061\u0070\u0069",_gafe :&_af .Client {Timeout :30*_deg .Second }};if _bf :=_eb .Getenv ("\u0055N\u0049\u0044\u004f\u0043_\u004c\u0049\u0043\u0045\u004eS\u0045_\u0053E\u0052\u0056\u0045\u0052\u005f\u0055\u0052L");_gc .HasPrefix (_bf ,"\u0068\u0074\u0074\u0070"){_bagd ._efb =_bf ;};return &_bagd ;};var _geg =false ;