github.com/unidoc/unipdf/v3@v3.55.0/internal/license/license.go (about) 1 // 2 // Copyright 2020 FoxyUtils ehf. All rights reserved. 3 // 4 // This is a commercial product and requires a license to operate. 5 // A trial license can be obtained at https://unidoc.io 6 // 7 // DO NOT EDIT: generated by unitwist Go source code obfuscator. 8 // 9 // Use of this source code is governed by the UniDoc End User License Agreement 10 // terms that can be accessed at https://unidoc.io/eula/ 11 12 package license ;import (_dg "bytes";_g "compress/gzip";_b "crypto";_ea "crypto/aes";_cc "crypto/cipher";_da "crypto/hmac";_db "crypto/rand";_df "crypto/rsa";_de "crypto/sha256";_ab "crypto/sha512";_dag "crypto/x509";_ef "encoding/base64";_gg "encoding/hex"; 13 _aa "encoding/json";_cae "encoding/pem";_ae "errors";_e "fmt";_abg "github.com/unidoc/unipdf/v3/common";_bg "io";_bf "io/ioutil";_ca "net";_a "net/http";_cd "os";_f "path/filepath";_d "sort";_bb "strings";_ga "sync";_ge "time";);var _ccbf map[string ]struct{}; 14 func _cdcef ()(_ca .IP ,error ){_daa ,_adbb :=_ca .Dial ("\u0075\u0064\u0070","\u0038\u002e\u0038\u002e\u0038\u002e\u0038\u003a\u0038\u0030");if _adbb !=nil {return nil ,_adbb ;};defer _daa .Close ();_ebc :=_daa .LocalAddr ().(*_ca .UDPAddr );return _ebc .IP ,nil ; 15 };func (_eg *LicenseKey )IsLicensed ()bool {return _eg .Tier !=LicenseTierUnlicensed ||_eg ._daga };func MakeUnlicensedKey ()*LicenseKey {_cee :=LicenseKey {};_cee .CustomerName ="\u0055\u006e\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0064";_cee .Tier =LicenseTierUnlicensed ; 16 _cee .CreatedAt =_ge .Now ().UTC ();_cee .CreatedAtInt =_cee .CreatedAt .Unix ();return &_cee ;};const _cfa ="\u0055N\u0049D\u004f\u0043\u005f\u004c\u0049C\u0045\u004eS\u0045\u005f\u0044\u0049\u0052";func _fc (_ad string ,_efb string )([]byte ,error ){var (_aab int ; 17 _fgf string ;);for _ ,_fgf =range []string {"\u000a\u002b\u000a","\u000d\u000a\u002b\r\u000a","\u0020\u002b\u0020"}{if _aab =_bb .Index (_efb ,_fgf );_aab !=-1{break ;};};if _aab ==-1{return nil ,_e .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"); 18 };_be :=_efb [:_aab ];_ee :=_aab +len (_fgf );_eb :=_efb [_ee :];if _be ==""||_eb ==""{return nil ,_e .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"); 19 };_ggb ,_fgg :=_ef .StdEncoding .DecodeString (_be );if _fgg !=nil {return nil ,_e .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0070\u0075\u0074\u0020\u006f\u0072\u0069\u0067\u0069\u006ea\u006c");};_gf ,_fgg :=_ef .StdEncoding .DecodeString (_eb ); 20 if _fgg !=nil {return nil ,_e .Errorf ("\u0069\u006e\u0076al\u0069\u0064\u0020\u0069\u006e\u0070\u0075\u0074\u0020\u0073\u0069\u0067\u006e\u0061\u0074\u0075\u0072\u0065");};_eab ,_ :=_cae .Decode ([]byte (_ad ));if _eab ==nil {return nil ,_e .Errorf ("\u0050\u0075\u0062\u004b\u0065\u0079\u0020\u0066\u0061\u0069\u006c\u0065\u0064"); 21 };_cb ,_fgg :=_dag .ParsePKIXPublicKey (_eab .Bytes );if _fgg !=nil {return nil ,_fgg ;};_afc :=_cb .(*_df .PublicKey );if _afc ==nil {return nil ,_e .Errorf ("\u0050u\u0062\u004b\u0065\u0079\u0020\u0063\u006f\u006e\u0076\u0065\u0072s\u0069\u006f\u006e\u0020\u0066\u0061\u0069\u006c\u0065\u0064"); 22 };_cgd :=_ab .New ();_cgd .Write (_ggb );_bgd :=_cgd .Sum (nil );_fgg =_df .VerifyPKCS1v15 (_afc ,_b .SHA512 ,_bgd ,_gf );if _fgg !=nil {return nil ,_fgg ;};return _ggb ,nil ;};func _adf ()*meteredClient {_bc :=meteredClient {_aee :"h\u0074\u0074\u0070\u0073\u003a\u002f/\u0063\u006c\u006f\u0075\u0064\u002e\u0075\u006e\u0069d\u006f\u0063\u002ei\u006f/\u0061\u0070\u0069",_ceg :&_a .Client {Timeout :30*_ge .Second }}; 23 if _cf :=_cd .Getenv ("\u0055N\u0049\u0044\u004f\u0043_\u004c\u0049\u0043\u0045\u004eS\u0045_\u0053E\u0052\u0056\u0045\u0052\u005f\u0055\u0052L");_bb .HasPrefix (_cf ,"\u0068\u0074\u0074\u0070"){_bc ._aee =_cf ;};return &_bc ;};type reportState struct{Instance string `json:"inst"`; 24 Next string `json:"n"`;Docs int64 `json:"d"`;NumErrors int64 `json:"e"`;LimitDocs bool `json:"ld"`;RemainingDocs int64 `json:"rd"`;LastReported _ge .Time `json:"lr"`;LastWritten _ge .Time `json:"lw"`;Usage map[string ]int `json:"u"`;};func (_fbga defaultStateHolder )loadState (_agg string )(reportState ,error ){_gea ,_ccd :=_fbgc (); 25 if _ccd !=nil {return reportState {},_ccd ;};_ccd =_cd .MkdirAll (_gea ,0777);if _ccd !=nil {return reportState {},_ccd ;};if len (_agg )< 20{return reportState {},_ae .New ("i\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006b\u0065\u0079");};_aggf :=[]byte (_agg ); 26 _dcg :=_ab .Sum512_256 (_aggf [:20]);_fdae :=_gg .EncodeToString (_dcg [:]);_ffg :=_f .Join (_gea ,_fdae );_faeg ,_ccd :=_bf .ReadFile (_ffg );if _ccd !=nil {if _cd .IsNotExist (_ccd ){return reportState {},nil ;};_abg .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_ccd ); 27 return reportState {},_ae .New ("\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0061");};const _fe ="\u0068\u00619\u004e\u004b\u0038]\u0052\u0062\u004c\u002a\u006d\u0034\u004c\u004b\u0057";_faeg ,_ccd =_eae ([]byte (_fe ),_faeg );if _ccd !=nil {return reportState {},_ccd ; 28 };var _eed reportState ;_ccd =_aa .Unmarshal (_faeg ,&_eed );if _ccd !=nil {_abg .Log .Debug ("\u0045\u0052\u0052OR\u003a\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0061\u003a\u0020\u0025\u0076",_ccd );return reportState {},_ae .New ("\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0061"); 29 };return _eed ,nil ;};type meteredClient struct{_aee string ;_daf string ;_ceg *_a .Client ;};func (_ec *LicenseKey )Validate ()error {if _ec ._daga {return nil ;};if len (_ec .LicenseId )< 10{return _e .Errorf ("i\u006e\u0076\u0061\u006c\u0069\u0064 \u006c\u0069\u0063\u0065\u006e\u0073\u0065\u003a\u0020L\u0069\u0063\u0065n\u0073e\u0020\u0049\u0064"); 30 };if len (_ec .CustomerId )< 10{return _e .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 (_ec .CustomerName )< 1{return _e .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"); 31 };if _cge .After (_ec .CreatedAt ){return _e .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"); 32 };if _ec .ExpiresAt ==nil {_dbag :=_ec .CreatedAt .AddDate (1,0,0);if _abd .After (_dbag ){_dbag =_abd ;};_ec .ExpiresAt =&_dbag ;};if _ec .CreatedAt .After (*_ec .ExpiresAt ){return _e .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"); 33 };if _ec .isExpired (){_aff :="\u0054\u0068\u0065\u0020\u006c\u0069c\u0065\u006e\u0073\u0065\u0020\u0068\u0061\u0073\u0020\u0061\u006c\u0072\u0065a\u0064\u0079\u0020\u0065\u0078\u0070\u0069r\u0065\u0064\u002e\u000a"+"\u0059o\u0075\u0020\u006d\u0061y\u0020n\u0065\u0065\u0064\u0020\u0074\u006f\u0020\u0075\u0070d\u0061\u0074\u0065\u0020\u0074\u0068\u0065\u0020l\u0069\u0063\u0065\u006e\u0073\u0065\u0020\u006b\u0065\u0079\u0020t\u006f\u0020\u0074\u0068\u0065\u0020\u006e\u0065\u0077\u0065s\u0074\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0020\u006b\u0065\u0079\u0020\u0066\u006f\u0072\u0020\u0079o\u0075\u0072\u0020\u006f\u0072\u0067\u0061\u006e\u0069\u007a\u0061\u0074i\u006fn\u002e\u000a"+"\u0054o\u0020\u0066\u0069\u006ed y\u006f\u0075\u0072\u0020n\u0065\u0077\u0065\u0073\u0074\u0020\u006c\u0069\u0063\u0065n\u0073\u0065\u0020\u006b\u0065\u0079\u002c\u0020\u0067\u006f\u0020\u0074\u006f\u0020\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0063l\u006f\u0075\u0064\u002e\u0075\u006e\u0069\u0064oc\u002e\u0069\u006f \u0061\u006e\u0064\u0020\u0067o\u0020t\u006f\u0020\u0074\u0068\u0065\u0020\u006c\u0069\u0063e\u006e\u0073\u0065\u0020\u006d\u0065\u006e\u0075\u002e"; 34 return _e .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u003a\u0020\u0025\u0073",_aff );};if len (_ec .CreatorName )< 1{return _e .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"); 35 };if len (_ec .CreatorEmail )< 1{return _e .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 _ec .CreatedAt .After (_ebd ){if !_ec .UniPDF {return _e .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065:\u0020\u0054\u0068\u0069\u0073\u0020\u0055\u006e\u0069\u0044\u006f\u0063\u0020k\u0065\u0079\u0020\u0069\u0073\u0020\u0069\u006e\u0076\u0061\u006c\u0069d \u0066\u006f\u0072\u0020\u0055\u006e\u0069\u0050\u0044\u0046"); 36 };};return nil ;};type LicenseKey struct{LicenseId string `json:"license_id"`;CustomerId string `json:"customer_id"`;CustomerName string `json:"customer_name"`;Tier string `json:"tier"`;CreatedAt _ge .Time `json:"-"`;CreatedAtInt int64 `json:"created_at"`; 37 ExpiresAt *_ge .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"`; 38 UniHTML bool `json:"unihtml"`;Trial bool `json:"trial"`;_daga bool ;_cca string ;_dfg bool ;};const _ccbd ="\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"; 39 func _dfga (_eaf *_a .Response )(_bg .ReadCloser ,error ){var _fdc error ;var _dbda _bg .ReadCloser ;switch _bb .ToLower (_eaf .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067")){case "\u0067\u007a\u0069\u0070":_dbda ,_fdc =_g .NewReader (_eaf .Body ); 40 if _fdc !=nil {return _dbda ,_fdc ;};defer _dbda .Close ();default:_dbda =_eaf .Body ;};return _dbda ,nil ;};func _ggee (_gebc []byte )(_bg .Reader ,error ){_geef :=new (_dg .Buffer );_cdb :=_g .NewWriter (_geef );_cdb .Write (_gebc );_fbcc :=_cdb .Close (); 41 if _fbcc !=nil {return nil ,_fbcc ;};return _geef ,nil ;};func GetMeteredState ()(MeteredStatus ,error ){if _gbf ==nil {return MeteredStatus {},_ae .New ("\u006c\u0069\u0063\u0065ns\u0065\u0020\u006b\u0065\u0079\u0020\u006e\u006f\u0074\u0020\u0073\u0065\u0074"); 42 };if !_gbf ._daga ||len (_gbf ._cca )==0{return MeteredStatus {},_ae .New ("\u0061p\u0069 \u006b\u0065\u0079\u0020\u006e\u006f\u0074\u0020\u0073\u0065\u0074");};_abf ,_deb :=_abgd .loadState (_gbf ._cca );if _deb !=nil {_abg .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_deb ); 43 return MeteredStatus {},_deb ;};if _abf .Docs > 0{_dbgg :=_adff ("","",true );if _dbgg !=nil {return MeteredStatus {},_dbgg ;};};_afd .Lock ();defer _afd .Unlock ();_gc :=_adf ();_gc ._daf =_gbf ._cca ;_fb ,_deb :=_gc .getStatus ();if _deb !=nil {return MeteredStatus {},_deb ; 44 };if !_fb .Valid {return MeteredStatus {},_ae .New ("\u006b\u0065\u0079\u0020\u006e\u006f\u0074\u0020\u0076\u0061\u006c\u0069\u0064");};_dabg :=MeteredStatus {OK :true ,Credits :_fb .OrgCredits ,Used :_fb .OrgUsed };return _dabg ,nil ;};var _gbf =MakeUnlicensedKey (); 45 var _abd =_ge .Date (2020,1,1,0,0,0,0,_ge .UTC );func _adff (_cef string ,_gffb string ,_cdce bool )error {if _gbf ==nil {return _ae .New ("\u006e\u006f\u0020\u006c\u0069\u0063\u0065\u006e\u0073e\u0020\u006b\u0065\u0079");};if !_gbf ._daga ||len (_gbf ._cca )==0{return nil ; 46 };if len (_cef )==0&&!_cdce {return _ae .New ("\u0064\u006f\u0063\u004b\u0065\u0079\u0020\u006e\u006ft\u0020\u0073\u0065\u0074");};_afd .Lock ();defer _afd .Unlock ();if _ccbf ==nil {_ccbf =map[string ]struct{}{};};if _ddc ==nil {_ddc =map[string ]int {}; 47 };_fbb :=0;if len (_cef )> 0{_ ,_add :=_ccbf [_cef ];if !_add {_ccbf [_cef ]=struct{}{};_fbb ++;};};if _fbb ==0&&!_cdce {return nil ;};_ddc [_gffb ]++;_cefa :=_ge .Now ();_dda ,_ecb :=_abgd .loadState (_gbf ._cca );if _ecb !=nil {_abg .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_ecb ); 48 return _ecb ;};if _dda .Usage ==nil {_dda .Usage =map[string ]int {};};for _bcc ,_dabf :=range _ddc {if _bcc !=""{_dda .Usage [_bcc ]+=_dabf ;};};_ddc =nil ;const _faa =24*_ge .Hour ;const _bagc =3*24*_ge .Hour ;if len (_dda .Instance )==0||_cefa .Sub (_dda .LastReported )> _faa ||(_dda .LimitDocs &&_dda .RemainingDocs <=_dda .Docs +int64 (_fbb ))||_cdce {_gde ,_bbfa :=_cd .Hostname (); 49 if _bbfa !=nil {return _bbfa ;};_fbcb :=_dda .Docs ;_ecg ,_cefc ,_bbfa :=_acd ();if _bbfa !=nil {_abg .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",_bbfa .Error ()); 50 _ecg =append (_ecg ,"\u0069n\u0066\u006f\u0072\u006da\u0074\u0069\u006f\u006e\u0020n\u006ft\u0020a\u0076\u0061\u0069\u006c\u0061\u0062\u006ce");_cefc =append (_cefc ,"\u0069n\u0066\u006f\u0072\u006da\u0074\u0069\u006f\u006e\u0020n\u006ft\u0020a\u0076\u0061\u0069\u006c\u0061\u0062\u006ce"); 51 }else {_d .Strings (_cefc );_d .Strings (_ecg );_eag ,_ccf :=_cdcef ();if _ccf !=nil {return _ccf ;};_dcd :=false ;for _ ,_gad :=range _cefc {if _gad ==_eag .String (){_dcd =true ;};};if !_dcd {_cefc =append (_cefc ,_eag .String ());};};_cefe :=_adf (); 52 _cefe ._daf =_gbf ._cca ;_fbcb +=int64 (_fbb );_bbdc :=meteredUsageCheckinForm {Instance :_dda .Instance ,Next :_dda .Next ,UsageNumber :int (_fbcb ),NumFailed :_dda .NumErrors ,Hostname :_gde ,LocalIP :_bb .Join (_cefc ,"\u002c\u0020"),MacAddress :_bb .Join (_ecg ,"\u002c\u0020"),Package :"\u0075\u006e\u0069\u0070\u0064\u0066",PackageVersion :_abg .Version ,Usage :_dda .Usage ,IsPersistentCache :_gbf ._dfg ,Timestamp :_cefa .Unix ()}; 53 if len (_ecg )==0{_bbdc .MacAddress ="\u006e\u006f\u006e\u0065";};_gcf :=int64 (0);_eadc :=_dda .NumErrors ;_afb :=_cefa ;_def :=0;_fbge :=_dda .LimitDocs ;_bad ,_bbfa :=_cefe .checkinUsage (_bbdc );if _bbfa !=nil {if _cefa .Sub (_dda .LastReported )> _bagc {if !_bad .Success {return _ae .New (_bad .Message ); 54 };return _ae .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");};_gcf =_fbcb ;_eadc ++; 55 _afb =_dda .LastReported ;}else {_fbge =_bad .LimitDocs ;_def =_bad .RemainingDocs ;_eadc =0;};if len (_bad .Instance )==0{_bad .Instance =_bbdc .Instance ;};if len (_bad .Next )==0{_bad .Next =_bbdc .Next ;};_bbfa =_abgd .updateState (_cefe ._daf ,_bad .Instance ,_bad .Next ,int (_gcf ),_fbge ,_def ,int (_eadc ),_afb ,nil ); 56 if _bbfa !=nil {return _bbfa ;};if !_bad .Success {return _e .Errorf ("\u0065r\u0072\u006f\u0072\u003a\u0020\u0025s",_bad .Message );};}else {_ecb =_abgd .updateState (_gbf ._cca ,_dda .Instance ,_dda .Next ,int (_dda .Docs )+_fbb ,_dda .LimitDocs ,int (_dda .RemainingDocs ),int (_dda .NumErrors ),_dda .LastReported ,_dda .Usage ); 57 if _ecb !=nil {return _ecb ;};};return nil ;};const _eea ="\u0055\u004e\u0049\u0050DF\u005f\u004c\u0049\u0043\u0045\u004e\u0053\u0045\u005f\u0050\u0041\u0054\u0048";func (_cbb *LicenseKey )getExpiryDateToCompare ()_ge .Time {if _cbb .Trial {return _ge .Now ().UTC (); 58 };return _abg .ReleasedAt ;};func _ed (_ade string )(LicenseKey ,error ){var _cdc LicenseKey ;_bd ,_aae :=_ccgg (_ccg ,_cg ,_ade );if _aae !=nil {return _cdc ,_aae ;};_fa ,_aae :=_fc (_ccbd ,_bd );if _aae !=nil {return _cdc ,_aae ;};_aae =_aa .Unmarshal (_fa ,&_cdc ); 59 if _aae !=nil {return _cdc ,_aae ;};_cdc .CreatedAt =_ge .Unix (_cdc .CreatedAtInt ,0);if _cdc .ExpiresAtInt > 0{_dba :=_ge .Unix (_cdc .ExpiresAtInt ,0);_cdc .ExpiresAt =&_dba ;};return _cdc ,nil ;};func GetLicenseKey ()*LicenseKey {if _gbf ==nil {return nil ; 60 };_ccc :=*_gbf ;return &_ccc ;};type MeteredStatus struct{OK bool ;Credits int64 ;Used int64 ;};var _cge =_ge .Date (2010,1,1,0,0,0,0,_ge .UTC );type stateLoader interface{loadState (_bgg string )(reportState ,error );updateState (_bac ,_bgb ,_eac string ,_acf int ,_eff bool ,_egg int ,_aag int ,_bed _ge .Time ,_dd map[string ]int )error ; 61 };func (_dbae defaultStateHolder )updateState (_bag ,_cec ,_cgcd string ,_fbg int ,_ced bool ,_ccb int ,_ebde int ,_abc _ge .Time ,_fga map[string ]int )error {_fbc ,_cad :=_fbgc ();if _cad !=nil {return _cad ;};if len (_bag )< 20{return _ae .New ("i\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006b\u0065\u0079"); 62 };_geb :=[]byte (_bag );_fae :=_ab .Sum512_256 (_geb [:20]);_acfd :=_gg .EncodeToString (_fae [:]);_gff :=_f .Join (_fbc ,_acfd );var _gdg reportState ;_gdg .Docs =int64 (_fbg );_gdg .NumErrors =int64 (_ebde );_gdg .LimitDocs =_ced ;_gdg .RemainingDocs =int64 (_ccb ); 63 _gdg .LastWritten =_ge .Now ().UTC ();_gdg .LastReported =_abc ;_gdg .Instance =_cec ;_gdg .Next =_cgcd ;_gdg .Usage =_fga ;_cfb ,_cad :=_aa .Marshal (_gdg );if _cad !=nil {return _cad ;};const _bga ="\u0068\u00619\u004e\u004b\u0038]\u0052\u0062\u004c\u002a\u006d\u0034\u004c\u004b\u0057"; 64 _cfb ,_cad =_ceb ([]byte (_bga ),_cfb );if _cad !=nil {return _cad ;};_cad =_bf .WriteFile (_gff ,_cfb ,0600);if _cad !=nil {return _cad ;};return nil ;};func _bdf (_dbad *_a .Response )([]byte ,error ){var _aabg []byte ;_dgf ,_edba :=_dfga (_dbad );if _edba !=nil {return _aabg ,_edba ; 65 };return _bf .ReadAll (_dgf );};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"`;};type meteredStatusForm struct{}; 66 func (_cde *LicenseKey )ToString ()string {if _cde ._daga {return "M\u0065t\u0065\u0072\u0065\u0064\u0020\u0073\u0075\u0062s\u0063\u0072\u0069\u0070ti\u006f\u006e";};_dfgf :=_e .Sprintf ("\u004ci\u0063e\u006e\u0073\u0065\u0020\u0049\u0064\u003a\u0020\u0025\u0073\u000a",_cde .LicenseId ); 67 _dfgf +=_e .Sprintf ("\u0043\u0075s\u0074\u006f\u006de\u0072\u0020\u0049\u0064\u003a\u0020\u0025\u0073\u000a",_cde .CustomerId );_dfgf +=_e .Sprintf ("\u0043u\u0073t\u006f\u006d\u0065\u0072\u0020N\u0061\u006de\u003a\u0020\u0025\u0073\u000a",_cde .CustomerName ); 68 _dfgf +=_e .Sprintf ("\u0054i\u0065\u0072\u003a\u0020\u0025\u0073\n",_cde .Tier );_dfgf +=_e .Sprintf ("\u0043r\u0065a\u0074\u0065\u0064\u0020\u0041\u0074\u003a\u0020\u0025\u0073\u000a",_abg .UtcTimeFormat (_cde .CreatedAt ));if _cde .ExpiresAt ==nil {_dfgf +="\u0045x\u0070i\u0072\u0065\u0073\u0020\u0041t\u003a\u0020N\u0065\u0076\u0065\u0072\u000a"; 69 }else {_dfgf +=_e .Sprintf ("\u0045x\u0070i\u0072\u0065\u0073\u0020\u0041\u0074\u003a\u0020\u0025\u0073\u000a",_abg .UtcTimeFormat (*_cde .ExpiresAt ));};_dfgf +=_e .Sprintf ("\u0043\u0072\u0065\u0061\u0074\u006f\u0072\u003a\u0020\u0025\u0073\u0020<\u0025\u0073\u003e\u000a",_cde .CreatorName ,_cde .CreatorEmail ); 70 return _dfgf ;};const (_ccg ="\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";_cg ="\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"; 71 );func _eae (_gaa ,_cfg []byte )([]byte ,error ){_gcd :=make ([]byte ,_ef .URLEncoding .DecodedLen (len (_cfg )));_eafg ,_edcg :=_ef .URLEncoding .Decode (_gcd ,_cfg );if _edcg !=nil {return nil ,_edcg ;};_gcd =_gcd [:_eafg ];_eadb ,_edcg :=_ea .NewCipher (_gaa ); 72 if _edcg !=nil {return nil ,_edcg ;};if len (_gcd )< _ea .BlockSize {return nil ,_ae .New ("c\u0069p\u0068\u0065\u0072\u0074\u0065\u0078\u0074\u0020t\u006f\u006f\u0020\u0073ho\u0072\u0074");};_fec :=_gcd [:_ea .BlockSize ];_gcd =_gcd [_ea .BlockSize :]; 73 _agf :=_cc .NewCFBDecrypter (_eadb ,_fec );_agf .XORKeyStream (_gcd ,_gcd );return _gcd ,nil ;};func TrackUse (useKey string ){if _gbf ==nil {return ;};if !_gbf ._daga ||len (_gbf ._cca )==0{return ;};if len (useKey )==0{return ;};_afd .Lock ();defer _afd .Unlock (); 74 if _ddc ==nil {_ddc =map[string ]int {};};_ddc [useKey ]++;};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"`; 75 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"`; 76 };type defaultStateHolder struct{};func _af (_ba string ,_fg []byte )(string ,error ){_cgc ,_ :=_cae .Decode ([]byte (_ba ));if _cgc ==nil {return "",_e .Errorf ("\u0050\u0072\u0069\u0076\u004b\u0065\u0079\u0020\u0066a\u0069\u006c\u0065\u0064");};_afe ,_gb :=_dag .ParsePKCS1PrivateKey (_cgc .Bytes ); 77 if _gb !=nil {return "",_gb ;};_ag :=_ab .New ();_ag .Write (_fg );_ccge :=_ag .Sum (nil );_gee ,_gb :=_df .SignPKCS1v15 (_db .Reader ,_afe ,_b .SHA512 ,_ccge );if _gb !=nil {return "",_gb ;};_dbc :=_ef .StdEncoding .EncodeToString (_fg );_dbc +="\u000a\u002b\u000a"; 78 _dbc +=_ef .StdEncoding .EncodeToString (_gee );return _dbc ,nil ;};func _ceb (_cedf ,_ddcd []byte )([]byte ,error ){_eggb ,_gfe :=_ea .NewCipher (_cedf );if _gfe !=nil {return nil ,_gfe ;};_dee :=make ([]byte ,_ea .BlockSize +len (_ddcd ));_efa :=_dee [:_ea .BlockSize ]; 79 if _ ,_aeg :=_bg .ReadFull (_db .Reader ,_efa );_aeg !=nil {return nil ,_aeg ;};_dfc :=_cc .NewCFBEncrypter (_eggb ,_efa );_dfc .XORKeyStream (_dee [_ea .BlockSize :],_ddcd );_gadd :=make ([]byte ,_ef .URLEncoding .EncodedLen (len (_dee )));_ef .URLEncoding .Encode (_gadd ,_dee ); 80 return _gadd ,nil ;};var _ddc map[string ]int ;var _ebd =_ge .Date (2019,6,6,0,0,0,0,_ge .UTC );func _ccgg (_bbf string ,_adc string ,_dgb string )(string ,error ){_agd :=_bb .Index (_dgb ,_bbf );if _agd ==-1{return "",_e .Errorf ("\u0068\u0065a\u0064\u0065\u0072 \u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064"); 81 };_dac :=_bb .Index (_dgb ,_adc );if _dac ==-1{return "",_e .Errorf ("\u0066\u006fo\u0074\u0065\u0072 \u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064");};_bbd :=_agd +len (_bbf )+1;return _dgb [_bbd :_dac -1],nil ;};func _acd ()([]string ,[]string ,error ){_bdb ,_ffa :=_ca .Interfaces (); 82 if _ffa !=nil {return nil ,nil ,_ffa ;};var _gag []string ;var _bggg []string ;for _ ,_adef :=range _bdb {if _adef .Flags &_ca .FlagUp ==0||_dg .Equal (_adef .HardwareAddr ,nil ){continue ;};_cdf ,_dbd :=_adef .Addrs ();if _dbd !=nil {return nil ,nil ,_dbd ; 83 };_fed :=0;for _ ,_dbdc :=range _cdf {var _aga _ca .IP ;switch _cbe :=_dbdc .(type ){case *_ca .IPNet :_aga =_cbe .IP ;case *_ca .IPAddr :_aga =_cbe .IP ;};if _aga .IsLoopback (){continue ;};if _aga .To4 ()==nil {continue ;};_bggg =append (_bggg ,_aga .String ()); 84 _fed ++;};_faab :=_adef .HardwareAddr .String ();if _faab !=""&&_fed > 0{_gag =append (_gag ,_faab );};};return _gag ,_bggg ,nil ;};func (_dae *LicenseKey )isExpired ()bool {return _dae .getExpiryDateToCompare ().After (*_dae .ExpiresAt )};func Track (docKey string ,useKey string )error {return _adff (docKey ,useKey ,!_gbf ._dfg )}; 85 const _ccda ="U\u004eI\u0050\u0044\u0046\u005f\u0043\u0055\u0053\u0054O\u004d\u0045\u0052\u005fNA\u004d\u0045";func SetLicenseKey (content string ,customerName string )error {_gae ,_edcd :=_ed (content );if _edcd !=nil {_abg .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",_edcd ); 86 return _edcd ;};if !_bb .EqualFold (_gae .CustomerName ,customerName ){_abg .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",_gae .CustomerName ,customerName ); 87 return _e .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'",_gae .CustomerName ,customerName ); 88 };_edcd =_gae .Validate ();if _edcd !=nil {_abg .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",_edcd ); 89 return _edcd ;};_gbf =&_gae ;return nil ;};func (_bba *meteredClient )getStatus ()(meteredStatusResp ,error ){var _ff meteredStatusResp ;_ead :=_bba ._aee +"\u002fm\u0065t\u0065\u0072\u0065\u0064\u002f\u0073\u0074\u0061\u0074\u0075\u0073";var _dea meteredStatusForm ; 90 _fge ,_gd :=_aa .Marshal (_dea );if _gd !=nil {return _ff ,_gd ;};_ffe ,_gd :=_ggee (_fge );if _gd !=nil {return _ff ,_gd ;};_gbg ,_gd :=_a .NewRequest ("\u0050\u004f\u0053\u0054",_ead ,_ffe );if _gd !=nil {return _ff ,_gd ;};_gbg .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"); 91 _gbg .Header .Add ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0067\u007a\u0069\u0070");_gbg .Header .Add ("\u0041c\u0063e\u0070\u0074\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0067\u007a\u0069\u0070"); 92 _gbg .Header .Add ("\u0058-\u0041\u0050\u0049\u002d\u004b\u0045Y",_bba ._daf );_bca ,_gd :=_bba ._ceg .Do (_gbg );if _gd !=nil {return _ff ,_gd ;};defer _bca .Body .Close ();if _bca .StatusCode !=200{return _ff ,_e .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",_bca .StatusCode ); 93 };_edc ,_gd :=_bdf (_bca );if _gd !=nil {return _ff ,_gd ;};_gd =_aa .Unmarshal (_edc ,&_ff );if _gd !=nil {return _ff ,_gd ;};return _ff ,nil ;};const (LicenseTierUnlicensed ="\u0075\u006e\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0064";LicenseTierCommunity ="\u0063o\u006d\u006d\u0075\u006e\u0069\u0074y"; 94 LicenseTierIndividual ="\u0069\u006e\u0064\u0069\u0076\u0069\u0064\u0075\u0061\u006c";LicenseTierBusiness ="\u0062\u0075\u0073\u0069\u006e\u0065\u0073\u0073";);var _abgd stateLoader =defaultStateHolder {};func init (){_cce :=_cd .Getenv (_eea );_efe :=_cd .Getenv (_ccda ); 95 if len (_cce )==0||len (_efe )==0{return ;};_edb ,_fac :=_bf .ReadFile (_cce );if _fac !=nil {_abg .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",_fac ); 96 return ;};_fac =SetLicenseKey (string (_edb ),_efe );if _fac !=nil {_abg .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",_fac ); 97 return ;};};type meteredStatusResp struct{Valid bool `json:"valid"`;OrgCredits int64 `json:"org_credits"`;OrgUsed int64 `json:"org_used"`;OrgRemaining int64 `json:"org_remaining"`;};func (_ce *LicenseKey )TypeToString ()string {if _ce ._daga {return "M\u0065t\u0065\u0072\u0065\u0064\u0020\u0073\u0075\u0062s\u0063\u0072\u0069\u0070ti\u006f\u006e"; 98 };if _ce .Tier ==LicenseTierUnlicensed {return "\u0055\u006e\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0064";};if _ce .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"; 99 };if _ce .Tier ==LicenseTierIndividual ||_ce .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"; 100 };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 (_dbg *meteredClient )checkinUsage (_aeb meteredUsageCheckinForm )(meteredUsageCheckinResp ,error ){_aeb .Package ="\u0075\u006e\u0069\u0070\u0064\u0066"; 101 _aeb .PackageVersion =_abg .Version ;var _gge meteredUsageCheckinResp ;_ac :=_dbg ._aee +"\u002f\u006d\u0065\u0074er\u0065\u0064\u002f\u0075\u0073\u0061\u0067\u0065\u005f\u0063\u0068\u0065\u0063\u006bi\u006e";_bgf ,_dfd :=_aa .Marshal (_aeb );if _dfd !=nil {return _gge ,_dfd ; 102 };_fd ,_dfd :=_ggee (_bgf );if _dfd !=nil {return _gge ,_dfd ;};_fda ,_dfd :=_a .NewRequest ("\u0050\u004f\u0053\u0054",_ac ,_fd );if _dfd !=nil {return _gge ,_dfd ;};_fda .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"); 103 _fda .Header .Add ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0067\u007a\u0069\u0070");_fda .Header .Add ("\u0041c\u0063e\u0070\u0074\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0067\u007a\u0069\u0070"); 104 _fda .Header .Add ("\u0058-\u0041\u0050\u0049\u002d\u004b\u0045Y",_dbg ._daf );_dab ,_dfd :=_dbg ._ceg .Do (_fda );if _dfd !=nil {return _gge ,_dfd ;};defer _dab .Body .Close ();if _dab .StatusCode !=200{_fdf ,_afg :=_bdf (_dab );if _afg !=nil {return _gge ,_afg ; 105 };_afg =_aa .Unmarshal (_fdf ,&_gge );if _afg !=nil {return _gge ,_afg ;};return _gge ,_e .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",_dab .StatusCode ); 106 };_dbf :=_dab .Header .Get ("\u0058\u002d\u0055\u0043\u002d\u0053\u0069\u0067\u006ea\u0074\u0075\u0072\u0065");_dead :=_cfd (_aeb .MacAddress ,string (_bgf ));if _dead !=_dbf {_abg .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"); 107 return _gge ,_ae .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"); 108 };_aaf ,_dfd :=_bdf (_dab );if _dfd !=nil {return _gge ,_dfd ;};_dfd =_aa .Unmarshal (_aaf ,&_gge );if _dfd !=nil {return _gge ,_dfd ;};return _gge ,nil ;};func _cfd (_effd ,_ddfc string )string {_ggc :=[]byte (_effd );_aaea :=_da .New (_de .New ,_ggc ); 109 _aaea .Write ([]byte (_ddfc ));return _ef .StdEncoding .EncodeToString (_aaea .Sum (nil ));};func SetMeteredKey (apiKey string )error {if len (apiKey )==0{_abg .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"); 110 _abg .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"); 111 return _e .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"); 112 };if _gbf !=nil &&(_gbf ._daga ||_gbf .Tier !=LicenseTierUnlicensed ){_abg .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"); 113 return _ae .New ("\u006c\u0069\u0063en\u0073\u0065\u0020\u006b\u0065\u0079\u0020\u0061\u006c\u0072\u0065\u0061\u0064\u0079\u0020\u0073\u0065\u0074");};_gdd :=_adf ();_gdd ._daf =apiKey ;_dc ,_fdaf :=_gdd .getStatus ();if _fdaf !=nil {return _fdaf ;};if !_dc .Valid {return _ae .New ("\u006b\u0065\u0079\u0020\u006e\u006f\u0074\u0020\u0076\u0061\u006c\u0069\u0064"); 114 };_bge :=&LicenseKey {_daga :true ,_cca :apiKey ,_dfg :true };_gbf =_bge ;return nil ;};func _ebcg ()string {_adcf :=_cd .Getenv ("\u0048\u004f\u004d\u0045");if len (_adcf )==0{_adcf ,_ =_cd .UserHomeDir ();};return _adcf ;};var _afd =&_ga .Mutex {};func _fbgc ()(string ,error ){_aeef :=_bb .TrimSpace (_cd .Getenv (_cfa )); 115 if _aeef ==""{_abg .Log .Debug ("\u0024\u0025\u0073\u0020e\u006e\u0076\u0069\u0072\u006f\u006e\u006d\u0065\u006e\u0074\u0020\u0076\u0061\u0072\u0069\u0061\u0062l\u0065\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064\u002e\u0020\u0057\u0069\u006c\u006c\u0020\u0075\u0073\u0065\u0020\u0068\u006f\u006d\u0065\u0020\u0064\u0069\u0072\u0065\u0063\u0074\u006f\u0072\u0079\u0020\u0074\u006f\u0020s\u0074\u006f\u0072\u0065\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0020in\u0066o\u0072\u006d\u0061\u0074\u0069\u006f\u006e\u002e",_cfa ); 116 _bace :=_ebcg ();if len (_bace )==0{return "",_e .Errorf ("r\u0065\u0071\u0075\u0069\u0072\u0065\u0064\u0020\u0024\u0025\u0073\u0020\u0065\u006e\u0076\u0069\u0072\u006f\u006e\u006d\u0065\u006e\u0074\u0020\u0076\u0061r\u0069a\u0062\u006c\u0065\u0020o\u0072\u0020h\u006f\u006d\u0065\u0020\u0064\u0069\u0072\u0065\u0063\u0074\u006f\u0072\u0079\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064",_cfa ); 117 };_aeef =_f .Join (_bace ,"\u002eu\u006e\u0069\u0064\u006f\u0063");};_fad :=_cd .MkdirAll (_aeef ,0777);if _fad !=nil {return "",_fad ;};return _aeef ,nil ;};func SetMeteredKeyPersistentCache (val bool ){_gbf ._dfg =val };