_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q31200 | Fail | train | func Fail(msg string) {
logger := blog.Get()
logger.AuditErr(msg)
fmt.Fprintf(os.Stderr, msg)
os.Exit(1)
} | go | {
"resource": ""
} |
q31201 | FailOnError | train | func FailOnError(err error, msg string) {
if err != nil {
msg := fmt.Sprintf("%s: %s", msg, err)
Fail(msg)
}
} | go | {
"resource": ""
} |
q31202 | LoadCert | train | func LoadCert(path string) (cert []byte, err error) {
if path == "" {
err = errors.New("Issuer certificate was not provided in config.")
return
}
pemBytes, err := ioutil.ReadFile(path)
if err != nil {
return
}
block, _ := pem.Decode(pemBytes)
if block == nil || block.Type != "CERTIFICATE" {
err = errors... | go | {
"resource": ""
} |
q31203 | ReadConfigFile | train | func ReadConfigFile(filename string, out interface{}) error {
configData, err := ioutil.ReadFile(filename)
if err != nil {
return err
}
return json.Unmarshal(configData, out)
} | go | {
"resource": ""
} |
q31204 | VersionString | train | func VersionString() string {
name := path.Base(os.Args[0])
return fmt.Sprintf("Versions: %s=(%s %s) Golang=(%s) BuildHost=(%s)", name, core.GetBuildID(), core.GetBuildTime(), runtime.Version(), core.GetBuildHost())
} | go | {
"resource": ""
} |
q31205 | CatchSignals | train | func CatchSignals(logger blog.Logger, callback func()) {
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGTERM)
signal.Notify(sigChan, syscall.SIGINT)
signal.Notify(sigChan, syscall.SIGHUP)
sig := <-sigChan
if logger != nil {
logger.Infof("Caught %s", signalToName[sig])
}
if callback != ... | go | {
"resource": ""
} |
q31206 | saveCheckpoint | train | func saveCheckpoint(checkpointFile, id string) error {
tmpDir, err := ioutil.TempDir("", "checkpoint-tmp")
if err != nil {
return err
}
defer func() { _ = os.RemoveAll(tmpDir) }()
tmp, err := ioutil.TempFile(tmpDir, "checkpoint-atomic")
if err != nil {
return err
}
if _, err = tmp.Write([]byte(id)); err != ... | go | {
"resource": ""
} |
q31207 | getWork | train | func (p *expiredAuthzPurger) getWork(work chan string, query string, initialID string, purgeBefore time.Time, batchSize int64) (string, int, error) {
var idBatch []string
_, err := p.db.Select(
&idBatch,
query,
map[string]interface{}{
"id": initialID,
"expires": purgeBefore,
"limit": batchSize,
... | go | {
"resource": ""
} |
q31208 | deleteAuthorizations | train | func (p *expiredAuthzPurger) deleteAuthorizations(work chan string, maxDPS int, parallelism int, table string, checkpointFile string) {
wg := new(sync.WaitGroup)
deleted := int64(0)
var ticker *time.Ticker
if maxDPS > 0 {
ticker = time.NewTicker(time.Duration(float64(time.Second) / float64(maxDPS)))
}
for i := ... | go | {
"resource": ""
} |
q31209 | Write | train | func (r *responseWriterWithStatus) Write(body []byte) (int, error) {
if r.code == 0 {
r.code = http.StatusOK
}
return r.ResponseWriter.Write(body)
} | go | {
"resource": ""
} |
q31210 | Is | train | func Is(err error) bool {
return err == context.Canceled || grpc.Code(err) == codes.Canceled
} | go | {
"resource": ""
} |
q31211 | NewRegistrationAuthorityImpl | train | func NewRegistrationAuthorityImpl(
clk clock.Clock,
logger blog.Logger,
stats metrics.Scope,
maxContactsPerReg int,
keyPolicy goodkey.KeyPolicy,
maxNames int,
forceCNFromSAN bool,
reuseValidAuthz bool,
authorizationLifetime time.Duration,
pendingAuthorizationLifetime time.Duration,
pubc core.Publisher,
caaC... | go | {
"resource": ""
} |
q31212 | checkRegistrationIPLimit | train | func (ra *RegistrationAuthorityImpl) checkRegistrationIPLimit(
ctx context.Context,
limit ratelimit.RateLimitPolicy,
ip net.IP,
counter registrationCounter) error {
if !limit.Enabled() {
return nil
}
now := ra.clk.Now()
windowBegin := limit.WindowBegin(now)
count, err := counter(ctx, ip, windowBegin, now)
... | go | {
"resource": ""
} |
q31213 | checkRegistrationLimits | train | func (ra *RegistrationAuthorityImpl) checkRegistrationLimits(ctx context.Context, ip net.IP) error {
// Check the registrations per IP limit using the CountRegistrationsByIP SA
// function that matches IP addresses exactly
exactRegLimit := ra.rlPolicies.RegistrationsPerIP()
err := ra.checkRegistrationIPLimit(ctx, e... | go | {
"resource": ""
} |
q31214 | NewRegistration | train | func (ra *RegistrationAuthorityImpl) NewRegistration(ctx context.Context, init core.Registration) (core.Registration, error) {
if err := ra.keyPolicy.GoodKey(init.Key.Key); err != nil {
return core.Registration{}, berrors.MalformedError("invalid public key: %s", err.Error())
}
if err := ra.checkRegistrationLimits(... | go | {
"resource": ""
} |
q31215 | validateEmail | train | func validateEmail(address string) error {
email, err := mail.ParseAddress(address)
if err != nil {
return unparseableEmailError
}
splitEmail := strings.SplitN(email.Address, "@", -1)
domain := strings.ToLower(splitEmail[len(splitEmail)-1])
if forbiddenMailDomains[domain] {
return berrors.InvalidEmailError(
... | go | {
"resource": ""
} |
q31216 | checkNewOrdersPerAccountLimit | train | func (ra *RegistrationAuthorityImpl) checkNewOrdersPerAccountLimit(ctx context.Context, acctID int64) error {
limit := ra.rlPolicies.NewOrdersPerAccount()
if !limit.Enabled() {
return nil
}
latest := ra.clk.Now()
earliest := latest.Add(-limit.Window.Duration)
count, err := ra.SA.CountOrders(ctx, acctID, earlies... | go | {
"resource": ""
} |
q31217 | checkOrderAuthorizations | train | func (ra *RegistrationAuthorityImpl) checkOrderAuthorizations(
ctx context.Context,
names []string,
acctID accountID,
orderID orderID) (map[string]*core.Authorization, error) {
acctIDInt := int64(acctID)
orderIDInt := int64(orderID)
// Get all of the valid authorizations for this account/order
authzs, err := ra... | go | {
"resource": ""
} |
q31218 | checkAuthorizations | train | func (ra *RegistrationAuthorityImpl) checkAuthorizations(ctx context.Context, names []string, regID int64) (map[string]*core.Authorization, error) {
now := ra.clk.Now()
for i := range names {
names[i] = strings.ToLower(names[i])
}
auths, err := ra.SA.GetValidAuthorizations(ctx, regID, names, now)
if err != nil {... | go | {
"resource": ""
} |
q31219 | checkAuthorizationsCAA | train | func (ra *RegistrationAuthorityImpl) checkAuthorizationsCAA(
ctx context.Context,
names []string,
authzs map[string]*core.Authorization,
regID int64,
now time.Time) error {
// badNames contains the names that were unauthorized
var badNames []string
// recheckAuthzs is a list of authorizations that must have the... | go | {
"resource": ""
} |
q31220 | recheckCAA | train | func (ra *RegistrationAuthorityImpl) recheckCAA(ctx context.Context, authzs []*core.Authorization) error {
ra.stats.Inc("recheck_caa", 1)
ra.stats.Inc("recheck_caa_authzs", int64(len(authzs)))
ch := make(chan error, len(authzs))
for _, authz := range authzs {
go func(authz *core.Authorization) {
name := authz.... | go | {
"resource": ""
} |
q31221 | failOrder | train | func (ra *RegistrationAuthorityImpl) failOrder(
ctx context.Context,
order *corepb.Order,
prob *probs.ProblemDetails) *corepb.Order {
// Convert the problem to a protobuf problem for the *corepb.Order field
pbProb, err := bgrpc.ProblemDetailsToPB(prob)
if err != nil {
ra.log.AuditErrf("Could not convert order ... | go | {
"resource": ""
} |
q31222 | FinalizeOrder | train | func (ra *RegistrationAuthorityImpl) FinalizeOrder(ctx context.Context, req *rapb.FinalizeOrderRequest) (*corepb.Order, error) {
order := req.Order
if *order.Status != string(core.StatusReady) {
return nil, berrors.OrderNotReadyError(
"Order's status (%q) is not acceptable for finalization",
*order.Status)
... | go | {
"resource": ""
} |
q31223 | NewCertificate | train | func (ra *RegistrationAuthorityImpl) NewCertificate(ctx context.Context, req core.CertificateRequest, regID int64) (core.Certificate, error) {
// Verify the CSR
if err := csrlib.VerifyCSR(req.CSR, ra.maxNames, &ra.keyPolicy, ra.PA, ra.forceCNFromSAN, regID); err != nil {
return core.Certificate{}, berrors.Malformed... | go | {
"resource": ""
} |
q31224 | issueCertificate | train | func (ra *RegistrationAuthorityImpl) issueCertificate(
ctx context.Context,
req core.CertificateRequest,
acctID accountID,
oID orderID) (core.Certificate, error) {
// Construct the log event
logEvent := certificateRequestEvent{
ID: core.NewToken(),
OrderID: int64(oID),
Requester: int64(acctID... | go | {
"resource": ""
} |
q31225 | domainsForRateLimiting | train | func domainsForRateLimiting(names []string) ([]string, error) {
var domains []string
for _, name := range names {
domain, err := publicsuffix.Domain(name)
if err != nil {
// The only possible errors are:
// (1) publicsuffix.Domain is giving garbage values
// (2) the public suffix is the domain itself
... | go | {
"resource": ""
} |
q31226 | suffixesForRateLimiting | train | func suffixesForRateLimiting(names []string) ([]string, error) {
var suffixMatches []string
for _, name := range names {
_, err := publicsuffix.Domain(name)
if err != nil {
// Like `domainsForRateLimiting`, the only possible errors here are:
// (1) publicsuffix.Domain is giving garbage values
// (2) the ... | go | {
"resource": ""
} |
q31227 | enforceNameCounts | train | func (ra *RegistrationAuthorityImpl) enforceNameCounts(
ctx context.Context,
names []string,
limit ratelimit.RateLimitPolicy,
regID int64,
countFunc certCountRPC) ([]string, error) {
now := ra.clk.Now()
windowBegin := limit.WindowBegin(now)
counts, err := countFunc(ctx, names, windowBegin, now)
if err != nil ... | go | {
"resource": ""
} |
q31228 | UpdateRegistration | train | func (ra *RegistrationAuthorityImpl) UpdateRegistration(ctx context.Context, base core.Registration, update core.Registration) (core.Registration, error) {
if changed := mergeUpdate(&base, update); !changed {
// If merging the update didn't actually change the base then our work is
// done, we can return before ca... | go | {
"resource": ""
} |
q31229 | mergeUpdate | train | func mergeUpdate(r *core.Registration, input core.Registration) bool {
var changed bool
// Note: we allow input.Contact to overwrite r.Contact even if the former is
// empty in order to allow users to remove the contact associated with
// a registration. Since the field type is a pointer to slice of pointers we
/... | go | {
"resource": ""
} |
q31230 | revokeCertificate | train | func (ra *RegistrationAuthorityImpl) revokeCertificate(ctx context.Context, cert x509.Certificate, code revocation.Reason) error {
now := time.Now()
signRequest := core.OCSPSigningRequest{
CertDER: cert.Raw,
Status: string(core.OCSPStatusRevoked),
Reason: code,
RevokedAt: now,
}
ocspResponse, err :=... | go | {
"resource": ""
} |
q31231 | RevokeCertificateWithReg | train | func (ra *RegistrationAuthorityImpl) RevokeCertificateWithReg(ctx context.Context, cert x509.Certificate, revocationCode revocation.Reason, regID int64) error {
serialString := core.SerialToString(cert.SerialNumber)
var err error
if features.Enabled(features.RevokeAtRA) {
err = ra.revokeCertificate(ctx, cert, revo... | go | {
"resource": ""
} |
q31232 | onValidationUpdate | train | func (ra *RegistrationAuthorityImpl) onValidationUpdate(ctx context.Context, authz core.Authorization) error {
// Consider validation successful if any of the challenges
// specified in the authorization has been fulfilled
for _, ch := range authz.Challenges {
if ch.Status == core.StatusValid {
authz.Status = c... | go | {
"resource": ""
} |
q31233 | DeactivateRegistration | train | func (ra *RegistrationAuthorityImpl) DeactivateRegistration(ctx context.Context, reg core.Registration) error {
if reg.Status != core.StatusValid {
return berrors.MalformedError("only valid registrations can be deactivated")
}
err := ra.SA.DeactivateRegistration(ctx, reg.ID)
if err != nil {
return berrors.Inter... | go | {
"resource": ""
} |
q31234 | DeactivateAuthorization | train | func (ra *RegistrationAuthorityImpl) DeactivateAuthorization(ctx context.Context, auth core.Authorization) error {
if auth.Status != core.StatusValid && auth.Status != core.StatusPending {
return berrors.MalformedError("only valid and pending authorizations can be deactivated")
}
err := ra.SA.DeactivateAuthorizati... | go | {
"resource": ""
} |
q31235 | createPendingAuthz | train | func (ra *RegistrationAuthorityImpl) createPendingAuthz(ctx context.Context, reg int64, identifier core.AcmeIdentifier, v2 bool) (*corepb.Authorization, error) {
expires := ra.clk.Now().Add(ra.pendingAuthorizationLifetime).Truncate(time.Second).UnixNano()
status := string(core.StatusPending)
authz := &corepb.Authori... | go | {
"resource": ""
} |
q31236 | authzValidChallengeEnabled | train | func (ra *RegistrationAuthorityImpl) authzValidChallengeEnabled(authz *core.Authorization) bool {
for _, chall := range authz.Challenges {
if chall.Status == core.StatusValid {
return ra.PA.ChallengeTypeEnabled(chall.Type)
}
}
return false
} | go | {
"resource": ""
} |
q31237 | wildcardOverlap | train | func wildcardOverlap(dnsNames []string) error {
nameMap := make(map[string]bool, len(dnsNames))
for _, v := range dnsNames {
nameMap[v] = true
}
for name := range nameMap {
if name[0] == '*' {
continue
}
labels := strings.Split(name, ".")
labels[0] = "*"
if nameMap[strings.Join(labels, ".")] {
ret... | go | {
"resource": ""
} |
q31238 | NewSourceFromDatabase | train | func NewSourceFromDatabase(
dbMap dbSelector,
caKeyHash []byte,
reqSerialPrefixes []string,
timeout time.Duration,
log blog.Logger,
) (src *DBSource, err error) {
src = &DBSource{
dbMap: dbMap,
caKeyHash: caKeyHash,
reqSerialPrefixes: reqSerialPrefixes,
timeout: timeout,
lo... | go | {
"resource": ""
} |
q31239 | Response | train | func (src *DBSource) Response(req *ocsp.Request) ([]byte, http.Header, error) {
// Check that this request is for the proper CA
if bytes.Compare(req.IssuerKeyHash, src.caKeyHash) != 0 {
src.log.Debugf("Request intended for CA Cert ID: %s", hex.EncodeToString(req.IssuerKeyHash))
return nil, nil, cfocsp.ErrNotFound... | go | {
"resource": ""
} |
q31240 | Timeout | train | func (d DNSError) Timeout() bool {
if netErr, ok := d.underlying.(*net.OpError); ok {
return netErr.Timeout()
} else if d.underlying == context.Canceled || d.underlying == context.DeadlineExceeded {
return true
}
return false
} | go | {
"resource": ""
} |
q31241 | Set | train | func Set(featureSet map[string]bool) error {
fMu.Lock()
defer fMu.Unlock()
for n, v := range featureSet {
f, present := nameToFeature[n]
if !present {
return fmt.Errorf("feature '%s' doesn't exist", n)
}
features[f] = v
}
return nil
} | go | {
"resource": ""
} |
q31242 | Enabled | train | func Enabled(n FeatureFlag) bool {
fMu.RLock()
defer fMu.RUnlock()
v, present := features[n]
if !present {
panic(fmt.Sprintf("feature '%s' doesn't exist", n.String()))
}
return v
} | go | {
"resource": ""
} |
q31243 | Reset | train | func Reset() {
fMu.Lock()
defer fMu.Unlock()
for k, v := range initial {
features[k] = v
}
} | go | {
"resource": ""
} |
q31244 | NewDbMap | train | func NewDbMap(dbConnect string, maxOpenConns int) (*gorp.DbMap, error) {
var err error
var config *mysql.Config
config, err = mysql.ParseDSN(dbConnect)
if err != nil {
return nil, err
}
return NewDbMapFromConfig(config, maxOpenConns)
} | go | {
"resource": ""
} |
q31245 | adjustMySQLConfig | train | func adjustMySQLConfig(conf *mysql.Config) *mysql.Config {
// Required to turn DATETIME fields into time.Time
conf.ParseTime = true
// Required to make UPDATE return the number of rows matched,
// instead of the number of rows changed by the UPDATE.
conf.ClientFoundRows = true
// Ensures that MySQL/MariaDB warn... | go | {
"resource": ""
} |
q31246 | SetSQLDebug | train | func SetSQLDebug(dbMap *gorp.DbMap, log blog.Logger) {
dbMap.TraceOn("SQL: ", &SQLLogger{log})
} | go | {
"resource": ""
} |
q31247 | Printf | train | func (log *SQLLogger) Printf(format string, v ...interface{}) {
log.Debugf(format, v...)
} | go | {
"resource": ""
} |
q31248 | LookupTXT | train | func (mock *MockDNSClient) LookupTXT(_ context.Context, hostname string) ([]string, []string, error) {
if hostname == "_acme-challenge.servfail.com" {
return nil, nil, fmt.Errorf("SERVFAIL")
}
if hostname == "_acme-challenge.good-dns01.com" {
// base64(sha256("LoqXcYV8q5ONbJQxbmR7SCTNo3tiAXDfowyjxAjEuX0"
// ... | go | {
"resource": ""
} |
q31249 | LookupCAA | train | func (mock *MockDNSClient) LookupCAA(_ context.Context, domain string) ([]*dns.CAA, error) {
return nil, nil
} | go | {
"resource": ""
} |
q31250 | ToDb | train | func (tc BoulderTypeConverter) ToDb(val interface{}) (interface{}, error) {
switch t := val.(type) {
case core.AcmeIdentifier, []core.Challenge, []string, [][]int:
jsonBytes, err := json.Marshal(t)
if err != nil {
return nil, err
}
return string(jsonBytes), nil
case jose.JSONWebKey:
jsonBytes, err := t.... | go | {
"resource": ""
} |
q31251 | NewPromScope | train | func NewPromScope(registerer prometheus.Registerer, scopes ...string) Scope {
return &promScope{
prefix: scopes,
autoRegisterer: newAutoRegisterer(registerer),
registerer: registerer,
}
} | go | {
"resource": ""
} |
q31252 | NewScope | train | func (s *promScope) NewScope(scopes ...string) Scope {
return &promScope{
prefix: append(s.prefix, scopes...),
autoRegisterer: s.autoRegisterer,
registerer: s.registerer,
}
} | go | {
"resource": ""
} |
q31253 | Inc | train | func (s *promScope) Inc(stat string, value int64) {
s.autoCounter(s.statName(stat)).Add(float64(value))
} | go | {
"resource": ""
} |
q31254 | GaugeDelta | train | func (s *promScope) GaugeDelta(stat string, value int64) {
s.autoGauge(s.statName(stat)).Add(float64(value))
} | go | {
"resource": ""
} |
q31255 | Timing | train | func (s *promScope) Timing(stat string, delta int64) {
s.autoSummary(s.statName(stat) + "_seconds").Observe(float64(delta))
} | go | {
"resource": ""
} |
q31256 | TimingDuration | train | func (s *promScope) TimingDuration(stat string, delta time.Duration) {
s.autoSummary(s.statName(stat) + "_seconds").Observe(delta.Seconds())
} | go | {
"resource": ""
} |
q31257 | SetInt | train | func (s *promScope) SetInt(stat string, value int64) {
s.autoGauge(s.statName(stat)).Set(float64(value))
} | go | {
"resource": ""
} |
q31258 | statName | train | func (s *promScope) statName(stat string) string {
if len(s.prefix) > 0 {
return strings.Join(s.prefix, "_") + "_" + stat
}
return stat
} | go | {
"resource": ""
} |
q31259 | NewCachePurgeClient | train | func NewCachePurgeClient(
endpoint,
clientToken,
clientSecret,
accessToken string,
v3Network string,
retries int,
retryBackoff time.Duration,
log blog.Logger,
stats metrics.Scope,
) (*CachePurgeClient, error) {
stats = stats.NewScope("CCU")
if strings.HasSuffix(endpoint, "/") {
endpoint = endpoint[:len(end... | go | {
"resource": ""
} |
q31260 | signingKey | train | func signingKey(clientSecret string, timestamp string) []byte {
h := hmac.New(sha256.New, []byte(clientSecret))
h.Write([]byte(timestamp))
key := make([]byte, base64.StdEncoding.EncodedLen(32))
base64.StdEncoding.Encode(key, h.Sum(nil))
return key
} | go | {
"resource": ""
} |
q31261 | purge | train | func (cpc *CachePurgeClient) purge(urls []string) error {
purgeReq := v3PurgeRequest{
Objects: urls,
}
endpoint := fmt.Sprintf("%s%s%s", cpc.apiEndpoint, v3PurgePath, cpc.v3Network)
reqJSON, err := json.Marshal(purgeReq)
if err != nil {
return errFatal(err.Error())
}
req, err := http.NewRequest(
"POST",
... | go | {
"resource": ""
} |
q31262 | Purge | train | func (cpc *CachePurgeClient) Purge(urls []string) error {
for i := 0; i < len(urls); {
sliceEnd := i + akamaiBatchSize
if sliceEnd > len(urls) {
sliceEnd = len(urls)
}
err := cpc.purgeBatch(urls[i:sliceEnd])
if err != nil {
return err
}
i += akamaiBatchSize
}
return nil
} | go | {
"resource": ""
} |
q31263 | CheckSignature | train | func CheckSignature(secret string, url string, r *http.Request, body []byte) error {
bodyHash := sha256.Sum256(body)
bodyHashB64 := base64.StdEncoding.EncodeToString(bodyHash[:])
authorization := r.Header.Get("Authorization")
authValues := make(map[string]string)
for _, v := range strings.Split(authorization, ";"... | go | {
"resource": ""
} |
q31264 | findIDs | train | func (c idExporter) findIDs() ([]id, error) {
var idsList []id
_, err := c.dbMap.Select(
&idsList,
`SELECT id
FROM registrations
WHERE contact != 'null' AND
id IN (
SELECT registrationID
FROM certificates
WHERE expires >= :expireCutoff
);`,
map[string]interface{}{
"expireCutoff": c.clk.... | go | {
"resource": ""
} |
q31265 | writeIDs | train | func writeIDs(idsList []id, outfile string) error {
data, err := json.Marshal(idsList)
if err != nil {
return err
}
data = append(data, '\n')
if outfile != "" {
return ioutil.WriteFile(outfile, data, 0644)
}
fmt.Printf("%s", data)
return nil
} | go | {
"resource": ""
} |
q31266 | ClientHandshake | train | func (tc *clientTransportCredentials) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
var err error
host := tc.hostOverride
if host == "" {
// IMPORTANT: Don't wrap the errors returned from this method. gRPC expects to be
// able to check err.Temporar... | go | {
"resource": ""
} |
q31267 | ServerHandshake | train | func (tc *clientTransportCredentials) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
return nil, nil, ServerHandshakeNopErr
} | go | {
"resource": ""
} |
q31268 | Clone | train | func (tc *clientTransportCredentials) Clone() credentials.TransportCredentials {
return NewClientCredentials(tc.roots, tc.clients, tc.hostOverride)
} | go | {
"resource": ""
} |
q31269 | ServerHandshake | train | func (tc *serverTransportCredentials) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
// Perform the server <- client TLS handshake. This will validate the peer's
// client certificate.
conn := tls.Server(rawConn, tc.serverConfig)
if err := conn.Handshake(); err != nil {
return nil, ni... | go | {
"resource": ""
} |
q31270 | ClientHandshake | train | func (tc *serverTransportCredentials) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
return nil, nil, ClientHandshakeNopErr
} | go | {
"resource": ""
} |
q31271 | GetRequestMetadata | train | func (tc *serverTransportCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {
return nil, nil
} | go | {
"resource": ""
} |
q31272 | Clone | train | func (tc *serverTransportCredentials) Clone() credentials.TransportCredentials {
clone, _ := NewServerCredentials(tc.serverConfig, tc.acceptedSANs)
return clone
} | go | {
"resource": ""
} |
q31273 | ValidChallenge | train | func ValidChallenge(name string) bool {
switch name {
case ChallengeTypeHTTP01,
ChallengeTypeDNS01,
ChallengeTypeTLSALPN01:
return true
default:
return false
}
} | go | {
"resource": ""
} |
q31274 | UnmarshalJSON | train | func (cr *CertificateRequest) UnmarshalJSON(data []byte) error {
var raw RawCertificateRequest
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
csr, err := x509.ParseCertificateRequest(raw.CSR)
if err != nil {
return err
}
cr.CSR = csr
cr.Bytes = raw.CSR
return nil
} | go | {
"resource": ""
} |
q31275 | MarshalJSON | train | func (cr CertificateRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(RawCertificateRequest{
CSR: cr.CSR.Raw,
})
} | go | {
"resource": ""
} |
q31276 | ExpectedKeyAuthorization | train | func (ch Challenge) ExpectedKeyAuthorization(key *jose.JSONWebKey) (string, error) {
if key == nil {
return "", fmt.Errorf("Cannot authorize a nil key")
}
thumbprint, err := key.Thumbprint(crypto.SHA256)
if err != nil {
return "", err
}
return ch.Token + "." + base64.RawURLEncoding.EncodeToString(thumbprint... | go | {
"resource": ""
} |
q31277 | RecordsSane | train | func (ch Challenge) RecordsSane() bool {
if ch.ValidationRecord == nil || len(ch.ValidationRecord) == 0 {
return false
}
switch ch.Type {
case ChallengeTypeHTTP01:
for _, rec := range ch.ValidationRecord {
if rec.URL == "" || rec.Hostname == "" || rec.Port == "" || rec.AddressUsed == nil ||
len(rec.Addr... | go | {
"resource": ""
} |
q31278 | CheckConsistencyForClientOffer | train | func (ch Challenge) CheckConsistencyForClientOffer() error {
if err := ch.checkConsistency(); err != nil {
return err
}
// Before completion, the key authorization field should be empty
if ch.ProvidedKeyAuthorization != "" {
return fmt.Errorf("A response to this challenge was already submitted.")
}
return ni... | go | {
"resource": ""
} |
q31279 | CheckConsistencyForValidation | train | func (ch Challenge) CheckConsistencyForValidation() error {
if err := ch.checkConsistency(); err != nil {
return err
}
// If the challenge is completed, then there should be a key authorization
return looksLikeKeyAuthorization(ch.ProvidedKeyAuthorization)
} | go | {
"resource": ""
} |
q31280 | checkConsistency | train | func (ch Challenge) checkConsistency() error {
if ch.Status != StatusPending {
return fmt.Errorf("The challenge is not pending.")
}
// There always needs to be a token
if !LooksLikeAToken(ch.Token) {
return fmt.Errorf("The token is missing.")
}
return nil
} | go | {
"resource": ""
} |
q31281 | StringID | train | func (ch Challenge) StringID() string {
h := fnv.New128a()
h.Write([]byte(ch.Token))
h.Write([]byte(ch.Type))
return base64.URLEncoding.EncodeToString(h.Sum(nil)[0:4])
} | go | {
"resource": ""
} |
q31282 | FindChallenge | train | func (authz *Authorization) FindChallenge(challengeID int64) int {
for i, c := range authz.Challenges {
if c.ID == challengeID {
return i
}
}
return -1
} | go | {
"resource": ""
} |
q31283 | FindChallengeByStringID | train | func (authz *Authorization) FindChallengeByStringID(id string) int {
for i, c := range authz.Challenges {
if c.StringID() == id {
return i
}
}
return -1
} | go | {
"resource": ""
} |
q31284 | base64URLEncode | train | func base64URLEncode(data []byte) string {
var result = base64.URLEncoding.EncodeToString(data)
return strings.TrimRight(result, "=")
} | go | {
"resource": ""
} |
q31285 | base64URLDecode | train | func base64URLDecode(data string) ([]byte, error) {
var missing = (4 - len(data)%4) % 4
data += strings.Repeat("=", missing)
return base64.URLEncoding.DecodeString(data)
} | go | {
"resource": ""
} |
q31286 | MarshalJSON | train | func (jb JSONBuffer) MarshalJSON() (result []byte, err error) {
return json.Marshal(base64URLEncode(jb))
} | go | {
"resource": ""
} |
q31287 | UnmarshalJSON | train | func (jb *JSONBuffer) UnmarshalJSON(data []byte) (err error) {
var str string
err = json.Unmarshal(data, &str)
if err != nil {
return err
}
*jb, err = base64URLDecode(str)
return
} | go | {
"resource": ""
} |
q31288 | RelativeEndpoint | train | func RelativeEndpoint(request *http.Request, endpoint string) string {
var result string
proto := "http"
host := request.Host
// If the request was received via TLS, use `https://` for the protocol
if request.TLS != nil {
proto = "https"
}
// Allow upstream proxies to specify the forwarded protocol. Allow t... | go | {
"resource": ""
} |
q31289 | NewMessage | train | func NewMessage(chatID int64, text string) MessageConfig {
return MessageConfig{
BaseChat: BaseChat{
ChatID: chatID,
ReplyToMessageID: 0,
},
Text: text,
DisableWebPagePreview: false,
}
} | go | {
"resource": ""
} |
q31290 | NewDeleteMessage | train | func NewDeleteMessage(chatID int64, messageID int) DeleteMessageConfig {
return DeleteMessageConfig{
ChatID: chatID,
MessageID: messageID,
}
} | go | {
"resource": ""
} |
q31291 | NewMessageToChannel | train | func NewMessageToChannel(username string, text string) MessageConfig {
return MessageConfig{
BaseChat: BaseChat{
ChannelUsername: username,
},
Text: text,
}
} | go | {
"resource": ""
} |
q31292 | NewForward | train | func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig {
return ForwardConfig{
BaseChat: BaseChat{ChatID: chatID},
FromChatID: fromChatID,
MessageID: messageID,
}
} | go | {
"resource": ""
} |
q31293 | NewPhotoUpload | train | func NewPhotoUpload(chatID int64, file interface{}) PhotoConfig {
return PhotoConfig{
BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID},
File: file,
UseExisting: false,
},
}
} | go | {
"resource": ""
} |
q31294 | NewPhotoShare | train | func NewPhotoShare(chatID int64, fileID string) PhotoConfig {
return PhotoConfig{
BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID},
FileID: fileID,
UseExisting: true,
},
}
} | go | {
"resource": ""
} |
q31295 | NewAudioUpload | train | func NewAudioUpload(chatID int64, file interface{}) AudioConfig {
return AudioConfig{
BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID},
File: file,
UseExisting: false,
},
}
} | go | {
"resource": ""
} |
q31296 | NewAudioShare | train | func NewAudioShare(chatID int64, fileID string) AudioConfig {
return AudioConfig{
BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID},
FileID: fileID,
UseExisting: true,
},
}
} | go | {
"resource": ""
} |
q31297 | NewDocumentUpload | train | func NewDocumentUpload(chatID int64, file interface{}) DocumentConfig {
return DocumentConfig{
BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID},
File: file,
UseExisting: false,
},
}
} | go | {
"resource": ""
} |
q31298 | NewDocumentShare | train | func NewDocumentShare(chatID int64, fileID string) DocumentConfig {
return DocumentConfig{
BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID},
FileID: fileID,
UseExisting: true,
},
}
} | go | {
"resource": ""
} |
q31299 | NewStickerUpload | train | func NewStickerUpload(chatID int64, file interface{}) StickerConfig {
return StickerConfig{
BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID},
File: file,
UseExisting: false,
},
}
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.