text stringlengths 11 6.3k | embedding listlengths 768 768 |
|---|---|
func readFull(r io.Reader, buf []byte) (int, error) {
var n int
var err error
for n < len(buf) && err == nil {
var nn int
nn, err = r.Read(buf[n:])
n += nn
}
if n == len(buf) {
return n, nil
}
if err == io.EOF {
return n, io.ErrUnexpectedEOF
}
return n, err
} | [
0.5946165323257446,
0.10644682496786118,
0.6416204571723938,
0.08831573277711868,
-0.10343896597623825,
-0.07590409368276596,
0.2640000283718109,
0.12860697507858276,
-0.08748085051774979,
0.3530281186103821,
-0.6145873665809631,
-0.04122493043541908,
-0.07263315469026566,
0.12173252552747... |
func (p *ProxyWriter) StatusCode() int {
if p.Code == 0 {
// per contract standard lib will set this to http.StatusOK if not set
// by user, here we avoid the confusion by mirroring this logic
return http.StatusOK
}
return p.Code
} | [
-0.2462887167930603,
-0.1811945140361786,
0.5191574096679688,
0.09528441727161407,
-0.08743736147880554,
-0.016482697799801826,
0.8824688196182251,
1.1994837522506714,
-0.007689341902732849,
0.39583638310432434,
1.2248014211654663,
-0.778412938117981,
-0.8245289325714111,
0.187546551227569... |
func (p *ProxyWriter) Write(buf []byte) (int, error) {
return p.W.Write(buf)
} | [
-0.672587513923645,
0.5966049432754517,
0.30890387296676636,
-0.3597293794155121,
0.7875382900238037,
-0.3298792541027069,
1.0605438947677612,
0.6704726219177246,
-0.5849075317382812,
0.10580787062644958,
-0.8652851581573486,
-0.5403539538383484,
-1.5657126903533936,
0.42584583163261414,
... |
func (p *ProxyWriter) WriteHeader(code int) {
p.Code = code
p.W.WriteHeader(code)
} | [
-1.3328118324279785,
0.38633766770362854,
0.3776850700378418,
-0.6766616106033325,
0.6965305805206299,
0.01339644193649292,
1.0634620189666748,
0.5812699198722839,
0.0003667883574962616,
-0.18359409272670746,
0.024958204478025436,
-0.05066914111375809,
-0.5421611666679382,
0.74510514736175... |
func (p *ProxyWriter) Flush() {
if f, ok := p.W.(http.Flusher); ok {
f.Flush()
}
} | [
-0.27488234639167786,
0.7791703343391418,
0.13972538709640503,
-0.3794158399105072,
0.5659213066101074,
0.21231816709041595,
0.7691726684570312,
-0.2025807946920395,
-0.7692143321037292,
-0.8005052208900452,
0.5937501788139343,
0.3125654458999634,
-0.298367977142334,
1.051629900932312,
-... |
func NewWriterStub() *WriterStub {
return &WriterStub{Code: http.StatusOK, Headers: make(http.Header)}
} | [
-0.927721381187439,
-0.26208430528640747,
0.4330059885978699,
-0.12830750644207,
-0.2187068611383438,
-0.4908246695995331,
0.8875426054000854,
0.6567848324775696,
-0.3074301481246948,
-0.6334325671195984,
-0.2446068972349167,
0.1166837140917778,
0.09845879673957825,
-0.2588902413845062,
... |
func (p *WriterStub) Write(buf []byte) (int, error) {
p.Body = append(p.Body, buf...)
return len(p.Body), nil
} | [
-1.6433484554290771,
0.6888757348060608,
0.44793081283569336,
-0.20506076514720917,
1.095450758934021,
0.4981124699115753,
0.582819402217865,
0.4735301434993744,
-0.3533959984779358,
-0.3086479902267456,
-1.5094146728515625,
-0.585242509841919,
-1.3240045309066772,
0.5498635172843933,
-0... |
func (p *WriterStub) WriteHeader(code int) {
p.Code = code
} | [
-1.6829910278320312,
0.12975049018859863,
0.43477198481559753,
0.07852409034967422,
0.7749981880187988,
0.3653251528739929,
1.0335094928741455,
0.5605732202529907,
-0.13738413155078888,
-0.34062668681144714,
-0.665816068649292,
-0.2347886860370636,
-0.16673845052719116,
0.6596307754516602,... |
func NewBufferWriter(w io.WriteCloser) *BufferWriter {
return &BufferWriter{
W: w,
H: make(http.Header),
}
} | [
-0.03693345934152603,
-0.7144222855567932,
0.3862611949443817,
0.516132652759552,
-1.2111942768096924,
-0.5768950581550598,
-0.035203464329242706,
-1.046537160873413,
0.11788118630647659,
-0.38291001319885254,
-0.3188331425189972,
-0.02152075245976448,
-0.07867565006017685,
0.7062857151031... |
func (b *BufferWriter) Close() error {
return b.W.Close()
} | [
0.06464918702840805,
0.10429730266332626,
0.46544405817985535,
0.7546119689941406,
0.12358412146568298,
0.05765455216169357,
1.1047102212905884,
-0.7067778706550598,
-0.9189414381980896,
-0.9851722717285156,
-0.10382235050201416,
-0.48708200454711914,
-1.4388494491577148,
1.132160067558288... |
func (b *BufferWriter) Write(buf []byte) (int, error) {
return b.W.Write(buf)
} | [
-0.7914305329322815,
0.36604851484298706,
0.31655198335647583,
0.9158812761306763,
0.9007701277732849,
-0.3511737585067749,
1.4515212774276733,
0.26451051235198975,
-0.33131393790245056,
-0.032750003039836884,
-1.2256685495376587,
-0.5767843127250671,
-1.131377935409546,
1.272807002067566,... |
func NopWriteCloser(w io.Writer) io.WriteCloser {
return &nopWriteCloser{w}
} | [
-0.8156471252441406,
-0.6432245373725891,
0.37765902280807495,
-0.3976321518421173,
-1.4560589790344238,
0.2677334249019623,
0.7239776253700256,
-1.3405581712722778,
-0.5303378105163574,
-1.1345881223678589,
0.9791319966316223,
-0.8072093725204468,
-1.4181677103042603,
1.4793833494186401,
... |
func CopyURL(i *url.URL) *url.URL {
out := *i
if i.User != nil {
out.User = &(*i.User)
}
return &out
} | [
-0.07664512097835541,
-0.021267661824822426,
0.3053704798221588,
1.3140490055084229,
-1.4078713655471802,
1.1524412631988525,
0.8530371189117432,
-0.019314395263791084,
1.0903218984603882,
0.65853351354599,
0.14726051688194275,
-0.07287249714136124,
0.15694719552993774,
-0.6474024057388306... |
func CopyHeaders(dst, src http.Header) {
for k, vv := range src {
dst[k] = append([]string{}, vv...)
}
} | [
-0.7653377652168274,
-0.1120796650648117,
0.26688721776008606,
-0.6894055008888245,
-0.2512524425983429,
0.5157678723335266,
-1.7542885541915894,
-0.1027839332818985,
-0.6438366770744324,
1.38804292678833,
-0.7439183592796326,
0.8480827212333679,
-0.06853695958852768,
0.29050445556640625,
... |
func HasHeaders(names []string, headers http.Header) bool {
for _, h := range names {
if headers.Get(h) != "" {
return true
}
}
return false
} | [
-0.057241860777139664,
0.0877131000161171,
0.5964159965515137,
-0.06223578751087189,
0.25958219170570374,
-0.22963406145572662,
-1.894962191581726,
0.1843971610069275,
-0.635869026184082,
0.18829618394374847,
-0.4542570114135742,
-0.9242632985115051,
-0.8210774660110474,
0.6657024025917053... |
func RemoveHeaders(headers http.Header, names ...string) {
for _, h := range names {
headers.Del(h)
}
} | [
-0.5270053148269653,
0.21934416890144348,
0.4608578681945801,
-0.20115306973457336,
-0.23559439182281494,
-0.22938759624958038,
-1.3121908903121948,
0.16302751004695892,
-0.8660379648208618,
0.2500901520252228,
-0.8491197824478149,
-0.6467892527580261,
-1.3988816738128662,
0.37917953729629... |
func IsWebsocketRequest(req *http.Request) bool {
return ConstainsHeader(req, "Connection", "upgrade") && ConstainsHeader(req, "Upgrade", "websocket")
} | [
-0.8729269504547119,
0.08708484470844269,
0.7700903415679932,
0.6582483649253845,
-0.28201499581336975,
-0.45072728395462036,
-0.8187448978424072,
-0.8332089185714722,
1.183396339416504,
0.364612877368927,
0.2652013301849365,
0.9006953239440918,
0.37770169973373413,
1.4813084602355957,
-... |
func ConstainsHeader(req *http.Request, name, value string) bool {
if name == "" || value == "" {
return false
}
items := strings.Split(req.Header.Get(name), ",")
for _, item := range items {
if value == strings.ToLower(strings.TrimSpace(item)) {
return true
}
}
return false
} | [
-0.2419908493757248,
-0.7667983770370483,
0.5823209285736084,
0.15254119038581848,
-0.32231342792510986,
0.22195884585380554,
-1.4978415966033936,
-0.19239382445812225,
-0.3643605709075928,
0.09765690565109253,
0.2990264892578125,
-0.3114365339279175,
-1.317213535308838,
0.3306163251399994... |
func init() {
var transport = NewDefaultPooledTransport()
EnsureTransporterFinalized(transport)
DefaultTransport = transport
} | [
0.17210757732391357,
0.10789833217859268,
0.3525317907333374,
-0.15982204675674438,
1.0543444156646729,
0.5014602541923523,
0.5395451188087463,
0.00640097027644515,
-0.6932719349861145,
-0.22649887204170227,
-1.21577787399292,
0.34920498728752136,
-0.18630920350551605,
0.29629677534103394,... |
func EnsureTransporterFinalized(httpTransport *http.Transport) {
runtime.SetFinalizer(&httpTransport, func(transportInt **http.Transport) {
(*transportInt).CloseIdleConnections()
})
} | [
-0.5430610179901123,
-0.4154475927352905,
0.422606885433197,
-0.5921231508255005,
0.37997812032699585,
0.42182204127311707,
-0.3286173939704895,
-1.0171140432357788,
0.0016405237838625908,
-0.3485836386680603,
-1.010675072669983,
-0.723101019859314,
-0.6389509439468384,
1.0643583536148071,... |
func NewDefaultTransport() *http.Transport {
transport := NewDefaultPooledTransport()
transport.DisableKeepAlives = true
transport.MaxIdleConnsPerHost = -1
return transport
} | [
0.049891311675310135,
0.16497503221035004,
0.3143249750137329,
0.8304770588874817,
0.23344361782073975,
0.4373086392879486,
0.2184692919254303,
-0.4006955623626709,
0.20606064796447754,
-0.5348122715950012,
-1.3346730470657349,
-0.023185808211565018,
-0.6417273283004761,
-0.063472628593444... |
func NewDefaultPooledTransport() *http.Transport {
return &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
DisableKeepAlives: false,
MaxIdleConnsPerHost: 1,
}
} | [
0.0839424878358841,
-0.047615617513656616,
0.4825689196586609,
-0.10581286996603012,
0.21524778008460999,
0.7751876711845398,
-0.18627645075321198,
-0.8326184153556824,
0.02106531336903572,
-0.0035244354512542486,
-1.6401703357696533,
0.11156374961137772,
-0.5430673956871033,
0.12351782619... |
func Bytes(n int64, decimals int, long bool) string {
padding := " "
levels := []string{
"B", "KB", "MB", "GB", "TB", "PB", "EB", /* "ZB", "YB" will overflow int64 */
}
if long {
levels = []string{
"bytes", "kilobyte", "megabyte", "gigabyte", "terabyte", "petabyte", "exabyte",
}
}
return human(n, levels... | [
-0.6076761484146118,
0.5809304714202881,
0.6080594658851624,
-0.6506302952766418,
-0.6172745823860168,
0.3835833668708801,
-1.3379942178726196,
-0.6734925508499146,
-0.27657732367515564,
-0.5440497994422913,
0.332695871591568,
0.07743315398693085,
0.20736537873744965,
-0.031177867203950882... |
func Kilos(n int64, decimals int, long bool) string {
padding := " "
levels := []string{
"", "k", "M", "G", "T", "P", "E", /* "Z", "Y" will overflow int64 */
}
if long {
levels = []string{
"s", "kilo", "mega", "giga", "tera", "peta", "exa",
}
}
return human(n, levels, 1000, decimals, padding)
} | [
-0.2047998458147049,
0.8379206657409668,
0.6187681555747986,
-0.45248648524284363,
-1.5670018196105957,
-0.5785995721817017,
-1.4991447925567627,
-0.6648955941200256,
-0.6576730608940125,
0.2646123170852661,
0.5263738036155701,
-0.0813879445195198,
0.9347779750823975,
0.09918971359729767,
... |
func human(n int64, levels []string, base int, decimals int, padding string) string {
format := fmt.Sprintf("%%.%df%v%%v", decimals, padding)
res := strconv.FormatInt(n, 10)
for i, level := range levels {
nom := float64(n)
den := math.Pow(float64(base), float64(i))
val := nom / den
if val < float64(base) {... | [
0.2892594337463379,
0.03284574672579765,
0.772855818271637,
-0.42783457040786743,
-0.7188292145729065,
-0.08446281403303146,
-0.21244798600673676,
-0.8291528820991516,
-1.900611400604248,
-0.06942345947027206,
0.37606102228164673,
-0.4840702414512634,
0.18321143090724945,
0.194646984338760... |
func Abs(x int) int {
if x < 0 {
return -x
}
return x
} | [
-1.0961229801177979,
0.16803443431854248,
0.3248300552368164,
-0.18877452611923218,
-0.7153193354606628,
1.065349817276001,
-1.297670602798462,
-0.5553025007247925,
-0.3668280839920044,
-0.5725286602973938,
0.22804827988147736,
1.0209152698516846,
0.7503883242607117,
0.18345056474208832,
... |
func LoginAs(user *model.User) (echo.Context, echo.HandlerFunc) {
sd, _ := Login(user)
token := sd.Token
token = "Bearer " + token
e := cuxs.New()
req, _ := http.NewRequest(echo.GET, "/", nil)
req.Header.Set(echo.HeaderAuthorization, token)
res := httptest.NewRecorder()
c := e.NewContext(req, res)
var x = fu... | [
-0.8301131129264832,
-0.5822432041168213,
0.9166388511657715,
0.18263240158557892,
-0.8543145060539246,
0.2817370891571045,
-0.503452718257904,
-0.8379949331283569,
0.5978147983551025,
-0.7594258189201355,
-0.8487364649772644,
1.0090479850769043,
1.0358638763427734,
-0.3216516375541687,
... |
func timeDelta(event string) {
now := time.Now()
debug.Printf("Time [%s]: %s", event, now.Sub(lastTimeDelta).String())
lastTimeDelta = now
} | [
0.40916767716407776,
-0.8893002271652222,
0.76142418384552,
-0.9346787929534912,
0.8735372424125671,
0.321402907371521,
0.9326186180114746,
0.5631019473075867,
-0.11095427721738815,
-0.41471123695373535,
-0.25082188844680786,
0.37817737460136414,
0.1367008090019226,
0.4214034676551819,
0... |
func tildeExpand(path string) (string, error) {
path = filepath.Clean(path)
if path[:2] == "~/" {
usr, err := user.Current()
if err != nil {
return path, err
}
homedir := usr.HomeDir
return strings.Replace(path, "~", homedir, 1), nil
} else if path[:1] == "~" {
slashindex := strings.Index(path, "/")
... | [
-0.24066823720932007,
0.3983016014099121,
0.9909245371818542,
0.5315709710121155,
-1.0943156480789185,
0.8421667218208313,
1.5801489353179932,
0.08501207083463669,
0.48471879959106445,
-0.17398451268672943,
0.8167577981948853,
0.26038670539855957,
-0.714902400970459,
0.15615901350975037,
... |
func decodeHexString(s string) []byte {
r, err := hex.DecodeString(s)
if err != nil {
log.Fatalf("unable to decode hex string: %v\n", err)
}
return r
} | [
0.3040899932384491,
-0.43241867423057556,
0.15258951485157013,
-0.04612649232149124,
-0.5957037210464478,
0.17287294566631317,
-0.9874130487442017,
0.5595642328262329,
0.15846602618694305,
-0.4525572657585144,
-0.7021104097366333,
0.01670878194272518,
-0.5936113595962524,
-0.87795019149780... |
func fmtbytes(n int64, fixedWidth bool) string {
if fixedWidth {
if n >= 1024*1024*1024*1024 {
return fmt.Sprintf("%6.2f TiB", float64(n)/(1024.*1024.*
1024.*1024.))
} else if n >= 1024*1024*1024 {
return fmt.Sprintf("%6.2f GiB", float64(n)/(1024.*1024.*
1024.))
} else if n > 1024*1024 {
return ... | [
0.5011745095252991,
0.18307384848594666,
0.7917149662971497,
-1.159972071647644,
-0.6120948791503906,
-0.48513063788414,
-0.36630353331565857,
-0.7137054204940796,
0.3564031422138214,
0.4753679931163788,
0.5327879786491394,
-0.16578306257724762,
-0.5323036313056946,
1.4451793432235718,
-... |
func printFinalStats() {
updateActiveMemory()
statsMutex.Lock()
defer statsMutex.Unlock()
syncTime := time.Now().Sub(syncStartTime)
fmt.Printf("skicka: preparation time %s, sync time %s\n",
fmtDuration(syncStartTime.Sub(startTime)), fmtDuration(syncTime))
fmt.Printf("skicka: updated %d Drive files, %d local f... | [
0.9273477792739868,
-0.6303379535675049,
0.7475836277008057,
-0.7879446744918823,
0.23683424293994904,
0.06668533384799957,
0.1635223925113678,
-0.6793057918548584,
-0.10476792603731155,
-0.0558658130466938,
0.3734402358531952,
1.3186759948730469,
-0.25307464599609375,
0.7675920128822327,
... |
func handleHTTPResponse(resp *http.Response, err error, ntries int) HTTPResponseResult {
if err == nil && resp != nil && resp.StatusCode >= 200 && resp.StatusCode <= 299 {
return Success
}
if ntries == maxHTTPRetries {
return Fail
}
if resp != nil && resp.StatusCode == 401 {
// After an hour, the OAuth2 to... | [
-0.18715567886829376,
-0.15153561532497406,
0.49382680654525757,
-0.35845381021499634,
-0.3229779303073883,
-0.6707050800323486,
-0.9717133045196533,
-0.8223729729652405,
0.3854318857192993,
0.05186864361166954,
0.27948933839797974,
-0.5583807229995728,
-0.7443219423294067,
-0.808021843433... |
func encryptBytes(key []byte, iv []byte, plaintext []byte) []byte {
r, _ := ioutil.ReadAll(makeEncrypterReader(key, iv, bytes.NewReader(plaintext)))
return r
} | [
-0.4824841618537903,
0.7828910946846008,
0.25939518213272095,
0.029966464266180992,
0.447454035282135,
-0.22911196947097778,
-0.9713770151138306,
-0.03645366430282593,
-0.46008628606796265,
1.2926325798034668,
-0.4658648371696472,
0.2825446128845215,
-1.6467865705490112,
-0.256491094827652... |
func makeEncrypterReader(key []byte, iv []byte, reader io.Reader) io.Reader {
if key == nil {
log.Fatalf("uninitialized key in makeEncrypterReader()")
}
block, err := aes.NewCipher(key)
if err != nil {
log.Fatalf("unable to create AES cypher: %v", err)
}
if len(iv) != aes.BlockSize {
log.Fatalf("IV length %... | [
-0.2183387130498886,
-0.6447329521179199,
0.40933603048324585,
-0.42323288321495056,
-0.7456310987472534,
0.037844568490982056,
0.18030574917793274,
0.4685544967651367,
0.024115275591611862,
0.5587752461433411,
0.10310858488082886,
0.13262680172920227,
-0.7046915292739868,
0.19685079157352... |
func decryptBytes(key []byte, iv []byte, ciphertext []byte) []byte {
r, _ := ioutil.ReadAll(makeDecryptionReader(key, iv, bytes.NewReader(ciphertext)))
return r
} | [
-0.11075941473245621,
0.38034313917160034,
0.27680015563964844,
-0.08169480413198471,
-0.147067591547966,
-0.5346421003341675,
-0.6587552428245544,
0.48088523745536804,
-0.44974640011787415,
0.9622824192047119,
-0.5683113932609558,
-0.06402424722909927,
-1.3776109218597412,
-0.663769841194... |
func getRandomBytes(n int) []byte {
bytes := make([]byte, n)
if _, err := io.ReadFull(rand.Reader, bytes); err != nil {
log.Fatalf("unable to get random bytes: %v", err)
}
return bytes
} | [
-0.152800515294075,
0.7526701092720032,
0.26848477125167847,
0.33736366033554077,
-0.037299998104572296,
0.2700697183609009,
-0.4502415955066681,
-1.1965452432632446,
0.8323330283164978,
-0.2700705826282501,
-0.7539572715759277,
-0.06346263736486435,
-1.1552810668945312,
0.6679460406303406... |
func generateKey() {
passphrase := os.Getenv(passphraseEnvironmentVariable)
if passphrase == "" {
printErrorAndExit(fmt.Errorf("skicka: SKICKA_PASSPHRASE " +
"environment variable not set.\n"))
}
// Derive a 64-byte hash from the passphrase using PBKDF2 with 65536
// rounds of SHA256.
salt := getRandomBytes... | [
-0.014804428443312645,
0.4792797863483429,
0.877373456954956,
-0.2183632254600525,
1.1734641790390015,
0.3971237242221832,
0.2571113407611847,
0.33419620990753174,
-0.3249419033527374,
0.6095613837242126,
-0.11720799654722214,
-0.06928027421236038,
-0.11206918954849243,
0.8542329668998718,... |
func decryptEncryptionKey() ([]byte, error) {
if key != nil {
log.Fatalf("key aready decrypted!")
}
salt := decodeHexString(config.Encryption.Salt)
passphraseHash := decodeHexString(config.Encryption.Passphrase_hash)
encryptedKey := decodeHexString(config.Encryption.Encrypted_key)
encryptedKeyIv := decodeHexSt... | [
-0.15633636713027954,
0.37426063418388367,
0.7407984137535095,
0.2735648453235626,
0.6132581830024719,
0.04389912262558937,
0.47733378410339355,
0.2787659466266632,
-0.5478429794311523,
0.577430248260498,
0.2535337209701538,
-0.4071786105632782,
-0.7506210803985596,
0.6854732036590576,
0... |
func getFileById(id string) (*drive.File, error) {
for ntries := 0; ; ntries++ {
file, err := drivesvc.Files.Get(id).Do()
if err == nil {
return file, nil
} else if err = tryToHandleDriveAPIError(err, ntries); err != nil {
return nil, err
}
}
} | [
0.36548733711242676,
0.02828272432088852,
0.27131250500679016,
-0.2971054017543793,
0.9974246621131897,
-0.47496989369392395,
-0.11388066411018372,
-0.7629839181900024,
-0.3134782016277313,
-0.6883244514465332,
0.4855738580226898,
-0.5129808783531189,
-1.0030184984207153,
0.523912966251373... |
func runDriveQuery(query string) []*drive.File {
pageToken := ""
var result []*drive.File
for {
q := drivesvc.Files.List().Q(query)
if pageToken != "" {
q = q.PageToken(pageToken)
}
for ntries := 0; ; ntries++ {
r, err := q.Do()
if err == nil {
result = append(result, r.Items...)
pageToken ... | [
-0.9159800410270691,
-0.7300344705581665,
0.584206759929657,
-0.2181338220834732,
0.6957866549491882,
-0.4827878475189209,
-0.681306004524231,
-0.029662635177373886,
0.07497070729732513,
-0.3962089419364929,
0.5315144658088684,
-0.05575691908597946,
-1.4373149871826172,
0.7232491374015808,... |
func deleteIncompleteDriveFiles(title string, parentId string) {
query := fmt.Sprintf("'%s' in parents and title='%s'", parentId, title)
files := runDriveQuery(query)
for _, f := range files {
for ntries := 0; ; ntries++ {
err := drivesvc.Files.Delete(f.Id).Do()
if err == nil {
return
} else if err = ... | [
0.055309731513261795,
-0.6807807087898254,
0.627152681350708,
-0.3559942841529846,
0.3790218234062195,
-0.47643542289733887,
0.5282014012336731,
0.24978548288345337,
-0.47520026564598083,
0.5096859335899353,
0.18573163449764252,
-0.5789939165115356,
-1.4526393413543701,
0.4917641282081604,... |
func createMissingProperties(f *drive.File, mode os.FileMode, encrypt bool) error {
if !isFolder(f) {
if encrypt {
if _, err := getProperty(f, "IV"); err != nil {
// Compute a unique IV for the file.
iv := getRandomBytes(aes.BlockSize)
ivhex := hex.EncodeToString(iv)
ivprop := new(drive.Property)... | [
-0.27239811420440674,
-0.12627796828746796,
0.6944632530212402,
0.2073291391134262,
0.8444493412971497,
0.45708024501800537,
-0.11703266203403473,
0.36606714129447937,
-0.5611915588378906,
0.14488470554351807,
0.3147113025188446,
-0.5184085965156555,
0.018426604568958282,
0.491360694169998... |
func insertNewDriveFile(f *drive.File) (*drive.File, error) {
for ntries := 0; ; ntries++ {
r, err := drivesvc.Files.Insert(f).Do()
if err == nil {
debug.Printf("Created new Google Drive file for %s: ID=%s",
f.Title, r.Id)
return r, err
}
debug.Printf("Error %v trying to create drive file for %s. "+
... | [
-0.4682224988937378,
0.460347980260849,
0.6799301505088806,
-0.3480861783027649,
1.2405200004577637,
0.3173219859600067,
0.6028077006340027,
-0.3595157265663147,
-1.0907748937606812,
-0.538801908493042,
0.07661934196949005,
-0.9123744368553162,
-1.2112263441085815,
0.9361752271652222,
0.... |
func createDriveFile(filename string, mode os.FileMode, modTime time.Time, encrypt bool,
parentFolder *drive.File) (*drive.File, error) {
var proplist []*drive.Property
if encrypt {
// Compute a unique IV for the file.
iv := getRandomBytes(aes.BlockSize)
ivhex := hex.EncodeToString(iv)
ivprop := new(drive.P... | [
0.20229142904281616,
0.017035584896802902,
0.9897818565368652,
-0.10482747852802277,
0.8866561651229858,
0.5393579602241516,
-0.12679995596408844,
0.5531660318374634,
-1.1985630989074707,
-0.17539362609386444,
0.3273008167743683,
-0.7666394114494324,
-1.1040151119232178,
-0.138708129525184... |
func createDriveFolder(title string, mode os.FileMode, modTime time.Time,
parentFolder *drive.File) (*drive.File, error) {
var proplist []*drive.Property
permprop := new(drive.Property)
permprop.Key = "Permissions"
permprop.Value = fmt.Sprintf("%#o", mode&os.ModePerm)
proplist = append(proplist, permprop)
paren... | [
0.0011102533899247646,
-0.3181067407131195,
0.8397123217582703,
0.01605003885924816,
0.40801507234573364,
0.8290254473686218,
0.12185673415660858,
-0.1376553773880005,
-1.240084171295166,
-0.38823142647743225,
0.4274566173553467,
-0.2259114682674408,
-1.0846319198608398,
0.5822114944458008... |
func getDriveFile(path string) (*drive.File, error) {
parent, err := getFileById("root")
if err != nil {
return nil, fmt.Errorf("unable to get Drive root directory: %v", err)
}
dirs := strings.Split(path, "/")
// Walk through the directories in the path in turn.
for _, dir := range dirs {
if dir == "" {
/... | [
0.6266098618507385,
0.29225724935531616,
0.7740218639373779,
0.36505579948425293,
0.5846577882766724,
-0.5587940216064453,
0.9410064220428467,
-0.6347296237945557,
-0.5644351243972778,
-0.4601442217826843,
0.5734269618988037,
-0.22733467817306519,
-1.4504793882369995,
0.15790754556655884,
... |
func getFolderContents(path string, parentFolder *drive.File, recursive bool,
existingFiles map[string]*drive.File) error {
query := fmt.Sprintf("trashed=false and '%s' in parents", parentFolder.Id)
dirfiles := runDriveQuery(query)
for _, f := range dirfiles {
filepath := filepath.Clean(path + "/" + f.Title)
if... | [
-0.12345492839813232,
0.07758542150259018,
0.5826444029808044,
0.7615272998809814,
0.2811366319656372,
-0.30538496375083923,
0.2840583622455597,
-0.502315878868103,
-1.2422584295272827,
-0.11647838354110718,
0.591151237487793,
-0.5369088053703308,
-0.4692271649837494,
0.9502676725387573,
... |
func getFilesAtRemotePath(path string, recursive, includeBase,
mustExist bool) map[string]*drive.File {
existingFiles := make(map[string]*drive.File)
file, err := getDriveFile(path)
if err != nil {
if !mustExist {
return existingFiles
}
printErrorAndExit(fmt.Errorf("skicka: %v\n", err))
}
if isFolder(fi... | [
-0.01680748350918293,
-0.16923178732395172,
0.7850568890571594,
-0.15152493119239807,
0.022451424971222878,
0.6951826214790344,
-0.7117847800254822,
0.12064438313245773,
-0.8329043984413147,
0.7181045413017273,
-0.00930849276483059,
0.4078846871852875,
-0.865996241569519,
0.633432626724243... |
func getProperty(driveFile *drive.File, name string) (string, error) {
for _, prop := range driveFile.Properties {
if prop.Key == name {
return prop.Value, nil
}
}
return "", fmt.Errorf("%s: property not found", name)
} | [
0.16561958193778992,
-1.6301727294921875,
0.5746929049491882,
0.3237469494342804,
-0.15932482481002808,
-0.500957190990448,
-0.2713356018066406,
-0.21241429448127747,
-0.7246850728988647,
1.0256391763687134,
1.0050060749053955,
-0.3596661686897278,
-0.7274776101112366,
-0.33893105387687683... |
func getInitializationVector(driveFile *drive.File) ([]byte, error) {
ivhex, err := getProperty(driveFile, "IV")
if err != nil {
return nil, err
}
iv, err := hex.DecodeString(ivhex)
if err != nil {
return nil, err
}
if len(iv) != aes.BlockSize {
return nil, fmt.Errorf("unexpected length of IV %d", len(iv))... | [
-0.5021440982818604,
-0.15791000425815582,
0.7088127732276917,
-0.16524621844291687,
0.22580517828464508,
0.09783269464969635,
0.29194891452789307,
0.4802253842353821,
-0.15102770924568176,
0.2723017930984497,
-0.25450587272644043,
0.23806199431419373,
-0.492886483669281,
0.531441211700439... |
func uploadFileContents(driveFile *drive.File, contentsReader io.Reader,
length int64, currentTry int) error {
// Limit upload bandwidth, if requested..
if config.Upload.Bytes_per_second_limit > 0 {
contentsReader = &RateLimitedReader{R: contentsReader}
}
// Get the PUT request for the upload.
req, err := prep... | [
-0.568272590637207,
-0.2289571613073349,
0.790299117565155,
-0.46434804797172546,
-0.207346573472023,
-0.7716771364212036,
-0.18340665102005005,
-0.6615781784057617,
-0.4302637577056885,
0.3441677391529083,
0.6273773312568665,
-0.4697408676147461,
-0.9780573844909668,
-0.2181129902601242,
... |
func getDriveFileContentsReader(driveFile *drive.File) (io.ReadCloser, error) {
// The file download URL expires some hours after it's retrieved;
// re-grab the file right before downloading it so that we have a
// fresh URL.
driveFile, err := getFileById(driveFile.Id)
if err != nil {
return nil, err
}
url :=... | [
-0.3633602559566498,
-1.1853413581848145,
0.6218002438545227,
-0.3733634352684021,
-0.13858526945114136,
-0.585436999797821,
-0.5870533585548401,
-0.35735371708869934,
-0.6764233112335205,
-0.47577613592147827,
1.1424567699432373,
-0.25137123465538025,
-0.827228307723999,
0.196639671921730... |
func tryToHandleDriveAPIError(err error, ntries int) error {
debug.Printf("tryToHandleDriveAPIError: ntries %d error %T %+v",
ntries, err, err)
maxAPIRetries := 6
if ntries == maxAPIRetries {
return err
}
switch err := err.(type) {
case *googleapi.Error:
if err.Code == 401 {
// After an hour, the OAuth2... | [
-0.3429936468601227,
-0.14263816177845,
0.4306722581386566,
-0.5093969702720642,
-0.042086102068424225,
-0.2780522108078003,
-0.7104186415672302,
-0.5003666877746582,
0.3536769449710846,
-0.11540406942367554,
0.44606709480285645,
0.09030172228813171,
-0.3255423605442047,
-0.027934221550822... |
func fileMetadataMatches(info os.FileInfo, encrypt bool,
driveFile *drive.File) (bool, error) {
localSize := info.Size()
driveSize := driveFile.FileSize
if encrypt {
// We store a copy of the initialization vector at the start of
// the file stored in Google Drive; account for this when
// comparing the file ... | [
-0.1958869844675064,
-0.6634193062782288,
0.8486410975456238,
-0.177427738904953,
0.12326626479625702,
0.5308630466461182,
-0.4279063642024994,
-0.005558250471949577,
-0.2464928925037384,
0.8317301273345947,
0.149173766374588,
-0.13180015981197357,
-0.8109168410301208,
0.1503477841615677,
... |
func localFileMD5Contents(path string, encrypt bool, iv []byte) (string, error) {
contentsReader, _, err := getFileContentsReaderForUpload(path, encrypt, iv)
if contentsReader != nil {
defer contentsReader.Close()
}
if err != nil {
return "", err
}
md5 := md5.New()
n, err := io.Copy(md5, contentsReader)
if... | [
-0.32651931047439575,
-0.9934577941894531,
0.5492186546325684,
-0.8153246641159058,
-1.0173500776290894,
-0.019161222502589226,
-0.013352510519325733,
-0.5770699977874756,
-0.6959553956985474,
0.4876905679702759,
0.12081480771303177,
-0.7978114485740662,
-0.6524158716201782,
-0.13377323746... |
func getFileContentsReaderForUpload(path string, encrypt bool,
iv []byte) (io.ReadCloser, int64, error) {
f, err := os.Open(path)
if err != nil {
return f, 0, err
}
stat, err := os.Stat(path)
if err != nil {
return nil, 0, err
}
fileSize := stat.Size()
if encrypt {
if key == nil {
key, err = decrypt... | [
-0.4893643260002136,
-0.6670973300933838,
0.8392436504364014,
-0.36870497465133667,
-0.5827038884162903,
-0.6865746378898621,
-0.10602085292339325,
-0.21142509579658508,
-0.68789142370224,
0.26173436641693115,
0.6360552906990051,
-0.20472244918346405,
-0.22297713160514832,
0.17919446527957... |
func syncFileUp(fileMapping LocalToRemoteFileMapping, encrypt bool,
existingDriveFiles map[string]*drive.File, pb *pb.ProgressBar) error {
debug.Printf("syncFileUp: %#v", fileMapping.LocalFileInfo)
// We need to create the file or folder on Google Drive.
var err error
// Get the *drive.File for the folder to cre... | [
-0.3397282361984253,
-0.487745076417923,
0.8238237500190735,
-0.1558554321527481,
0.730925977230072,
0.026845484972000122,
0.8754311203956604,
-0.09665241837501526,
-0.7076954245567322,
0.30952200293540955,
0.41317152976989746,
-0.13013802468776703,
-0.2172907590866089,
0.3789253830909729,... |
func syncHierarchyUp(localPath string, driveRoot string,
existingFiles map[string]*drive.File,
encrypt bool, ignoreTimes bool) error {
if encrypt {
var err error
key, err = decryptEncryptionKey()
if err != nil {
return err
}
}
// Kick off a background thread to periodically allow uploading
// a bit mo... | [
-0.2614505887031555,
0.023847106844186783,
0.9471344947814941,
0.4213383197784424,
0.5331069231033325,
-0.36431464552879333,
0.8056939840316772,
0.16218483448028564,
-0.11027101427316666,
0.40565523505210876,
0.08417809009552002,
-0.218398317694664,
-0.4932858347892761,
0.5459044575691223,... |
func isEncrypted(file *drive.File) (bool, error) {
if _, err := getProperty(file, "IV"); err == nil {
if strings.HasSuffix(file.Title, encryptionSuffix) {
return true, nil
}
return false, fmt.Errorf("has IV property but doesn't " +
"end with .aes256 suffix")
} else if strings.HasSuffix(file.Title, encrypt... | [
-0.14338751137256622,
-0.21537931263446808,
0.960145115852356,
0.3148048222064972,
0.24674075841903687,
-0.24580347537994385,
0.42449304461479187,
0.2349013239145279,
0.10901202261447906,
1.013689398765564,
-0.27392035722732544,
0.41452229022979736,
-0.5743594169616699,
0.4383982717990875,... |
func fileNeedsDownload(localPath string, drivePath string, driveFile *drive.File,
ignoreTimes bool) (bool, error) {
// See if the local file exists at all.
stat, err := os.Stat(localPath)
if err != nil {
// The local file doesn't exist (probably).
// TODO: confirm that's in fact the error...
return true, nil
... | [
-0.41959264874458313,
-0.03299352899193764,
0.9405615329742432,
-0.3663211464881897,
0.20950859785079956,
0.34284520149230957,
-0.16032984852790833,
-0.21442465484142303,
-0.6841143369674683,
0.44720134139060974,
0.5266111493110657,
-0.2089804857969284,
-0.36385560035705566,
0.800415575504... |
func syncFolderDown(localPath string, driveFilename string, driveFile *drive.File) error {
permissions, err := getPermissions(driveFile)
if err != nil {
permissions = 0755
}
if stat, err := os.Stat(localPath); err == nil {
// A file or directory already exists at localPath.
if stat.IsDir() {
err = os.Chmo... | [
0.5092242956161499,
-0.2574848532676697,
0.7473685145378113,
0.5194554924964905,
0.3334643542766571,
0.16763578355312347,
1.0980134010314941,
0.2487165927886963,
-0.35357430577278137,
-0.393291711807251,
0.9086948037147522,
-0.39960789680480957,
-0.4668126106262207,
0.6975409984588623,
0... |
func downloadDriveFile(writer io.Writer, driveFile *drive.File) error {
driveContentsReader, err := getDriveFileContentsReader(driveFile)
if driveContentsReader != nil {
defer driveContentsReader.Close()
}
if err != nil {
return err
}
// Rate-limit the download, if required.
var contentsReader io.Reader = d... | [
0.30922406911849976,
-0.43465766310691833,
0.6828063726425171,
-0.22815069556236267,
0.6484330296516418,
-0.7520269155502319,
0.43663352727890015,
0.05601192265748978,
-0.5780900716781616,
0.3271189033985138,
0.674685537815094,
-0.5398737192153931,
-0.4602707624435425,
-0.04743396118283272... |
func syncHierarchyDown(drivePath string, localPath string,
filesOnDrive map[string]*drive.File, ignoreTimes bool) error {
var driveFilenames []string
for name := range filesOnDrive {
driveFilenames = append(driveFilenames, name)
}
sort.Strings(driveFilenames)
// Both drivePath and localPath must be directories... | [
-0.03338925540447235,
-0.4579106569290161,
1.0076509714126587,
0.29000651836395264,
0.5143215656280518,
-0.28521761298179626,
0.571140468120575,
0.2588907778263092,
-0.5015766024589539,
0.2586991488933563,
0.7288730144500732,
-0.220524400472641,
-0.9180979132652283,
1.3305766582489014,
0... |
func createConfigFile(filename string) {
contents := `; Default .skicka.config file. See
; https://github.com/google/skicka/blob/master/README.md for more
; information about setting up skicka.
[google]
clientid=YOUR_GOOGLE_APP_CLIENT_ID
clientsecret=YOUR_GOOGLE_APP_SECRET
[encryption]
; Run 'skicka genkey'... | [
-0.15988166630268097,
-0.07846959680318832,
0.5817047357559204,
0.23148643970489502,
0.9328248500823975,
-0.026341766119003296,
0.8071611523628235,
0.2781755328178406,
-0.9753175973892212,
1.0988267660140991,
-0.3659260869026184,
-0.43902266025543213,
-0.4004574418067932,
0.744675099849700... |
func checkConfigValidity() {
nerrs := 0
if config.Google.ClientId == "" ||
config.Google.ClientId == "YOUR_GOOGLE_APP_CLIENT_ID" {
fmt.Fprintf(os.Stderr, "skicka: missing [google]/clientid in "+
"configuration file.\n")
nerrs++
}
if config.Google.ClientSecret == "" ||
config.Google.ClientSecret == "YOUR_... | [
-0.5213354229927063,
-0.07210919260978699,
0.752498209476471,
0.8243561387062073,
0.5794780850410461,
0.7868019342422485,
0.21076638996601105,
-0.08831144124269485,
-0.8428787589073181,
1.4069592952728271,
0.2821955978870392,
0.2995154857635498,
-0.8383889198303223,
1.1262528896331787,
1... |
func NewAPI(config config.Config, logger log.Logger) *API {
api := &API{
mux.NewRouter().StrictSlash(false),
newAuthMiddleware(config, logger),
log.NewLoggerWith(logger, "component", "api"),
config,
}
api.addRoute("", http.MethodGet, "/", func(w http.ResponseWriter, r *http.Request) {
if err := json.NewEn... | [
-0.6009355783462524,
-0.49509552121162415,
0.5728086233139038,
0.4097856283187866,
-0.8891412019729614,
0.2870014011859894,
0.1383543312549591,
0.5878511667251587,
0.12629833817481995,
0.07995772361755371,
-0.052260808646678925,
-0.1318511813879013,
-0.0042180451564490795,
0.25573155283927... |
func (a *API) AddRouteV1(method, path string, handleFunc http.HandlerFunc) {
a.addRoute("/api/v1", method, path, handleFunc)
} | [
-0.5220804810523987,
-0.0972529798746109,
0.6065345406532288,
0.6793871521949768,
0.8808014392852783,
0.3855230510234833,
-0.3112863302230835,
1.042797327041626,
-0.2680811285972595,
0.08692105859518051,
0.2911544144153595,
0.7351523041725159,
0.35634031891822815,
-0.1646644026041031,
-0... |
func (a *API) AddRouteV1WithBasicAuth(method, path string, handleFunc http.HandlerFunc) {
a.addRoute("/api/v1", method, path, a.enforceBasicAuth(handleFunc))
} | [
-0.5525239706039429,
-0.11163412034511566,
0.6491943001747131,
1.2101573944091797,
0.7216675877571106,
0.5430518388748169,
-0.4230664372444153,
0.49704715609550476,
-0.12024004757404327,
-0.02495250664651394,
0.3849487602710724,
0.09113230556249619,
0.26927879452705383,
-0.466131329536438,... |
func (a *API) Serve() error {
host := fmt.Sprintf("0.0.0.0:%d", a.Config.ListenPort)
a.logger.LogInfo("starting api", "host", "0.0.0.0", "port", a.Config.ListenPort)
return http.ListenAndServe(host, a)
} | [
-0.3852466940879822,
-1.346781849861145,
0.2747485637664795,
-0.465248167514801,
0.5807585120201111,
0.014758110046386719,
-0.205688938498497,
0.4936966896057129,
-1.0977249145507812,
-0.3190261423587799,
-0.2928404211997986,
-0.0603235699236393,
-0.9114044308662415,
-0.018259696662425995,... |
func NewCmdAddApp(commonOpts *opts.CommonOptions) *cobra.Command {
options := &AddAppOptions{
AddOptions: AddOptions{
CommonOptions: commonOpts,
},
}
cmd := &cobra.Command{
Use: "app",
Short: "Adds an App (an app is similar to an addon)",
Long: add_app_long,
Example: add_app_example,
Run: ... | [
0.4274670481681824,
-0.6815886497497559,
0.6143218278884888,
0.39545726776123047,
-0.3373963236808777,
0.8623326420783997,
-0.6403501033782959,
-0.34896084666252136,
0.7115470767021179,
0.03474632650613785,
0.3292144536972046,
0.5408464074134827,
-0.2149033546447754,
0.953823983669281,
0... |
func (o *AddAppOptions) Run() error {
o.GitOps, o.DevEnv = o.GetDevEnv()
if o.Repo == "" {
o.Repo = o.DevEnv.Spec.TeamSettings.AppsRepository
}
if o.Repo == "" {
o.Repo = kube.DefaultChartMuseumURL
}
jxClient, ns, err := o.JXClientAndDevNamespace()
if err != nil {
return errors.Wrapf(err, "getting jx clie... | [
0.3698136508464813,
-0.23193563520908356,
0.8003535270690918,
0.29023274779319763,
0.2570491433143616,
0.26832494139671326,
0.21658506989479065,
-1.0091170072555542,
0.10205893963575363,
0.6485393643379211,
0.1102050244808197,
-0.38895782828330994,
0.2565150260925293,
0.7470391392707825,
... |
func (bc *BoltClient) GetDeviceProfilesByCommandId(id string) ([]models.DeviceProfile, error) {
// Check if this command exists
err := bc.checkId(db.Command, id)
if err != nil {
return []models.DeviceProfile{}, err
}
return bc.getDeviceProfilesBy(func(encoded []byte) bool {
commands := jsoniter.Get(encoded, "... | [
0.24233290553092957,
0.5037291049957275,
0.40030166506767273,
-0.0581568218767643,
0.25839972496032715,
-0.05180444195866585,
-0.28226572275161743,
-1.1896750926971436,
0.6958130598068237,
0.759398877620697,
-0.7657775282859802,
0.2699008285999298,
-0.8154672980308533,
1.3612509965896606,
... |
func NewPostStorage() *PostStorage {
return &PostStorage{}
} | [
0.41250428557395935,
-0.4391757547855377,
0.025732479989528656,
0.7645953893661499,
-1.5016547441482544,
-0.394795298576355,
-0.1790386140346527,
-0.8357698321342468,
-0.5374650359153748,
-0.433473140001297,
-0.9242011904716492,
-1.0490570068359375,
-0.47193586826324463,
0.4052020013332367... |
func (ps *PostStorage) Create(post socialnet.Post) (socialnet.Post, error) {
ps.posts = append(ps.posts, post)
return post, nil
} | [
0.43993547558784485,
0.4125063717365265,
0.18142178654670715,
1.1143916845321655,
0.5930225253105164,
0.6893222332000732,
-1.3569470643997192,
-0.6442052721977234,
-0.1497752070426941,
-0.4599425196647644,
-0.19335611164569855,
-1.3619604110717773,
-1.0161035060882568,
0.2804749608039856,
... |
func (ps *PostStorage) Read(id string) (socialnet.Post, error) {
for _, p := range ps.posts {
if p.ID == id {
return p, nil
}
}
return socialnet.Post{}, fmt.Errorf(
"could not find post with ID %s",
id,
)
} | [
0.38304299116134644,
-0.7102619409561157,
0.3546009957790375,
0.31069156527519226,
-0.3391600549221039,
0.19745515286922455,
-0.7471472024917603,
-0.8606773018836975,
0.06912730634212494,
-0.5158739686012268,
0.29129651188850403,
0.016215065494179726,
-0.3721291422843933,
-0.55452322959899... |
func (ps *PostStorage) Update(id string, post socialnet.Post) (socialnet.Post, error) {
for i := range ps.posts {
if ps.posts[i].ID == id {
ps.posts[i] = post
return ps.posts[i], nil
}
}
return socialnet.Post{}, fmt.Errorf(
"could not find post with ID %s",
id,
)
} | [
0.3013014793395996,
-0.6242507696151733,
0.24438922107219696,
0.5785360336303711,
-0.015215377323329449,
0.02821194753050804,
-1.3002160787582397,
-0.68580162525177,
0.13983123004436493,
0.010974440723657608,
-0.04328609257936478,
-0.47507715225219727,
-0.9523180723190308,
-0.4663566350936... |
func (ps *PostStorage) Delete(id string) error {
for i := range ps.posts {
if ps.posts[i].ID == id {
ps.posts = append(ps.posts[:i], ps.posts[i+1:]...)
return nil
}
}
return fmt.Errorf(
"could not find post with ID %s",
id,
)
} | [
0.7093560099601746,
0.30010393261909485,
0.28652894496917725,
0.46915528178215027,
0.5054196715354919,
0.048442211002111435,
-0.4096550941467285,
0.01292638760060072,
0.15294389426708221,
0.354156494140625,
-0.5862910151481628,
-0.2272297739982605,
-0.9542037844657898,
-0.0685267373919487,... |
func (ps *PostStorage) List(username string) ([]socialnet.Post, error) {
var pp []socialnet.Post
for _, p := range ps.posts {
if p.Author == username {
pp = append(pp, p)
}
}
return pp, nil
} | [
0.49589043855667114,
-0.8484500050544739,
0.37495487928390503,
1.182611346244812,
0.1420229822397232,
0.048194508999586105,
-0.6569687724113464,
0.6151869893074036,
0.18901287019252777,
0.005953409243375063,
-0.36018139123916626,
-0.3461124300956726,
-0.40961185097694397,
0.017680309712886... |
func NewRoundRobin[T any](things ...T) (LoadBalance[T], any) {
if len(things) == 0 {
return nil, ErrNoArguments
}
return &roundRobin[T]{things: things, next: 0}, nil
} | [
-0.6608813405036926,
-0.6835609078407288,
0.5462232232093811,
0.32575735449790955,
0.2531973123550415,
-0.10273102670907974,
-0.7811087369918823,
-1.3201571702957153,
-0.5631787776947021,
0.04536917805671692,
-0.4481627345085144,
0.47167620062828064,
-0.9648950099945068,
0.8246126770973206... |
func getZero[T any]() T {
var result T
return result
} | [
0.10688255727291107,
0.06740791350603104,
0.1824965626001358,
1.584766149520874,
0.4843258261680603,
-1.1011362075805664,
0.31191834807395935,
-0.2610206604003906,
-0.3398040533065796,
-1.1795494556427002,
-0.7899386286735535,
0.40636157989501953,
0.1426064670085907,
-0.03037971630692482,
... |
func CreateString(name string, args ...interface{}) string {
stringID := uuid.GenUUID()
dispatcher_client.SendCreateStringReq(name, stringID, args)
return stringID
} | [
-0.697064995765686,
0.3621161878108978,
0.5068978667259216,
0.06938981264829636,
0.010662308894097805,
0.7304626107215881,
-0.21628417074680328,
-0.5881280899047852,
-0.10719303041696548,
0.3271624743938446,
-0.41321897506713867,
-0.15416181087493896,
-0.5308554172515869,
0.053232450038194... |
func CreateStringLocally(name string, args ...interface{}) string {
stringID := uuid.GenUUID()
OnCreateString(name, stringID, args)
dispatcher_client.SendCreateStringLocallyReq(name, stringID)
return stringID
} | [
0.08645164966583252,
-0.4643908441066742,
0.491486132144928,
-0.13113626837730408,
0.06919319927692413,
0.2975708246231079,
-0.18962010741233826,
-0.4649127423763275,
0.1841190755367279,
0.1529821753501892,
-0.3399532437324524,
0.057857997715473175,
0.22615298628807068,
0.29640451073646545... |
func OnCreateString(name string, stringID string, args []interface{}) {
createString(name, stringID, args, _CREATE_NEW, nil, nil)
} | [
0.11693871021270752,
-0.8273015022277832,
0.11004205793142319,
-0.021463356912136078,
0.11085960268974304,
-0.38404905796051025,
-0.46275395154953003,
-1.1682074069976807,
-0.48283499479293823,
0.5800888538360596,
-0.011656060814857483,
-0.14225563406944275,
0.3746303915977478,
0.751166224... |
func DeclareService(sid string, serviceName string) {
dispatcher_client.SendDeclareServiceReq(sid, serviceName)
} | [
0.25637316703796387,
-0.12817884981632233,
0.49504101276397705,
0.7250382304191589,
0.3844560980796814,
0.12269630283117294,
-0.8681551814079285,
-0.2355053573846817,
0.026746265590190887,
-0.5308123230934143,
-0.20887045562267303,
1.2184021472930908,
-0.3794703483581543,
0.944018423557281... |
func onStringRoutineQuit(s *String) {
stringID := s.ID
s.destroyString() // delete the string on local server
dispatcher_client.SendStringDelReq(stringID)
} | [
0.9172267317771912,
-1.399558663368225,
0.18988943099975586,
-1.5755112171173096,
-0.1644568145275116,
-0.09625569730997086,
-0.4069674611091614,
-0.612529993057251,
0.18339326977729797,
0.6384199261665344,
-0.5581642389297485,
0.7849079370498657,
-0.5957828164100647,
-0.31858348846435547,... |
func OnDelString(stringID string) {
undeclareServicesOfString(stringID)
} | [
0.6449317932128906,
-0.9273455739021301,
0.3500116467475891,
-0.39599305391311646,
-1.0194252729415894,
0.07790762186050415,
-0.4772644639015198,
-0.6421725153923035,
0.7587702870368958,
0.1436731368303299,
0.3038850724697113,
1.3519257307052612,
-0.2537783980369568,
0.1280272901058197,
... |
func ShowDep() string {
return "mymodule v0.0.1, fasthttp v1.15.1"
} | [
0.2759983539581299,
-0.8951306343078613,
0.7286823391914368,
0.07572603225708008,
-0.9271243810653687,
0.7571561336517334,
-0.16402564942836761,
-0.2653552293777466,
0.2156246155500412,
0.172943115234375,
0.0649673342704773,
0.35822662711143494,
0.4480597972869873,
0.6589276194572449,
0.... |
func FindMatches(entries []Matchable) ([]PiMatch, error) {
piMap := make(map[string][]Matchable)
// Scan through entries and create pi-->list(entries) mapping of entries
// with common pi value
for _, e := range entries {
piAsHexString := hex.EncodeToString(e.Pi())
tupleList := piMap[piAsHexString]
tupleList... | [
-0.555683434009552,
0.12276517599821091,
0.4866656959056854,
0.08144720643758774,
-0.03365272283554077,
0.2582171857357025,
-0.04495434835553169,
0.5054699778556824,
-0.02568037249147892,
-0.1318647563457489,
-0.43078160285949707,
-1.5363905429840088,
-0.9787101149559021,
0.796354413032531... |
func (fn ScanProductsHandlerFunc) Handle(params ScanProductsParams, principal interface{}) middleware.Responder {
return fn(params, principal)
} | [
-0.44886472821235657,
-0.18194259703159332,
0.27223464846611023,
1.3585706949234009,
-0.6002843379974365,
0.5260933041572571,
0.506945013999939,
-0.4318063259124756,
0.7839663028717041,
-0.7737197875976562,
0.13037152588367462,
-0.24262739717960358,
-0.389325350522995,
-0.7614476680755615,... |
func NewScanProducts(ctx *middleware.Context, handler ScanProductsHandler) *ScanProducts {
return &ScanProducts{Context: ctx, Handler: handler}
} | [
-0.6680737733840942,
-0.1970394402742386,
-0.20242643356323242,
1.3977632522583008,
-1.5156813859939575,
0.29011812806129456,
-0.5249574184417725,
-0.5017898678779602,
0.7677310109138489,
-0.24931541085243225,
-0.9184241890907288,
0.4527011811733246,
-0.028075439855456352,
-0.1001990959048... |
func (o *ScanProductsBody) Validate(formats strfmt.Registry) error {
var res []error
if err := o.validateBody(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
-0.5368159413337708,
-0.44362038373947144,
0.2648162841796875,
0.8087278008460999,
0.06187618523836136,
0.2401464879512787,
-0.23991383612155914,
-1.282859444618225,
0.6446627974510193,
0.3906191289424896,
-0.21797364950180054,
0.15309590101242065,
-0.6068897247314453,
0.2806737422943115,
... |
func (o *ScanProductsBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
} | [
-0.42203521728515625,
-0.2874820828437805,
0.3069496154785156,
0.6636561751365662,
-0.23459862172603607,
0.9690014719963074,
-0.7005589604377747,
-0.9460909366607666,
1.9937983751296997,
0.054277386516332626,
-0.453587144613266,
0.7133532762527466,
-0.8223389387130737,
-0.21461749076843262... |
func Init(workers int, hosts io.Reader, appsFile string, crawlCount int) (chan Result, error) {
var err error
wa, err = NewWebAnalyzer(workers, appsFile)
if err != nil {
return nil, err
}
// increment wg for outer root url loop
wa.wgJobs.Add(1)
// send hosts line by line to worker channel
go func(hosts io.R... | [
-0.44810575246810913,
-0.20070777833461761,
0.6837137341499329,
-0.6549215316772461,
-0.3564428687095642,
0.49875402450561523,
0.5266302227973938,
0.26223665475845337,
-1.2215778827667236,
-0.4990139603614807,
0.21232064068317413,
0.317693293094635,
-0.2806444764137268,
1.2306733131408691,... |
func NewWebAnalyzer(workers int, appsFile string) (*WebAnalyzer, error) {
wa := new(WebAnalyzer)
wa.Results = make(chan Result)
wa.jobs = make(chan *Job)
wa.wg = new(sync.WaitGroup)
wa.wgJobs = new(sync.WaitGroup)
if err := loadApps(appsFile); err != nil {
return nil, err
}
// start workers
initWorker(worker... | [
-0.14941151440143585,
-0.5650979280471802,
0.5577961206436157,
0.46716803312301636,
-1.1251510381698608,
0.09804922342300415,
0.9232158064842224,
0.18570029735565186,
-0.5261824131011963,
-0.25612491369247437,
-0.6997210383415222,
0.24001099169254303,
-0.5536637306213379,
1.501858711242675... |
func initWorker(count int, c chan *Job, results chan Result, wg *sync.WaitGroup) {
// start workers based on flag
for i := 0; i < count; i++ {
wg.Add(1)
go worker(c, results, wg)
}
} | [
-0.1625172197818756,
0.5867742896080017,
0.43041181564331055,
0.5731163620948792,
0.3556062579154968,
0.02407410927116871,
0.451585054397583,
0.3797609210014343,
-1.2568228244781494,
-0.06453243643045425,
-1.1095771789550781,
-0.22356092929840088,
-0.762887716293335,
1.274802565574646,
-... |
func worker(c chan *Job, results chan Result, wg *sync.WaitGroup) {
for job := range c {
u, err := url.Parse(job.URL)
if u.Scheme == "" {
u.Scheme = "http"
}
job.URL = u.String()
t0 := time.Now()
result, err := process(job)
t1 := time.Now()
result.Duration = t1.Sub(t0)
if err != nil {
result.... | [
-1.0471384525299072,
0.21064572036266327,
0.5912178158760071,
-0.361977756023407,
-0.07833624631166458,
0.1366117000579834,
0.07643264532089233,
0.08663829416036606,
-1.0809245109558105,
0.07919415831565857,
-0.9992443919181824,
-0.5156261324882507,
-0.16020989418029785,
1.0423026084899902... |
func process(job *Job) (Result, error) {
var result Result
result.Host = job.URL
result.Matches = make([]Match, 0)
var err error
var cookies []*http.Cookie
var cookiesMap = make(map[string]string)
var body []byte
var headers http.Header
// get response from host if allowed
if job.forceNotDownload {
body =... | [
-0.21401582658290863,
0.34437480568885803,
1.0672283172607422,
-0.044384539127349854,
-0.24896953999996185,
-0.052769217640161514,
-0.06375864893198013,
0.12708139419555664,
-0.29924073815345764,
0.6646671891212463,
0.09350474178791046,
0.23820999264717102,
-0.27205729484558105,
0.51700943... |
func findMatches(content string, regexes []AppRegexp) ([][]string, string) {
var m [][]string
var version string
for _, r := range regexes {
matches := r.Regexp.FindAllStringSubmatch(content, -1)
if matches == nil {
continue
}
m = append(m, matches...)
if r.Version != "" {
version = findVersion(m,... | [
0.3144024610519409,
-1.2909175157546997,
0.4818057119846344,
0.3120378851890564,
-0.06033395230770111,
0.13677693903446198,
0.2623145580291748,
0.03775135427713394,
-0.9357627034187317,
0.9481062293052673,
0.08874224871397018,
-0.7729429006576538,
-1.1210124492645264,
0.5603227615356445,
... |
func findVersion(matches [][]string, version string) string {
/*
log.Printf("Matches: %v", matches)
log.Printf("Version: %v", version)
*/
var v string
for _, matchPair := range matches {
// replace backtraces (max: 3)
for i := 1; i <= 3; i++ {
bt := fmt.Sprintf("\\%v", i)
if strings.Contains(version... | [
0.9227024912834167,
-0.8210212588310242,
0.9264836311340332,
0.40863460302352905,
-0.3960895538330078,
-0.16814111173152924,
0.19198763370513916,
-0.3016781210899353,
-0.5735186338424683,
1.3268051147460938,
0.6133216619491577,
-0.803585946559906,
-1.5076358318328857,
-0.15670029819011688,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.