mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-25 13:48:53 +08:00
12 lines
40 KiB
Go
12 lines
40 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 (_ec "bytes";_ae "compress/gzip";_a "crypto";_bgg "crypto/aes";_aa "crypto/cipher";_bg "crypto/hmac";_fe "crypto/rand";_ba "crypto/rsa";_fa "crypto/sha256";_cd "crypto/sha512";_be "crypto/x509";_eb "encoding/base64";_gb "encoding/binary";_ag "encoding/hex";_af "encoding/json";_b "encoding/pem";_cf "errors";_edd "fmt";_bd "github.com/unidoc/unioffice/common";_ebd "github.com/unidoc/unioffice/common/logger";_c "io";_aeg "io/ioutil";_fd "log";_ed "net";_gd "net/http";_da "os";_ee "path/filepath";_f "regexp";_d "sort";_ecb "strings";_e "sync";_dd "time";);func (_dga *meteredClient )getStatus ()(meteredStatusResp ,error ){var _afde meteredStatusResp ;_fdb :=_dga ._fgf +"\u002fm\u0065t\u0065\u0072\u0065\u0064\u002f\u0073\u0074\u0061\u0074\u0075\u0073";var _gaf meteredStatusForm ;_ecd ,_dde :=_af .Marshal (_gaf );if _dde !=nil {return _afde ,_dde ;};_ecbf ,_dde :=_gbab (_ecd );if _dde !=nil {return _afde ,_dde ;};_egg ,_dde :=_gd .NewRequest ("\u0050\u004f\u0053\u0054",_fdb ,_ecbf );if _dde !=nil {return _afde ,_dde ;};_egg .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");_egg .Header .Add ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0067\u007a\u0069\u0070");_egg .Header .Add ("\u0041c\u0063e\u0070\u0074\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0067\u007a\u0069\u0070");_egg .Header .Add ("\u0058-\u0041\u0050\u0049\u002d\u004b\u0045Y",_dga ._adg );_ff ,_dde :=_dga ._dcb .Do (_egg );if _dde !=nil {return _afde ,_dde ;};defer _ff .Body .Close ();if _ff .StatusCode !=200{return _afde ,_edd .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",_ff .StatusCode );};_bda ,_dde :=_cedg (_ff );if _dde !=nil {return _afde ,_dde ;};_dde =_af .Unmarshal (_bda ,&_afde );if _dde !=nil {return _afde ,_dde ;};return _afde ,nil ;};type LicenseKey struct{LicenseId string `json:"license_id"`;CustomerId string `json:"customer_id"`;CustomerName string `json:"customer_name"`;Tier string `json:"tier"`;CreatedAt _dd .Time `json:"-"`;CreatedAtInt int64 `json:"created_at"`;ExpiresAt _dd .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"`;_aec bool ;_ebg string ;_aaf bool ;};var _fbbc map[string ]struct{};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"`;};var _ced =false ;func Track (docKey string ,useKey string )error {return _aad (docKey ,useKey ,!_aae ._aaf )};type LegacyLicenseType byte ;func _ad (_gc string )(LicenseKey ,error ){var _acb LicenseKey ;_gbc ,_gcg :=_cgb (_cda ,_db ,_gc );if _gcg !=nil {return _acb ,_gcg ;};_fdd ,_gcg :=_aegg (_ece ,_gbc );if _gcg !=nil {return _acb ,_gcg ;};_gcg =_af .Unmarshal (_fdd ,&_acb );if _gcg !=nil {return _acb ,_gcg ;};_acb .CreatedAt =_dd .Unix (_acb .CreatedAtInt ,0);if _acb .ExpiresAtInt > 0{_dc :=_dd .Unix (_acb .ExpiresAtInt ,0);_acb .ExpiresAt =_dc ;};return _acb ,nil ;};func SetMeteredKeyPersistentCache (val bool ){_aae ._aaf =val };func GetLicenseKey ()*LicenseKey {if _aae ==nil {return nil ;};_fafd :=*_aae ;return &_fafd ;};func _gcf ()([]string ,[]string ,error ){_agec ,_bgd :=_ed .Interfaces ();if _bgd !=nil {return nil ,nil ,_bgd ;};var _gbfc []string ;var _ggf []string ;for _ ,_gac :=range _agec {if _gac .Flags &_ed .FlagUp ==0||_ec .Equal (_gac .HardwareAddr ,nil ){continue ;};_aga ,_bgge :=_gac .Addrs ();if _bgge !=nil {return nil ,nil ,_bgge ;};_ffd :=0;for _ ,_badd :=range _aga {var _eccc _ed .IP ;switch _bdb :=_badd .(type ){case *_ed .IPNet :_eccc =_bdb .IP ;case *_ed .IPAddr :_eccc =_bdb .IP ;};if _eccc .IsLoopback (){continue ;};if _eccc .To4 ()==nil {continue ;};_ggf =append (_ggf ,_eccc .String ());_ffd ++;};_bdba :=_gac .HardwareAddr .String ();if _bdba !=""&&_ffd > 0{_gbfc =append (_gbfc ,_bdba );};};return _gbfc ,_ggf ,nil ;};func (_abf *LicenseKey )TypeToString ()string {if _abf ._aec {return "M\u0065t\u0065\u0072\u0065\u0064\u0020\u0073\u0075\u0062s\u0063\u0072\u0069\u0070ti\u006f\u006e";};if _abf .Tier ==LicenseTierUnlicensed {return "\u0055\u006e\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0064";};if _abf .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 _abf .Tier ==LicenseTierIndividual ||_abf .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 (_fee *LicenseKey )IsLicensed ()bool {if _fee ==nil {return false ;};return _fee .Tier !=LicenseTierUnlicensed ||_fee ._aec ;};type MeteredStatus struct{OK bool ;Credits int64 ;Used int64 ;};func TrackUse (useKey string ){if _aae ==nil {return ;};if !_aae ._aec ||len (_aae ._ebg )==0{return ;};if len (useKey )==0{return ;};_bab .Lock ();defer _bab .Unlock ();if _bafd ==nil {_bafd =map[string ]int {};};_bafd [useKey ]++;};var _ccab =_dd .Date (2019,6,6,0,0,0,0,_dd .UTC );func _acbc (_geb ,_dabc []byte )([]byte ,error ){_dfa ,_cbb :=_bgg .NewCipher (_geb );if _cbb !=nil {return nil ,_cbb ;};_dgb :=make ([]byte ,_bgg .BlockSize +len (_dabc ));_aed :=_dgb [:_bgg .BlockSize ];if _ ,_gcec :=_c .ReadFull (_fe .Reader ,_aed );_gcec !=nil {return nil ,_gcec ;};_fab :=_aa .NewCFBEncrypter (_dfa ,_aed );_fab .XORKeyStream (_dgb [_bgg .BlockSize :],_dabc );_ccce :=make ([]byte ,_eb .URLEncoding .EncodedLen (len (_dgb )));_eb .URLEncoding .Encode (_ccce ,_dgb );return _ccce ,nil ;};func SetMeteredKey (apiKey string )error {if len (apiKey )==0{_ebd .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");_ebd .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 _edd .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 _aae !=nil &&(_aae ._aec ||_aae .Tier !=LicenseTierUnlicensed ){_ebd .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 _cf .New ("\u006c\u0069\u0063en\u0073\u0065\u0020\u006b\u0065\u0079\u0020\u0061\u006c\u0072\u0065\u0061\u0064\u0079\u0020\u0073\u0065\u0074");};_eea :=_cbe ();_eea ._adg =apiKey ;_ca ,_beec :=_eea .getStatus ();if _beec !=nil {return _beec ;};if !_ca .Valid {return _cf .New ("\u006b\u0065\u0079\u0020\u006e\u006f\u0074\u0020\u0076\u0061\u006c\u0069\u0064");};_bcg :=&LicenseKey {_aec :true ,_ebg :apiKey ,_aaf :true };_aae =_bcg ;return nil ;};type defaultStateHolder struct{};type meteredClient struct{_fgf string ;_adg string ;_dcb *_gd .Client ;};func init (){_cba ,_eg :=_ag .DecodeString (_dce );if _eg !=nil {_fd .Fatalf ("e\u0072\u0072\u006f\u0072 r\u0065a\u0064\u0069\u006e\u0067\u0020k\u0065\u0079\u003a\u0020\u0025\u0073",_eg );};_ege ,_eg :=_be .ParsePKIXPublicKey (_cba );if _eg !=nil {_fd .Fatalf ("e\u0072\u0072\u006f\u0072 r\u0065a\u0064\u0069\u006e\u0067\u0020k\u0065\u0079\u003a\u0020\u0025\u0073",_eg );};_dee =_ege .(*_ba .PublicKey );};func (_dadb *LicenseKey )isExpired ()bool {return _dadb .getExpiryDateToCompare ().After (_dadb .ExpiresAt );};type LegacyLicense struct{Name string ;Signature string `json:",omitempty"`;Expiration _dd .Time ;LicenseType LegacyLicenseType ;};func GetMeteredState ()(MeteredStatus ,error ){if _aae ==nil {return MeteredStatus {},_cf .New ("\u006c\u0069\u0063\u0065ns\u0065\u0020\u006b\u0065\u0079\u0020\u006e\u006f\u0074\u0020\u0073\u0065\u0074");};if !_aae ._aec ||len (_aae ._ebg )==0{return MeteredStatus {},_cf .New ("\u0061p\u0069 \u006b\u0065\u0079\u0020\u006e\u006f\u0074\u0020\u0073\u0065\u0074");};_ddec ,_gad :=_cea .loadState (_aae ._ebg );if _gad !=nil {_ebd .Log .Error ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_gad );return MeteredStatus {},_gad ;};if _ddec .Docs > 0{_ccc :=_aad ("","",true );if _ccc !=nil {return MeteredStatus {},_ccc ;};};_bab .Lock ();defer _bab .Unlock ();_dabde :=_cbe ();_dabde ._adg =_aae ._ebg ;_gdfb ,_gad :=_dabde .getStatus ();if _gad !=nil {return MeteredStatus {},_gad ;};if !_gdfb .Valid {return MeteredStatus {},_cf .New ("\u006b\u0065\u0079\u0020\u006e\u006f\u0074\u0020\u0076\u0061\u006c\u0069\u0064");};_ffc :=MeteredStatus {OK :true ,Credits :_gdfb .OrgCredits ,Used :_gdfb .OrgUsed };return _ffc ,nil ;};func SetLegacyLicenseKey (s string )error {_abfd :=_f .MustCompile ("\u005c\u0073");s =_abfd .ReplaceAllString (s ,"");var _dcf _c .Reader ;_dcf =_ecb .NewReader (s );_dcf =_eb .NewDecoder (_eb .RawURLEncoding ,_dcf );_dcf ,_ebaf :=_ae .NewReader (_dcf );if _ebaf !=nil {return _ebaf ;};_dgab :=_af .NewDecoder (_dcf );_agd :=&LegacyLicense {};if _dgc :=_dgab .Decode (_agd );_dgc !=nil {return _dgc ;};if _cef :=_agd .Verify (_dee );_cef !=nil {return _cf .New ("\u006c\u0069\u0063en\u0073\u0065\u0020\u0076\u0061\u006c\u0069\u0064\u0061\u0074\u0069\u006e\u0020\u0065\u0072\u0072\u006f\u0072");};if _agd .Expiration .Before (_bd .ReleasedAt ){return _cf .New ("\u006ci\u0063e\u006e\u0073\u0065\u0020\u0065\u0078\u0070\u0069\u0072\u0065\u0064");};_abec :=_dd .Now ().UTC ();_fbgf :=LicenseKey {};_fbgf .CreatedAt =_abec ;_fbgf .CustomerId ="\u004c\u0065\u0067\u0061\u0063\u0079";_fbgf .CustomerName =_agd .Name ;_fbgf .Tier =LicenseTierBusiness ;_fbgf .ExpiresAt =_agd .Expiration ;_fbgf .CreatorName ="\u0055\u006e\u0069\u0044\u006f\u0063\u0020\u0073\u0075p\u0070\u006f\u0072\u0074";_fbgf .CreatorEmail ="\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0040\u0075\u006e\u0069\u0064o\u0063\u002e\u0069\u006f";_fbgf .UniOffice =true ;_aae =&_fbgf ;return nil ;};var _bafd map[string ]int ;var _edad =_dd .Date (2010,1,1,0,0,0,0,_dd .UTC );var _dee *_ba .PublicKey ;func SetLicenseKey (content string ,customerName string )error {if _ced {return nil ;};_bca ,_abee :=_ad (content );if _abee !=nil {_ebd .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",_abee );return _abee ;};if !_ecb .EqualFold (_bca .CustomerName ,customerName ){_ebd .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",_bca .CustomerName ,customerName );return _edd .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'",_bca .CustomerName ,customerName );};_abee =_bca .Validate ();if _abee !=nil {_ebd .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",_abee );return _abee ;};_aae =&_bca ;return nil ;};func (_bfc defaultStateHolder )loadState (_bfa string )(reportState ,error ){_dbe :=_gace ();if len (_dbe )==0{return reportState {},_cf .New ("\u0068\u006fm\u0065\u0020\u0064i\u0072\u0020\u006e\u006f\u0074\u0020\u0073\u0065\u0074");};_gffd :=_ee .Join (_dbe ,"\u002eu\u006e\u0069\u0064\u006f\u0063");_dgae :=_da .MkdirAll (_gffd ,0777);if _dgae !=nil {return reportState {},_dgae ;};if len (_bfa )< 20{return reportState {},_cf .New ("i\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006b\u0065\u0079");};_fgd :=[]byte (_bfa );_gde :=_cd .Sum512_256 (_fgd [:20]);_fca :=_ag .EncodeToString (_gde [:]);_gddf :=_ee .Join (_gffd ,_fca );_bb ,_dgae :=_aeg .ReadFile (_gddf );if _dgae !=nil {if _da .IsNotExist (_dgae ){return reportState {},nil ;};_ebd .Log .Error ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_dgae );return reportState {},_cf .New ("\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0061");};const _gbf ="\u0068\u00619\u004e\u004b\u0038]\u0052\u0062\u004c\u002a\u006d\u0034\u004c\u004b\u0057";_bb ,_dgae =_gfee ([]byte (_gbf ),_bb );if _dgae !=nil {return reportState {},_dgae ;};var _cde reportState ;_dgae =_af .Unmarshal (_bb ,&_cde );if _dgae !=nil {_ebd .Log .Error ("\u0045\u0052\u0052OR\u003a\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0061\u003a\u0020\u0025\u0076",_dgae );return reportState {},_cf .New ("\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0061");};return _cde ,nil ;};func _ebff (_ffb ,_dec string )string {_cgc :=[]byte (_ffb );_ggd :=_bg .New (_fa .New ,_cgc );_ggd .Write ([]byte (_dec ));return _eb .StdEncoding .EncodeToString (_ggd .Sum (nil ));};type stateLoader interface{loadState (_gff string )(reportState ,error );updateState (_eba ,_df ,_ddee string ,_ce int ,_bed bool ,_afc int ,_abe int ,_gca _dd .Time ,_egdc map[string ]int )error ;};func (_cdg *LicenseKey )getExpiryDateToCompare ()_dd .Time {if _cdg .Trial {return _dd .Now ().UTC ();};return _bd .ReleasedAt ;};func (_ebca defaultStateHolder )updateState (_ebgc ,_gfe ,_gda string ,_ccg int ,_bcf bool ,_dbf int ,_ebf int ,_efa _dd .Time ,_cgfa map[string ]int )error {_bcc :=_gace ();if len (_bcc )==0{return _cf .New ("\u0068\u006fm\u0065\u0020\u0064i\u0072\u0020\u006e\u006f\u0074\u0020\u0073\u0065\u0074");};_dadc :=_ee .Join (_bcc ,"\u002eu\u006e\u0069\u0064\u006f\u0063");_dac :=_da .MkdirAll (_dadc ,0777);if _dac !=nil {return _dac ;};if len (_ebgc )< 20{return _cf .New ("i\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006b\u0065\u0079");};_baa :=[]byte (_ebgc );_ecgb :=_cd .Sum512_256 (_baa [:20]);_abg :=_ag .EncodeToString (_ecgb [:]);_fga :=_ee .Join (_dadc ,_abg );var _ceg reportState ;_ceg .Docs =int64 (_ccg );_ceg .NumErrors =int64 (_ebf );_ceg .LimitDocs =_bcf ;_ceg .RemainingDocs =int64 (_dbf );_ceg .LastWritten =_dd .Now ().UTC ();_ceg .LastReported =_efa ;_ceg .Instance =_gfe ;_ceg .Next =_gda ;_ceg .Usage =_cgfa ;_fcc ,_dac :=_af .Marshal (_ceg );if _dac !=nil {return _dac ;};const _baac ="\u0068\u00619\u004e\u004b\u0038]\u0052\u0062\u004c\u002a\u006d\u0034\u004c\u004b\u0057";_fcc ,_dac =_acbc ([]byte (_baac ),_fcc );if _dac !=nil {return _dac ;};_dac =_aeg .WriteFile (_fga ,_fcc ,0600);if _dac !=nil {return _dac ;};return nil ;};func _gafd ()(_ed .IP ,error ){_dae ,_afce :=_ed .Dial ("\u0075\u0064\u0070","\u0038\u002e\u0038\u002e\u0038\u002e\u0038\u003a\u0038\u0030");if _afce !=nil {return nil ,_afce ;};defer _dae .Close ();_acdd :=_dae .LocalAddr ().(*_ed .UDPAddr );return _acdd .IP ,nil ;};var _cea stateLoader =defaultStateHolder {};var _aae =MakeUnlicensedKey ();func (_cbae *meteredClient )checkinUsage (_cfe meteredUsageCheckinForm )(meteredUsageCheckinResp ,error ){_cfe .Package ="\u0075n\u0069\u006f\u0066\u0066\u0069\u0063e";_cfe .PackageVersion =_bd .Version ;var _aab meteredUsageCheckinResp ;_ecf :=_cbae ._fgf +"\u002f\u006d\u0065\u0074er\u0065\u0064\u002f\u0075\u0073\u0061\u0067\u0065\u005f\u0063\u0068\u0065\u0063\u006bi\u006e";_bfd ,_gab :=_af .Marshal (_cfe );if _gab !=nil {return _aab ,_gab ;};_cgf ,_gab :=_gbab (_bfd );if _gab !=nil {return _aab ,_gab ;};_ecc ,_gab :=_gd .NewRequest ("\u0050\u004f\u0053\u0054",_ecf ,_cgf );if _gab !=nil {return _aab ,_gab ;};_ecc .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");_ecc .Header .Add ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0067\u007a\u0069\u0070");_ecc .Header .Add ("\u0041c\u0063e\u0070\u0074\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0067\u007a\u0069\u0070");_ecc .Header .Add ("\u0058-\u0041\u0050\u0049\u002d\u004b\u0045Y",_cbae ._adg );_fea ,_gab :=_cbae ._dcb .Do (_ecc );if _gab !=nil {_ebd .Log .Error ("\u0049n\u0076\u0061\u006c\u0069d\u0020\u0068\u0074\u0074\u0070 \u0072e\u0073p\u006f\u006e\u0073\u0065\u003a\u0020\u0025v",_gab );return _aab ,_gab ;};defer _fea .Body .Close ();if _fea .StatusCode !=200{_gfb ,_ecg :=_cedg (_fea );if _ecg !=nil {return _aab ,_ecg ;};_ecg =_af .Unmarshal (_gfb ,&_aab );if _ecg !=nil {return _aab ,_ecg ;};return _aab ,_edd .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",_fea .StatusCode );};_bgf :=_fea .Header .Get ("\u0058\u002d\u0055\u0043\u002d\u0053\u0069\u0067\u006ea\u0074\u0075\u0072\u0065");_eed :=_ebff (_cfe .MacAddress ,string (_bfd ));if _eed !=_bgf {_ebd .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 _aab ,_cf .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");};_gdf ,_gab :=_cedg (_fea );if _gab !=nil {return _aab ,_gab ;};_gab =_af .Unmarshal (_gdf ,&_aab );if _gab !=nil {return _aab ,_gab ;};return _aab ,nil ;};func (_abc LegacyLicense )Verify (pubKey *_ba .PublicKey )error {_cfd :=_abc ;_cfd .Signature ="";_ga :=_ec .Buffer {};_age :=_af .NewEncoder (&_ga );if _cbd :=_age .Encode (_cfd );_cbd !=nil {return _cbd ;};_dag ,_dg :=_ag .DecodeString (_abc .Signature );if _dg !=nil {return _dg ;};_acc :=_fa .Sum256 (_ga .Bytes ());_dg =_ba .VerifyPKCS1v15 (pubKey ,_a .SHA256 ,_acc [:],_dag );return _dg ;};const (_cda ="\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";_db ="\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";);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 (_dabd *LicenseKey )ToString ()string {if _dabd ._aec {return "M\u0065t\u0065\u0072\u0065\u0064\u0020\u0073\u0075\u0062s\u0063\u0072\u0069\u0070ti\u006f\u006e";};_eef :=_edd .Sprintf ("\u004ci\u0063e\u006e\u0073\u0065\u0020\u0049\u0064\u003a\u0020\u0025\u0073\u000a",_dabd .LicenseId );_eef +=_edd .Sprintf ("\u0043\u0075s\u0074\u006f\u006de\u0072\u0020\u0049\u0064\u003a\u0020\u0025\u0073\u000a",_dabd .CustomerId );_eef +=_edd .Sprintf ("\u0043u\u0073t\u006f\u006d\u0065\u0072\u0020N\u0061\u006de\u003a\u0020\u0025\u0073\u000a",_dabd .CustomerName );_eef +=_edd .Sprintf ("\u0054i\u0065\u0072\u003a\u0020\u0025\u0073\n",_dabd .Tier );_eef +=_edd .Sprintf ("\u0043r\u0065a\u0074\u0065\u0064\u0020\u0041\u0074\u003a\u0020\u0025\u0073\u000a",_bd .UtcTimeFormat (_dabd .CreatedAt ));if _dabd .ExpiresAt .IsZero (){_eef +="\u0045x\u0070i\u0072\u0065\u0073\u0020\u0041t\u003a\u0020N\u0065\u0076\u0065\u0072\u000a";}else {_eef +=_edd .Sprintf ("\u0045x\u0070i\u0072\u0065\u0073\u0020\u0041\u0074\u003a\u0020\u0025\u0073\u000a",_bd .UtcTimeFormat (_dabd .ExpiresAt ));};_eef +=_edd .Sprintf ("\u0043\u0072\u0065\u0061\u0074\u006f\u0072\u003a\u0020\u0025\u0073\u0020<\u0025\u0073\u003e\u000a",_dabd .CreatorName ,_dabd .CreatorEmail );return _eef ;};func (_gf *LicenseKey )Validate ()error {if _gf ._aec {return nil ;};if len (_gf .LicenseId )< 10{return _edd .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 (_gf .CustomerId )< 10{return _edd .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 (_gf .CustomerName )< 1{return _edd .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 _edad .After (_gf .CreatedAt ){return _edd .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 _gf .ExpiresAt .IsZero (){_aaa :=_gf .CreatedAt .AddDate (1,0,0);if _dad .After (_aaa ){_aaa =_dad ;};_gf .ExpiresAt =_aaa ;};if _gf .CreatedAt .After (_gf .ExpiresAt ){return _edd .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 _gf .isExpired (){_ebc :="\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";return _edd .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u003a\u0020\u0025\u0073",_ebc );};if len (_gf .CreatorName )< 1{return _edd .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 (_gf .CreatorEmail )< 1{return _edd .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 _gf .CreatedAt .After (_ccab ){if !_gf .UniOffice {return _edd .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 _cedg (_ebad *_gd .Response )([]byte ,error ){var _dbbe []byte ;_fdf ,_ccbb :=_efe (_ebad );if _ccbb !=nil {return _dbbe ,_ccbb ;};return _aeg .ReadAll (_fdf );};func _cbe ()*meteredClient {_egd :=meteredClient {_fgf :"h\u0074\u0074\u0070\u0073\u003a\u002f/\u0063\u006c\u006f\u0075\u0064\u002e\u0075\u006e\u0069d\u006f\u0063\u002ei\u006f/\u0061\u0070\u0069",_dcb :&_gd .Client {Timeout :30*_dd .Second }};if _dbbf :=_da .Getenv ("\u0055N\u0049\u0044\u004f\u0043_\u004c\u0049\u0043\u0045\u004eS\u0045_\u0053E\u0052\u0056\u0045\u0052\u005f\u0055\u0052L");_ecb .HasPrefix (_dbbf ,"\u0068\u0074\u0074\u0070"){_egd ._fgf =_dbbf ;};return &_egd ;};var _dad =_dd .Date (2020,1,1,0,0,0,0,_dd .UTC );func _gbab (_bgdd []byte )(_c .Reader ,error ){_aeb :=new (_ec .Buffer );_faa :=_ae .NewWriter (_aeb );_faa .Write (_bgdd );_aac :=_faa .Close ();if _aac !=nil {return nil ,_aac ;};return _aeb ,nil ;};const _bafc ="\u0055\u004e\u0049\u004fFF\u0049\u0043\u0045\u005f\u004c\u0049\u0043\u0045\u004e\u0053\u0045\u005f\u0050\u0041T\u0048";func _aad (_ada string ,_bfdc string ,_cfed bool )error {if _aae ==nil {return _cf .New ("\u006e\u006f\u0020\u006c\u0069\u0063\u0065\u006e\u0073e\u0020\u006b\u0065\u0079");};if !_aae ._aec ||len (_aae ._ebg )==0{return nil ;};if len (_ada )==0&&!_cfed {return _cf .New ("\u0064\u006f\u0063\u004b\u0065\u0079\u0020\u006e\u006ft\u0020\u0073\u0065\u0074");};_bab .Lock ();defer _bab .Unlock ();if _fbbc ==nil {_fbbc =map[string ]struct{}{};};if _bafd ==nil {_bafd =map[string ]int {};};_fba :=0;_ ,_gba :=_fbbc [_ada ];if !_gba {_fbbc [_ada ]=struct{}{};_fba ++;};if _fba ==0{return nil ;};_bafd [_bfdc ]++;_dca :=_dd .Now ();_daf ,_fcg :=_cea .loadState (_aae ._ebg );if _fcg !=nil {_ebd .Log .Error ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_fcg );return _fcg ;};if _daf .Usage ==nil {_daf .Usage =map[string ]int {};};for _gfc ,_deac :=range _bafd {_daf .Usage [_gfc ]+=_deac ;};_bafd =nil ;const _ebb =24*_dd .Hour ;const _fbbb =3*24*_dd .Hour ;if len (_daf .Instance )==0||_dca .Sub (_daf .LastReported )> _ebb ||(_daf .LimitDocs &&_daf .RemainingDocs <=_daf .Docs +int64 (_fba ))||_cfed {_ebgg ,_aadb :=_da .Hostname ();if _aadb !=nil {return _aadb ;};_cbaef :=_daf .Docs ;_ecgc ,_fgdd ,_aadb :=_gcf ();if _aadb !=nil {_ebd .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",_aadb .Error ());_ecgc =append (_ecgc ,"\u0069n\u0066\u006f\u0072\u006da\u0074\u0069\u006f\u006e\u0020n\u006ft\u0020a\u0076\u0061\u0069\u006c\u0061\u0062\u006ce");_fgdd =append (_fgdd ,"\u0069n\u0066\u006f\u0072\u006da\u0074\u0069\u006f\u006e\u0020n\u006ft\u0020a\u0076\u0061\u0069\u006c\u0061\u0062\u006ce");}else {_d .Strings (_fgdd );_d .Strings (_ecgc );_fdba ,_dcaa :=_gafd ();if _dcaa !=nil {return _dcaa ;};_bad :=false ;for _ ,_cdd :=range _fgdd {if _cdd ==_fdba .String (){_bad =true ;};};if !_bad {_fgdd =append (_fgdd ,_fdba .String ());};};_gag :=_cbe ();_gag ._adg =_aae ._ebg ;_cbaef +=int64 (_fba );_ggc :=meteredUsageCheckinForm {Instance :_daf .Instance ,Next :_daf .Next ,UsageNumber :int (_cbaef ),NumFailed :_daf .NumErrors ,Hostname :_ebgg ,LocalIP :_ecb .Join (_fgdd ,"\u002c\u0020"),MacAddress :_ecb .Join (_ecgc ,"\u002c\u0020"),Package :"\u0075n\u0069\u006f\u0066\u0066\u0069\u0063e",PackageVersion :_bd .Version ,Usage :_daf .Usage ,IsPersistentCache :_aae ._aaf ,Timestamp :_dca .Unix ()};if len (_ecgc )==0{_ggc .MacAddress ="\u006e\u006f\u006e\u0065";};_bba :=int64 (0);_fead :=_daf .NumErrors ;_dbc :=_dca ;_aafa :=0;_cdb :=_daf .LimitDocs ;_abca ,_aadb :=_gag .checkinUsage (_ggc );if _aadb !=nil {if _dca .Sub (_daf .LastReported )> _fbbb {if !_abca .Success {return _cf .New (_abca .Message );};return _cf .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");};_bba =_cbaef ;_fead ++;_dbc =_daf .LastReported ;}else {_cdb =_abca .LimitDocs ;_aafa =_abca .RemainingDocs ;_fead =0;};if len (_abca .Instance )==0{_abca .Instance =_ggc .Instance ;};if len (_abca .Next )==0{_abca .Next =_ggc .Next ;};_aadb =_cea .updateState (_gag ._adg ,_abca .Instance ,_abca .Next ,int (_bba ),_cdb ,_aafa ,int (_fead ),_dbc ,nil );if _aadb !=nil {return _aadb ;};if !_abca .Success {return _edd .Errorf ("\u0065r\u0072\u006f\u0072\u003a\u0020\u0025s",_abca .Message );};}else {_fcg =_cea .updateState (_aae ._ebg ,_daf .Instance ,_daf .Next ,int (_daf .Docs )+_fba ,_daf .LimitDocs ,int (_daf .RemainingDocs ),int (_daf .NumErrors ),_daf .LastReported ,_daf .Usage );if _fcg !=nil {return _fcg ;};};return nil ;};type meteredStatusResp struct{Valid bool `json:"valid"`;OrgCredits int64 `json:"org_credits"`;OrgUsed int64 `json:"org_used"`;OrgRemaining int64 `json:"org_remaining"`;};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 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 _dd .Time `json:"lr"`;LastWritten _dd .Time `json:"lw"`;Usage map[string ]int `json:"u"`;};func _cgb (_dab string ,_bec string ,_fc string )(string ,error ){_baf :=_ecb .Index (_fc ,_dab );if _baf ==-1{return "",_edd .Errorf ("\u0068\u0065a\u0064\u0065\u0072 \u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064");};_ccb :=_ecb .Index (_fc ,_bec );if _ccb ==-1{return "",_edd .Errorf ("\u0066\u006fo\u0074\u0065\u0072 \u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064");};_acg :=_baf +len (_dab )+1;return _fc [_acg :_ccb -1],nil ;};func _gace ()string {_fag :=_da .Getenv ("\u0048\u004f\u004d\u0045");if len (_fag )==0{_fag ,_ =_da .UserHomeDir ();};return _fag ;};type meteredStatusForm struct{};func init (){_gadg :=_da .Getenv (_bafc );_bfcg :=_da .Getenv (_edg );if len (_gadg )==0||len (_bfcg )==0{return ;};_dfe ,_gbd :=_aeg .ReadFile (_gadg );if _gbd !=nil {_ebd .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",_gbd );return ;};_gbd =SetLicenseKey (string (_dfe ),_bfcg );if _gbd !=nil {_ebd .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",_gbd );return ;};};func _gfee (_eff ,_gae []byte )([]byte ,error ){_fcge :=make ([]byte ,_eb .URLEncoding .DecodedLen (len (_gae )));_acdf ,_gfeb :=_eb .URLEncoding .Decode (_fcge ,_gae );if _gfeb !=nil {return nil ,_gfeb ;};_fcge =_fcge [:_acdf ];_dabdb ,_gfeb :=_bgg .NewCipher (_eff );if _gfeb !=nil {return nil ,_gfeb ;};if len (_fcge )< _bgg .BlockSize {return nil ,_cf .New ("c\u0069p\u0068\u0065\u0072\u0074\u0065\u0078\u0074\u0020t\u006f\u006f\u0020\u0073ho\u0072\u0074");};_bga :=_fcge [:_bgg .BlockSize ];_fcge =_fcge [_bgg .BlockSize :];_cec :=_aa .NewCFBDecrypter (_dabdb ,_bga );_cec .XORKeyStream (_fcge ,_fcge );return _fcge ,nil ;};const _edg ="\u0055\u004e\u0049OF\u0046\u0049\u0043\u0045\u005f\u0043\u0055\u0053\u0054\u004f\u004d\u0045\u0052\u005f\u004e\u0041\u004d\u0045";const _ece ="\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";func _efe (_bcd *_gd .Response )(_c .ReadCloser ,error ){var _adge error ;var _accg _c .ReadCloser ;switch _ecb .ToLower (_bcd .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067")){case "\u0067\u007a\u0069\u0070":_accg ,_adge =_ae .NewReader (_bcd .Body );if _adge !=nil {return _accg ,_adge ;};defer _accg .Close ();default:_accg =_bcd .Body ;};return _accg ,nil ;};func GenRefId (prefix string )(string ,error ){var _ggfa _ec .Buffer ;_ggfa .WriteString (prefix );_ccae :=make ([]byte ,8+16);_agg :=_dd .Now ().UTC ().UnixNano ();_gb .BigEndian .PutUint64 (_ccae ,uint64 (_agg ));_ ,_aeca :=_fe .Read (_ccae [8:]);if _aeca !=nil {return "",_aeca ;};_ggfa .WriteString (_ag .EncodeToString (_ccae ));return _ggfa .String (),nil ;};func MakeUnlicensedKey ()*LicenseKey {_bdf :=LicenseKey {};_bdf .CustomerName ="\u0055\u006e\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0064";_bdf .Tier =LicenseTierUnlicensed ;_bdf .CreatedAt =_dd .Now ().UTC ();_bdf .CreatedAtInt =_bdf .CreatedAt .Unix ();return &_bdf ;};const _dce ="\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 _aegg (_gbe string ,_gdd string )([]byte ,error ){var (_bac int ;_gg string ;);for _ ,_gg =range []string {"\u000a\u002b\u000a","\u000d\u000a\u002b\r\u000a","\u0020\u002b\u0020"}{if _bac =_ecb .Index (_gdd ,_gg );_bac !=-1{break ;};};if _bac ==-1{return nil ,_edd .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");};_ab :=_gdd [:_bac ];_fbb :=_bac +len (_gg );_ac :=_gdd [_fbb :];if _ab ==""||_ac ==""{return nil ,_edd .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");};_dbb ,_fbg :=_eb .StdEncoding .DecodeString (_ab );if _fbg !=nil {return nil ,_edd .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0070\u0075\u0074\u0020\u006f\u0072\u0069\u0067\u0069\u006ea\u006c");};_afd ,_fbg :=_eb .StdEncoding .DecodeString (_ac );if _fbg !=nil {return nil ,_edd .Errorf ("\u0069\u006e\u0076al\u0069\u0064\u0020\u0069\u006e\u0070\u0075\u0074\u0020\u0073\u0069\u0067\u006e\u0061\u0074\u0075\u0072\u0065");};_acd ,_ :=_b .Decode ([]byte (_gbe ));if _acd ==nil {return nil ,_edd .Errorf ("\u0050\u0075\u0062\u004b\u0065\u0079\u0020\u0066\u0061\u0069\u006c\u0065\u0064");};_dea ,_fbg :=_be .ParsePKIXPublicKey (_acd .Bytes );if _fbg !=nil {return nil ,_fbg ;};_cca :=_dea .(*_ba .PublicKey );if _cca ==nil {return nil ,_edd .Errorf ("\u0050u\u0062\u004b\u0065\u0079\u0020\u0063\u006f\u006e\u0076\u0065\u0072s\u0069\u006f\u006e\u0020\u0066\u0061\u0069\u006c\u0065\u0064");};_bee :=_cd .New ();_bee .Write (_dbb );_faf :=_bee .Sum (nil );_fbg =_ba .VerifyPKCS1v15 (_cca ,_a .SHA512 ,_faf ,_afd );if _fbg !=nil {return nil ,_fbg ;};return _dbb ,nil ;};var _bab =&_e .Mutex {};func _fg (_bf string ,_ef []byte )(string ,error ){_ge ,_ :=_b .Decode ([]byte (_bf ));if _ge ==nil {return "",_edd .Errorf ("\u0050\u0072\u0069\u0076\u004b\u0065\u0079\u0020\u0066a\u0069\u006c\u0065\u0064");};_de ,_fac :=_be .ParsePKCS1PrivateKey (_ge .Bytes );if _fac !=nil {return "",_fac ;};_cb :=_cd .New ();_cb .Write (_ef );_cdc :=_cb .Sum (nil );_cc ,_fac :=_ba .SignPKCS1v15 (_fe .Reader ,_de ,_a .SHA512 ,_cdc );if _fac !=nil {return "",_fac ;};_bc :=_eb .StdEncoding .EncodeToString (_ef );_bc +="\u000a\u002b\u000a";_bc +=_eb .StdEncoding .EncodeToString (_cc );return _bc ,nil ;}; |