id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c11100
bothered with an error if it came from the backend as // a response to our query. gotResponse, err := l.cn.Unlisten(channel) if gotResponse && err != nil { return err } } // Don't bother waiting for resync if there's no connection. delete(l.channels, channel) return nil }
c11101
// should only be bothered with an error if it came from the backend as // a response to our query. gotResponse, err := l.cn.UnlistenAll() if gotResponse && err != nil { return err } } // Don't bother waiting for resync if there's no connection. l.channels = make(map[string]struct{}) return nil }
c11102
return errListenerClosed } if l.cn == nil { return errors.New("no connection") } return l.cn.Ping() }
c11103
// Ignore notifications while synchronization is going on to avoid // deadlocks. We have to send a nil notification over Notify anyway as // we can't possibly know which notifications (if any) were lost while // the connection was down, so there's no reason to try and process // these messages at all. for { s...
c11104
l.lock.Unlock() return l.isClosed }
c11105
if l.cn != nil { l.cn.Close() } l.isClosed = true return nil }
c11106
bool: return strconv.AppendBool(buf, v) case time.Time: return append(buf, formatTs(v)...) case nil: return append(buf, "\\N"...) default: errorf("encode: unknown type for %T", v) } panic("not reached") }
c11107
{ location = time.FixedZone("", offset) c.cache[offset] = location } return location }
c11108
< infinity) if !t.Before(infinityTsPositive) { return []byte("infinity") } } return FormatTimestamp(t) }
c11109
if offset != 0 { // RFC3339Nano already printed the minus sign if offset < 0 { offset = -offset } b = append(b, ':') if offset < 10 { b = append(b, '0') } b = strconv.AppendInt(b, int64(offset), 10) } if bc { b = append(b, " BC"...) } return b }
c11110
err != nil { return nil, fmt.Errorf("could not parse bytea value: %s", err.Error()) } result = append(result, byte(r)) s = s[4:] } else { // We hit an unescaped, raw byte. Try to read in as many as // possible in one go. i := bytes.IndexByte(s, '\\') if i == -1 { result = appe...
c11111
*SimpleBindRequest { return &SimpleBindRequest{ Username: username, Password: password, Controls: controls, } }
c11112
:= <-msgCtx.responses if !ok { return nil, NewError(ErrorNetwork, errors.New("ldap: response channel closed")) } packet, err = packetResponse.ReadPacket() l.Debug.Printf("%d: got response %p", msgCtx.id, packet) if err != nil { return nil, err } if l.Debug { if err := addLDAPDescriptions(packet); err != ...
c11113
return err } defer l.finishMessage(msgCtx) packetResponse, ok := <-msgCtx.responses if !ok { return NewError(ErrorNetwork, errors.New("ldap: response channel closed")) } packet, err = packetResponse.ReadPacket() l.Debug.Printf("%d: got response %p", msgCtx.id, packet) if err != nil { return err } if l....
c11114
&Error{ResultCode: resultCode, Err: err} }
c11115
} serverError, ok := err.(*Error) if !ok { return false } return serverError.ResultCode == desiredResultCode }
c11116
} packet, pos, err := compileFilter(filter, 1) if err != nil { return nil, err } if pos != len(filter) { return nil, NewError(ErrorFilterCompile, errors.New("ldap: finished compiling filter with extra at end: "+fmt.Sprint(filter[pos:]))) } return packet, nil }
c11117
// \ (%x5C) is not a valid character unless it is followed by two HEX characters due to not // being a member of UTF1SUBSET. if i+2 > len(escapedString) { return "", NewError(ErrorFilterCompile, errors.New("ldap: missing characters for escape in filter")) } escByte, decodeErr := hexpac.DecodeString(...
c11118
DN: DN, Controls: Controls, } }
c11119
msgCtx.id, packet) if err != nil { return err } if l.Debug { if err := addLDAPDescriptions(packet); err != nil { return err } ber.PrintPacket(packet) } if packet.Children[1].Tag == ApplicationDelResponse { resultCode, resultDescription := getLDAPResultCode(packet) if resultCode != 0 { return N...
c11120
:= key.Mode() if kmode != kmode&0600 { panic(ErrSSLKeyHasWorldPermissions) } }
c11121
if i < len(arr)-1 { hexed.WriteString(":") } } return hexed.String() }
c11122
case *ecdsa.PublicKey: return "ECDSA", publicKey.(*ecdsa.PublicKey).Curve.Params().BitSize case *rsa.PublicKey: return "RSA", publicKey.(*rsa.PublicKey).N.BitLen() default: return "", 0 } }
c11123
warnings = append(warnings, fmt.Sprintf("Certificate is not in X509v3 format (version is %d)", cert.Version+1)) } if len(cert.DNSNames) == 0 && len(cert.IPAddresses) == 0 && len(uriNames) == 0 && !cert.IsCA { warnings = append(warnings, fmt.Sprintf("Certificate doesn't have any valid DNS/URI names or IP address...
c11124
algorithm", algString(alg))) } } if alg == "RSA" { key := cert.PublicKey.(*rsa.PublicKey) if key.E < 3 { warnings = append(warnings, "Public key exponent in RSA key is less than 3") } if key.N.Sign() != 1 { warnings = append(warnings, "Public key modulus in RSA key appears to be zero/negative") } ...
c11125
verification since Go 1.3. tlsConf.InsecureSkipVerify = true verifyCaOnly = true case "verify-full": tlsConf.ServerName = o.Get("host") case "disable": return nil default: errorf(`unsupported sslmode %q; only "require" (default), "verify-full", "verify-ca", and "disable" supported`, mode) } sslClientCe...
c11126
cinfo, err = os.Stat(sslcert) if err != nil { panic(err) } kinfo, err = os.Stat(sslkey) if err != nil { panic(err) } } else { // Automatically find certificates from ~/.postgresql sslcert, sslkey, cinfo, kinfo = sslHomeCertificates() if cinfo == nil || kinfo == nil { // No certificates to l...
c11127
} ok := tlsConf.RootCAs.AppendCertsFromPEM(cert) if !ok { errorf("couldn't parse pem in sslrootcert") } } }
c11128
cert = filepath.Join(user.HomeDir, ".postgresql", "postgresql.crt") key = filepath.Join(user.HomeDir, ".postgresql", "postgresql.key") cinfo, err = os.Stat(cert) if err != nil { cinfo = nil } kinfo, err = os.Stat(key) if err != nil { kinfo = nil } return }
c11129
DNSName: client.ConnectionState().ServerName, Intermediates: x509.NewCertPool(), Roots: tlsConf.RootCAs, } for i, cert := range certs { if i == 0 { continue } opts.Intermediates.AddCert(cert) } _, err = certs[0].Verify(opts) if err != nil { panic(err) } }
c11130
addDefaultLDAPResponseDescriptions(packet) case ApplicationModifyRequest: addRequestDescriptions(packet) case ApplicationModifyResponse: case ApplicationAddRequest: addRequestDescriptions(packet) case ApplicationAddResponse: case ApplicationDelRequest: addRequestDescriptions(packet) case ApplicationDelRe...
c11131
:= ber.DecodePacket(file) addLDAPDescriptions(packet) ber.PrintPacket(packet) return nil }
c11132
return nil, err } buf := make([]byte, length) _, err = io.ReadFull(r, buf) if err != nil { return nil, err } return buf, nil }
c11133
len(password); i++ { buf[i*2+1] = password[i] } md.Write(buf) // Yes, "Mighty Aphrodite" is a constant used by this method. md.Write([]byte("Mighty Aphrodite")) return md }
c11134
return err } case 3: // Secret-key entry return fmt.Errorf("unimplemented: Secret-key") default: return fmt.Errorf("unimplemented tag: %d", tag) } } if md != nil { computed := md.Sum([]byte{}) actual := make([]byte, len(computed)) _, err := io.ReadFull(r, actual) if err != nil { retu...
c11135
if len(t.certs) < 1 { return nil, nil, fmt.Errorf("key has no certificates") } key, err = t.Recover(password) if err == nil { certs = t.certs return } } return }
c11136
if entry == nil { return nil, nil } switch t := entry.(type) { case *trustedCertEntry: return t.cert, nil } return nil, nil }
c11137
ok := v.(*privateKeyEntry); ok { r = append(r, k) } } return r }
c11138
:= v.(*trustedCertEntry); ok { r = append(r, k) } } return r }
c11139
os.Open(filename) if err != nil { return nil, err } defer file.Close() return LoadFromReader(file, password) }
c11140
ks.Parse(reader, password) if err != nil { return nil, err } return ks, err }
c11141
ctx.Done() != nil { closed = watchCancel(ctx, cn.cancel) } r, err := cn.query(query, list) if err != nil { return nil, err } r.closed = closed return r, nil }
c11142
if ctx.Done() != nil { closed := watchCancel(ctx, cn.cancel) defer close(closed) } return cn.Exec(query, list) }
c11143
err := cn.Begin() if err != nil { return nil, err } if ctx.Done() != nil { cn.txnClosed = watchCancel(ctx, cn.cancel) } return tx, nil }
c11144
debug { log.Printf(format, args...) } }
c11145
tlsInfoContext.CRI = criDesc.(*CertificateRequestInfo) } } funcMap := sprig.TxtFuncMap() extras := template.FuncMap{ "printCommonName": PrintCommonName, "printShortName": PrintShortName, "greenify": greenify, } for k, v := range extras { funcMap[k] = v } t := template.New("TLS template")....
c11146
lookup(cipherSuites, t.CipherSuite) return &TLSDescription{ version.Slug, cipher.Slug, } }
c11147
range cri.SignatureSchemes { desc, ok := signatureSchemeStrings[scheme] if !ok { desc = fmt.Sprintf("Unknown(0x%x)", scheme) } out.SignatureSchemes = append(out.SignatureSchemes, desc) } return out, nil }
c11148
if !ok { unknown := fmt.Sprintf("UNKNOWN_%x", what) return description{unknown, unknown, 0} } return v }
c11149
"_WITH_") d.Name = fmt.Sprintf("%s key exchange, %s cipher", kexAndCipher[0][len("TLS_"):], kexAndCipher[1]) return d }
c11150
c.GetControlType() == controlType { return c } } return nil }
c11151
{ return &ControlString{ ControlType: controlType, Criticality: criticality, ControlValue: controlValue, } }
c11152
cert, _ := keyStore.GetCert(alias) callback(EncodeX509ToPEM(cert, mergeHeaders(headers, map[string]string{nameHeader: alias}))) } for _, alias := range keyStore.ListPrivateKeys() { key, certs, err := keyStore.GetPrivateKeyAndCerts(alias, []byte(password(alias))) if err != nil { return fmt.Errorf("unab...
c11153
"CERTIFICATE", Bytes: cert.Raw, Headers: headers, } }
c11154
"PKCS7", Bytes: block.Raw, Headers: headers, } }
c11155
!= nil { return nil, fmt.Errorf("error marshaling key: %s\n", reflect.TypeOf(key)) } return &pem.Block{ Type: "EC PRIVATE KEY", Bytes: raw, Headers: headers, }, nil } return nil, fmt.Errorf("unknown key type: %s\n", reflect.TypeOf(key)) }
c11156
size := len(data) - len(rest) return size, data[:size], nil } return 0, nil, nil }) return scanner }
c11157
alter further computations. x := mat[0][0]*v[0] + mat[1][0]*v[1] v[1] = mat[0][1]*v[0] + mat[1][1]*v[1] v[0] = x }
c11158
mat[1][0] = temp return mat }
c11159
vec[0] *= f vec[1] *= f vec[2] *= f return vec }
c11160
vec[2] = -vec[2] return vec }
c11161
vec3.T{vec[0], vec[1], vec[2]} }
c11162
= v[0] vec[1] = v[1] vec[2] = v[2] vec[3] = 1 return vec }
c11163
a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3] }
c11164
} else if v < -1. { v = v + 2 } return math.Acos(v) }
c11165
} else if vec[i] > max[i] { vec[i] = max[i] } } return vec }
c11166
result.Clamp(min, max) return result }
c11167
rect.Min[0] && p[0] <= rect.Max[0] && p[1] >= rect.Min[1] && p[1] <= rect.Max[1] }
c11168
vec[1] * f, vec[2] * f, vec[3]} }
c11169
a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3] }
c11170
return vec.Sub(point).Rotate(angle).Add(point) }
c11171
b.Rotated(-a.Angle()) return ab.Angle() > 0 }
c11172
ab := b.Rotated(-a.Angle()) return ab.Angle() < 0 }
c11173
ool := 1 / math.Sqrt(norm) quat[0] *= ool quat[1] *= ool quat[2] *= ool quat[3] *= ool } return quat }
c11174
quat[2] * ool, quat[3] * ool, } } else { return *quat } }
c11175
quat[2] = -quat[2] quat[3] = -quat[3] return quat }
c11176
quat[2] = -quat[2] return quat }
c11177
&qv, &inv) v[0] = q[0] v[1] = q[1] v[2] = q[2] }
c11178
a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3] }
c11179
+ a[0]*b[1] - a[1]*b[0], a[3]*b[3] - a[0]*b[0] - a[1]*b[1] - a[2]*b[2], } return q.Normalized() }
c11180
b) return Mul(&q, c) }
c11181
= Mul(&q, c) return Mul(&q, d) }
c11182
b))) oosr := 1 / sr q := T{cr[0] * oosr, cr[1] * oosr, cr[2] * oosr, sr * 0.5} return q.Normalized() }
c11183
rect.Max = Max(a, b) return rect }
c11184
(rect.Max[0] - rect.Min[0]) * (rect.Max[1] - rect.Min[1]) }
c11185
rect.Max = Max(&a.Max, &b.Max) return rect }
c11186
sin, axis[2] * sin, math.Cos(angle)} return q.Normalized() }
c11187
qx := FromXAxisAngle(xPitch) qz := FromZAxisAngle(zRoll) return Mul3(&qy, &qx, &qz) }
c11188
{ ooSin = 1 / sin } axis[0] = quat[0] * ooSin axis[1] = quat[1] * ooSin axis[2] = quat[2] * ooSin return axis, angle }
c11189
s[0] mat[1][1] *= s[1] return mat }
c11190
*T { mat[2][0] = v[0] mat[2][1] = v[1] return mat }
c11191
v[0] mat[2][1] += v[1] return mat }
c11192
mat[1][1]*v[1] + mat[2][1]*v[2] v[2] = mat[0][2]*v[0] + mat[1][2]*v[1] + mat[2][2]*v[2] v[0] = x v[1] = y }
c11193
- mat[0][2]) * s, (mat[0][1] - mat[1][0]) * s, w, } return q.Normalized() }
c11194
wz mat[2][0] = xz + wy mat[0][1] = xy + wz mat[1][1] = 1 - (xx + zz) mat[2][1] = yz - wx mat[0][2] = xz - wy mat[1][2] = yz + wx mat[2][2] = 1 - (xx + yy) return mat }
c11195
mat[2][0] = x[2] mat[0][1] = y[0] mat[1][1] = y[1] mat[2][1] = y[2] mat[0][2] = z[0] mat[1][2] = z[1] mat[2][2] = z[2] return mat }
c11196
*T { vec[0] *= f vec[1] *= f return vec }
c11197
:= math.Cos(angle) return T{ vec[0]*cosinus - vec[1]*sinus, vec[0]*sinus + vec[1]*cosinus, } }
c11198
sinR*sinP*cosH mat[0][1] = sinR*cosH + cosR*sinP*sinH mat[1][1] = cosR * cosP mat[2][1] = sinR*sinH - cosR*sinP*cosH mat[0][2] = -cosP * sinH mat[1][2] = sinP mat[2][2] = cosP * cosH return mat }
c11199
mat[0][0]) } else { yHead = math.Atan2(-mat[0][2], mat[2][2]) zRoll = math.Atan2(-mat[1][0], mat[1][1]) } return yHead, xPitch, zRoll }