id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
27,100 | jlaffaye/ftp | ftp.go | DialWithDisabledEPSV | func DialWithDisabledEPSV(disabled bool) DialOption {
return DialOption{func(do *dialOptions) {
do.disableEPSV = disabled
}}
} | go | func DialWithDisabledEPSV(disabled bool) DialOption {
return DialOption{func(do *dialOptions) {
do.disableEPSV = disabled
}}
} | [
"func",
"DialWithDisabledEPSV",
"(",
"disabled",
"bool",
")",
"DialOption",
"{",
"return",
"DialOption",
"{",
"func",
"(",
"do",
"*",
"dialOptions",
")",
"{",
"do",
".",
"disableEPSV",
"=",
"disabled",
"\n",
"}",
"}",
"\n",
"}"
] | // DialWithDisabledEPSV returns a DialOption that configures the ServerConn with EPSV disabled
// Note that EPSV is only used when advertised in the server features. | [
"DialWithDisabledEPSV",
"returns",
"a",
"DialOption",
"that",
"configures",
"the",
"ServerConn",
"with",
"EPSV",
"disabled",
"Note",
"that",
"EPSV",
"is",
"only",
"used",
"when",
"advertised",
"in",
"the",
"server",
"features",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L165-L169 |
27,101 | jlaffaye/ftp | ftp.go | DialWithLocation | func DialWithLocation(location *time.Location) DialOption {
return DialOption{func(do *dialOptions) {
do.location = location
}}
} | go | func DialWithLocation(location *time.Location) DialOption {
return DialOption{func(do *dialOptions) {
do.location = location
}}
} | [
"func",
"DialWithLocation",
"(",
"location",
"*",
"time",
".",
"Location",
")",
"DialOption",
"{",
"return",
"DialOption",
"{",
"func",
"(",
"do",
"*",
"dialOptions",
")",
"{",
"do",
".",
"location",
"=",
"location",
"\n",
"}",
"}",
"\n",
"}"
] | // DialWithLocation returns a DialOption that configures the ServerConn with specified time.Location
// The lococation is used to parse the dates sent by the server which are in server's timezone | [
"DialWithLocation",
"returns",
"a",
"DialOption",
"that",
"configures",
"the",
"ServerConn",
"with",
"specified",
"time",
".",
"Location",
"The",
"lococation",
"is",
"used",
"to",
"parse",
"the",
"dates",
"sent",
"by",
"the",
"server",
"which",
"are",
"in",
"s... | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L173-L177 |
27,102 | jlaffaye/ftp | ftp.go | DialWithContext | func DialWithContext(ctx context.Context) DialOption {
return DialOption{func(do *dialOptions) {
do.context = ctx
}}
} | go | func DialWithContext(ctx context.Context) DialOption {
return DialOption{func(do *dialOptions) {
do.context = ctx
}}
} | [
"func",
"DialWithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"DialOption",
"{",
"return",
"DialOption",
"{",
"func",
"(",
"do",
"*",
"dialOptions",
")",
"{",
"do",
".",
"context",
"=",
"ctx",
"\n",
"}",
"}",
"\n",
"}"
] | // DialWithContext returns a DialOption that configures the ServerConn with specified context
// The context will be used for the initial connection setup | [
"DialWithContext",
"returns",
"a",
"DialOption",
"that",
"configures",
"the",
"ServerConn",
"with",
"specified",
"context",
"The",
"context",
"will",
"be",
"used",
"for",
"the",
"initial",
"connection",
"setup"
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L181-L185 |
27,103 | jlaffaye/ftp | ftp.go | DialWithTLS | func DialWithTLS(tlsConfig tls.Config) DialOption {
return DialOption{func(do *dialOptions) {
do.tlsConfig = tlsConfig
}}
} | go | func DialWithTLS(tlsConfig tls.Config) DialOption {
return DialOption{func(do *dialOptions) {
do.tlsConfig = tlsConfig
}}
} | [
"func",
"DialWithTLS",
"(",
"tlsConfig",
"tls",
".",
"Config",
")",
"DialOption",
"{",
"return",
"DialOption",
"{",
"func",
"(",
"do",
"*",
"dialOptions",
")",
"{",
"do",
".",
"tlsConfig",
"=",
"tlsConfig",
"\n",
"}",
"}",
"\n",
"}"
] | // DialWithTLS returns a DialOption that configures the ServerConn with specified TLS config | [
"DialWithTLS",
"returns",
"a",
"DialOption",
"that",
"configures",
"the",
"ServerConn",
"with",
"specified",
"TLS",
"config"
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L188-L192 |
27,104 | jlaffaye/ftp | ftp.go | DialWithDebugOutput | func DialWithDebugOutput(w io.Writer) DialOption {
return DialOption{func(do *dialOptions) {
do.debugOutput = w
}}
} | go | func DialWithDebugOutput(w io.Writer) DialOption {
return DialOption{func(do *dialOptions) {
do.debugOutput = w
}}
} | [
"func",
"DialWithDebugOutput",
"(",
"w",
"io",
".",
"Writer",
")",
"DialOption",
"{",
"return",
"DialOption",
"{",
"func",
"(",
"do",
"*",
"dialOptions",
")",
"{",
"do",
".",
"debugOutput",
"=",
"w",
"\n",
"}",
"}",
"\n",
"}"
] | // DialWithDebugOutput returns a DialOption that configures the ServerConn to write to the Writer
// everything it reads from the server | [
"DialWithDebugOutput",
"returns",
"a",
"DialOption",
"that",
"configures",
"the",
"ServerConn",
"to",
"write",
"to",
"the",
"Writer",
"everything",
"it",
"reads",
"from",
"the",
"server"
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L196-L200 |
27,105 | jlaffaye/ftp | ftp.go | DialWithDialFunc | func DialWithDialFunc(f func(network, address string) (net.Conn, error)) DialOption {
return DialOption{func(do *dialOptions) {
do.dialFunc = f
}}
} | go | func DialWithDialFunc(f func(network, address string) (net.Conn, error)) DialOption {
return DialOption{func(do *dialOptions) {
do.dialFunc = f
}}
} | [
"func",
"DialWithDialFunc",
"(",
"f",
"func",
"(",
"network",
",",
"address",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
")",
"DialOption",
"{",
"return",
"DialOption",
"{",
"func",
"(",
"do",
"*",
"dialOptions",
")",
"{",
"do",
".",
... | // DialWithDialFunc returns a DialOption that configures the ServerConn to use the
// specified function to establish both control and data connections
//
// If used together with the DialWithNetConn option, the DialWithNetConn
// takes precedence for the control connection, while data connections will
// be establishe... | [
"DialWithDialFunc",
"returns",
"a",
"DialOption",
"that",
"configures",
"the",
"ServerConn",
"to",
"use",
"the",
"specified",
"function",
"to",
"establish",
"both",
"control",
"and",
"data",
"connections",
"If",
"used",
"together",
"with",
"the",
"DialWithNetConn",
... | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L208-L212 |
27,106 | jlaffaye/ftp | ftp.go | feat | func (c *ServerConn) feat() error {
code, message, err := c.cmd(-1, "FEAT")
if err != nil {
return err
}
if code != StatusSystem {
// The server does not support the FEAT command. This is not an
// error: we consider that there is no additional feature.
return nil
}
lines := strings.Split(message, "\n")... | go | func (c *ServerConn) feat() error {
code, message, err := c.cmd(-1, "FEAT")
if err != nil {
return err
}
if code != StatusSystem {
// The server does not support the FEAT command. This is not an
// error: we consider that there is no additional feature.
return nil
}
lines := strings.Split(message, "\n")... | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"feat",
"(",
")",
"error",
"{",
"code",
",",
"message",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"-",
"1",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",... | // feat issues a FEAT FTP command to list the additional commands supported by
// the remote FTP server.
// FEAT is described in RFC 2389 | [
"feat",
"issues",
"a",
"FEAT",
"FTP",
"command",
"to",
"list",
"the",
"additional",
"commands",
"supported",
"by",
"the",
"remote",
"FTP",
"server",
".",
"FEAT",
"is",
"described",
"in",
"RFC",
"2389"
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L262-L294 |
27,107 | jlaffaye/ftp | ftp.go | setUTF8 | func (c *ServerConn) setUTF8() error {
if _, ok := c.features["UTF8"]; !ok {
return nil
}
code, message, err := c.cmd(-1, "OPTS UTF8 ON")
if err != nil {
return err
}
// Workaround for FTP servers, that does not support this option.
if code == StatusBadArguments {
return nil
}
// The ftpd "filezilla-s... | go | func (c *ServerConn) setUTF8() error {
if _, ok := c.features["UTF8"]; !ok {
return nil
}
code, message, err := c.cmd(-1, "OPTS UTF8 ON")
if err != nil {
return err
}
// Workaround for FTP servers, that does not support this option.
if code == StatusBadArguments {
return nil
}
// The ftpd "filezilla-s... | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"setUTF8",
"(",
")",
"error",
"{",
"if",
"_",
",",
"ok",
":=",
"c",
".",
"features",
"[",
"\"",
"\"",
"]",
";",
"!",
"ok",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"code",
",",
"message",
",",
"err",
... | // setUTF8 issues an "OPTS UTF8 ON" command. | [
"setUTF8",
"issues",
"an",
"OPTS",
"UTF8",
"ON",
"command",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L297-L324 |
27,108 | jlaffaye/ftp | ftp.go | epsv | func (c *ServerConn) epsv() (port int, err error) {
_, line, err := c.cmd(StatusExtendedPassiveMode, "EPSV")
if err != nil {
return
}
start := strings.Index(line, "|||")
end := strings.LastIndex(line, "|")
if start == -1 || end == -1 {
err = errors.New("invalid EPSV response format")
return
}
port, err =... | go | func (c *ServerConn) epsv() (port int, err error) {
_, line, err := c.cmd(StatusExtendedPassiveMode, "EPSV")
if err != nil {
return
}
start := strings.Index(line, "|||")
end := strings.LastIndex(line, "|")
if start == -1 || end == -1 {
err = errors.New("invalid EPSV response format")
return
}
port, err =... | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"epsv",
"(",
")",
"(",
"port",
"int",
",",
"err",
"error",
")",
"{",
"_",
",",
"line",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"StatusExtendedPassiveMode",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
... | // epsv issues an "EPSV" command to get a port number for a data connection. | [
"epsv",
"issues",
"an",
"EPSV",
"command",
"to",
"get",
"a",
"port",
"number",
"for",
"a",
"data",
"connection",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L327-L341 |
27,109 | jlaffaye/ftp | ftp.go | pasv | func (c *ServerConn) pasv() (host string, port int, err error) {
_, line, err := c.cmd(StatusPassiveMode, "PASV")
if err != nil {
return
}
// PASV response format : 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).
start := strings.Index(line, "(")
end := strings.LastIndex(line, ")")
if start == -1 || end == -1 ... | go | func (c *ServerConn) pasv() (host string, port int, err error) {
_, line, err := c.cmd(StatusPassiveMode, "PASV")
if err != nil {
return
}
// PASV response format : 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).
start := strings.Index(line, "(")
end := strings.LastIndex(line, ")")
if start == -1 || end == -1 ... | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"pasv",
"(",
")",
"(",
"host",
"string",
",",
"port",
"int",
",",
"err",
"error",
")",
"{",
"_",
",",
"line",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"StatusPassiveMode",
",",
"\"",
"\"",
")",
"\n",
"if... | // pasv issues a "PASV" command to get a port number for a data connection. | [
"pasv",
"issues",
"a",
"PASV",
"command",
"to",
"get",
"a",
"port",
"number",
"for",
"a",
"data",
"connection",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L344-L385 |
27,110 | jlaffaye/ftp | ftp.go | getDataConnPort | func (c *ServerConn) getDataConnPort() (string, int, error) {
if !c.options.disableEPSV && !c.skipEPSV {
if port, err := c.epsv(); err == nil {
return c.host, port, nil
}
// if there is an error, skip EPSV for the next attempts
c.skipEPSV = true
}
return c.pasv()
} | go | func (c *ServerConn) getDataConnPort() (string, int, error) {
if !c.options.disableEPSV && !c.skipEPSV {
if port, err := c.epsv(); err == nil {
return c.host, port, nil
}
// if there is an error, skip EPSV for the next attempts
c.skipEPSV = true
}
return c.pasv()
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"getDataConnPort",
"(",
")",
"(",
"string",
",",
"int",
",",
"error",
")",
"{",
"if",
"!",
"c",
".",
"options",
".",
"disableEPSV",
"&&",
"!",
"c",
".",
"skipEPSV",
"{",
"if",
"port",
",",
"err",
":=",
"c... | // getDataConnPort returns a host, port for a new data connection
// it uses the best available method to do so | [
"getDataConnPort",
"returns",
"a",
"host",
"port",
"for",
"a",
"new",
"data",
"connection",
"it",
"uses",
"the",
"best",
"available",
"method",
"to",
"do",
"so"
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L389-L400 |
27,111 | jlaffaye/ftp | ftp.go | openDataConn | func (c *ServerConn) openDataConn() (net.Conn, error) {
host, port, err := c.getDataConnPort()
if err != nil {
return nil, err
}
addr := net.JoinHostPort(host, strconv.Itoa(port))
if c.options.dialFunc != nil {
return c.options.dialFunc("tcp", addr)
}
return c.options.dialer.Dial("tcp", addr)
} | go | func (c *ServerConn) openDataConn() (net.Conn, error) {
host, port, err := c.getDataConnPort()
if err != nil {
return nil, err
}
addr := net.JoinHostPort(host, strconv.Itoa(port))
if c.options.dialFunc != nil {
return c.options.dialFunc("tcp", addr)
}
return c.options.dialer.Dial("tcp", addr)
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"openDataConn",
"(",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"host",
",",
"port",
",",
"err",
":=",
"c",
".",
"getDataConnPort",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil... | // openDataConn creates a new FTP data connection. | [
"openDataConn",
"creates",
"a",
"new",
"FTP",
"data",
"connection",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L403-L415 |
27,112 | jlaffaye/ftp | ftp.go | cmd | func (c *ServerConn) cmd(expected int, format string, args ...interface{}) (int, string, error) {
_, err := c.conn.Cmd(format, args...)
if err != nil {
return 0, "", err
}
return c.conn.ReadResponse(expected)
} | go | func (c *ServerConn) cmd(expected int, format string, args ...interface{}) (int, string, error) {
_, err := c.conn.Cmd(format, args...)
if err != nil {
return 0, "", err
}
return c.conn.ReadResponse(expected)
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"cmd",
"(",
"expected",
"int",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"int",
",",
"string",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"c",
".",
"conn",
".",
"... | // cmd is a helper function to execute a command and check for the expected FTP
// return code | [
"cmd",
"is",
"a",
"helper",
"function",
"to",
"execute",
"a",
"command",
"and",
"check",
"for",
"the",
"expected",
"FTP",
"return",
"code"
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L419-L426 |
27,113 | jlaffaye/ftp | ftp.go | cmdDataConnFrom | func (c *ServerConn) cmdDataConnFrom(offset uint64, format string, args ...interface{}) (net.Conn, error) {
conn, err := c.openDataConn()
if err != nil {
return nil, err
}
if offset != 0 {
_, _, err := c.cmd(StatusRequestFilePending, "REST %d", offset)
if err != nil {
conn.Close()
return nil, err
}
... | go | func (c *ServerConn) cmdDataConnFrom(offset uint64, format string, args ...interface{}) (net.Conn, error) {
conn, err := c.openDataConn()
if err != nil {
return nil, err
}
if offset != 0 {
_, _, err := c.cmd(StatusRequestFilePending, "REST %d", offset)
if err != nil {
conn.Close()
return nil, err
}
... | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"cmdDataConnFrom",
"(",
"offset",
"uint64",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"c",
".",
"ope... | // cmdDataConnFrom executes a command which require a FTP data connection.
// Issues a REST FTP command to specify the number of bytes to skip for the transfer. | [
"cmdDataConnFrom",
"executes",
"a",
"command",
"which",
"require",
"a",
"FTP",
"data",
"connection",
".",
"Issues",
"a",
"REST",
"FTP",
"command",
"to",
"specify",
"the",
"number",
"of",
"bytes",
"to",
"skip",
"for",
"the",
"transfer",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L430-L461 |
27,114 | jlaffaye/ftp | ftp.go | NameList | func (c *ServerConn) NameList(path string) (entries []string, err error) {
conn, err := c.cmdDataConnFrom(0, "NLST %s", path)
if err != nil {
return
}
r := &Response{conn: conn, c: c}
defer r.Close()
scanner := bufio.NewScanner(r)
for scanner.Scan() {
entries = append(entries, scanner.Text())
}
if err = ... | go | func (c *ServerConn) NameList(path string) (entries []string, err error) {
conn, err := c.cmdDataConnFrom(0, "NLST %s", path)
if err != nil {
return
}
r := &Response{conn: conn, c: c}
defer r.Close()
scanner := bufio.NewScanner(r)
for scanner.Scan() {
entries = append(entries, scanner.Text())
}
if err = ... | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"NameList",
"(",
"path",
"string",
")",
"(",
"entries",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"c",
".",
"cmdDataConnFrom",
"(",
"0",
",",
"\"",
"\"",
",",
"path",
")... | // NameList issues an NLST FTP command. | [
"NameList",
"issues",
"an",
"NLST",
"FTP",
"command",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L464-L481 |
27,115 | jlaffaye/ftp | ftp.go | List | func (c *ServerConn) List(path string) (entries []*Entry, err error) {
var cmd string
var parser parseFunc
if c.mlstSupported {
cmd = "MLSD"
parser = parseRFC3659ListLine
} else {
cmd = "LIST"
parser = parseListLine
}
conn, err := c.cmdDataConnFrom(0, "%s %s", cmd, path)
if err != nil {
return
}
r... | go | func (c *ServerConn) List(path string) (entries []*Entry, err error) {
var cmd string
var parser parseFunc
if c.mlstSupported {
cmd = "MLSD"
parser = parseRFC3659ListLine
} else {
cmd = "LIST"
parser = parseListLine
}
conn, err := c.cmdDataConnFrom(0, "%s %s", cmd, path)
if err != nil {
return
}
r... | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"List",
"(",
"path",
"string",
")",
"(",
"entries",
"[",
"]",
"*",
"Entry",
",",
"err",
"error",
")",
"{",
"var",
"cmd",
"string",
"\n",
"var",
"parser",
"parseFunc",
"\n\n",
"if",
"c",
".",
"mlstSupported",
... | // List issues a LIST FTP command. | [
"List",
"issues",
"a",
"LIST",
"FTP",
"command",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L484-L516 |
27,116 | jlaffaye/ftp | ftp.go | ChangeDirToParent | func (c *ServerConn) ChangeDirToParent() error {
_, _, err := c.cmd(StatusRequestedFileActionOK, "CDUP")
return err
} | go | func (c *ServerConn) ChangeDirToParent() error {
_, _, err := c.cmd(StatusRequestedFileActionOK, "CDUP")
return err
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"ChangeDirToParent",
"(",
")",
"error",
"{",
"_",
",",
"_",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"StatusRequestedFileActionOK",
",",
"\"",
"\"",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // ChangeDirToParent issues a CDUP FTP command, which changes the current
// directory to the parent directory. This is similar to a call to ChangeDir
// with a path set to "..". | [
"ChangeDirToParent",
"issues",
"a",
"CDUP",
"FTP",
"command",
"which",
"changes",
"the",
"current",
"directory",
"to",
"the",
"parent",
"directory",
".",
"This",
"is",
"similar",
"to",
"a",
"call",
"to",
"ChangeDir",
"with",
"a",
"path",
"set",
"to",
"..",
... | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L528-L531 |
27,117 | jlaffaye/ftp | ftp.go | CurrentDir | func (c *ServerConn) CurrentDir() (string, error) {
_, msg, err := c.cmd(StatusPathCreated, "PWD")
if err != nil {
return "", err
}
start := strings.Index(msg, "\"")
end := strings.LastIndex(msg, "\"")
if start == -1 || end == -1 {
return "", errors.New("unsuported PWD response format")
}
return msg[star... | go | func (c *ServerConn) CurrentDir() (string, error) {
_, msg, err := c.cmd(StatusPathCreated, "PWD")
if err != nil {
return "", err
}
start := strings.Index(msg, "\"")
end := strings.LastIndex(msg, "\"")
if start == -1 || end == -1 {
return "", errors.New("unsuported PWD response format")
}
return msg[star... | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"CurrentDir",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"_",
",",
"msg",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"StatusPathCreated",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r... | // CurrentDir issues a PWD FTP command, which Returns the path of the current
// directory. | [
"CurrentDir",
"issues",
"a",
"PWD",
"FTP",
"command",
"which",
"Returns",
"the",
"path",
"of",
"the",
"current",
"directory",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L535-L549 |
27,118 | jlaffaye/ftp | ftp.go | FileSize | func (c *ServerConn) FileSize(path string) (int64, error) {
_, msg, err := c.cmd(StatusFile, "SIZE %s", path)
if err != nil {
return 0, err
}
return strconv.ParseInt(msg, 10, 64)
} | go | func (c *ServerConn) FileSize(path string) (int64, error) {
_, msg, err := c.cmd(StatusFile, "SIZE %s", path)
if err != nil {
return 0, err
}
return strconv.ParseInt(msg, 10, 64)
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"FileSize",
"(",
"path",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"_",
",",
"msg",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"StatusFile",
",",
"\"",
"\"",
",",
"path",
")",
"\n",
"if",
"err",... | // FileSize issues a SIZE FTP command, which Returns the size of the file | [
"FileSize",
"issues",
"a",
"SIZE",
"FTP",
"command",
"which",
"Returns",
"the",
"size",
"of",
"the",
"file"
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L552-L559 |
27,119 | jlaffaye/ftp | ftp.go | Retr | func (c *ServerConn) Retr(path string) (*Response, error) {
return c.RetrFrom(path, 0)
} | go | func (c *ServerConn) Retr(path string) (*Response, error) {
return c.RetrFrom(path, 0)
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"Retr",
"(",
"path",
"string",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"return",
"c",
".",
"RetrFrom",
"(",
"path",
",",
"0",
")",
"\n",
"}"
] | // Retr issues a RETR FTP command to fetch the specified file from the remote
// FTP server.
//
// The returned ReadCloser must be closed to cleanup the FTP data connection. | [
"Retr",
"issues",
"a",
"RETR",
"FTP",
"command",
"to",
"fetch",
"the",
"specified",
"file",
"from",
"the",
"remote",
"FTP",
"server",
".",
"The",
"returned",
"ReadCloser",
"must",
"be",
"closed",
"to",
"cleanup",
"the",
"FTP",
"data",
"connection",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L565-L567 |
27,120 | jlaffaye/ftp | ftp.go | RetrFrom | func (c *ServerConn) RetrFrom(path string, offset uint64) (*Response, error) {
conn, err := c.cmdDataConnFrom(offset, "RETR %s", path)
if err != nil {
return nil, err
}
return &Response{conn: conn, c: c}, nil
} | go | func (c *ServerConn) RetrFrom(path string, offset uint64) (*Response, error) {
conn, err := c.cmdDataConnFrom(offset, "RETR %s", path)
if err != nil {
return nil, err
}
return &Response{conn: conn, c: c}, nil
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"RetrFrom",
"(",
"path",
"string",
",",
"offset",
"uint64",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"c",
".",
"cmdDataConnFrom",
"(",
"offset",
",",
"\"",
"\"",
",",
"pa... | // RetrFrom issues a RETR FTP command to fetch the specified file from the remote
// FTP server, the server will not send the offset first bytes of the file.
//
// The returned ReadCloser must be closed to cleanup the FTP data connection. | [
"RetrFrom",
"issues",
"a",
"RETR",
"FTP",
"command",
"to",
"fetch",
"the",
"specified",
"file",
"from",
"the",
"remote",
"FTP",
"server",
"the",
"server",
"will",
"not",
"send",
"the",
"offset",
"first",
"bytes",
"of",
"the",
"file",
".",
"The",
"returned"... | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L573-L580 |
27,121 | jlaffaye/ftp | ftp.go | Rename | func (c *ServerConn) Rename(from, to string) error {
_, _, err := c.cmd(StatusRequestFilePending, "RNFR %s", from)
if err != nil {
return err
}
_, _, err = c.cmd(StatusRequestedFileActionOK, "RNTO %s", to)
return err
} | go | func (c *ServerConn) Rename(from, to string) error {
_, _, err := c.cmd(StatusRequestFilePending, "RNFR %s", from)
if err != nil {
return err
}
_, _, err = c.cmd(StatusRequestedFileActionOK, "RNTO %s", to)
return err
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"Rename",
"(",
"from",
",",
"to",
"string",
")",
"error",
"{",
"_",
",",
"_",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"StatusRequestFilePending",
",",
"\"",
"\"",
",",
"from",
")",
"\n",
"if",
"err",
"!="... | // Rename renames a file on the remote FTP server. | [
"Rename",
"renames",
"a",
"file",
"on",
"the",
"remote",
"FTP",
"server",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L612-L620 |
27,122 | jlaffaye/ftp | ftp.go | Delete | func (c *ServerConn) Delete(path string) error {
_, _, err := c.cmd(StatusRequestedFileActionOK, "DELE %s", path)
return err
} | go | func (c *ServerConn) Delete(path string) error {
_, _, err := c.cmd(StatusRequestedFileActionOK, "DELE %s", path)
return err
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"Delete",
"(",
"path",
"string",
")",
"error",
"{",
"_",
",",
"_",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"StatusRequestedFileActionOK",
",",
"\"",
"\"",
",",
"path",
")",
"\n",
"return",
"err",
"\n",
"}"
... | // Delete issues a DELE FTP command to delete the specified file from the
// remote FTP server. | [
"Delete",
"issues",
"a",
"DELE",
"FTP",
"command",
"to",
"delete",
"the",
"specified",
"file",
"from",
"the",
"remote",
"FTP",
"server",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L624-L627 |
27,123 | jlaffaye/ftp | ftp.go | RemoveDirRecur | func (c *ServerConn) RemoveDirRecur(path string) error {
err := c.ChangeDir(path)
if err != nil {
return err
}
currentDir, err := c.CurrentDir()
if err != nil {
return err
}
entries, err := c.List(currentDir)
if err != nil {
return err
}
for _, entry := range entries {
if entry.Name != ".." && entry... | go | func (c *ServerConn) RemoveDirRecur(path string) error {
err := c.ChangeDir(path)
if err != nil {
return err
}
currentDir, err := c.CurrentDir()
if err != nil {
return err
}
entries, err := c.List(currentDir)
if err != nil {
return err
}
for _, entry := range entries {
if entry.Name != ".." && entry... | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"RemoveDirRecur",
"(",
"path",
"string",
")",
"error",
"{",
"err",
":=",
"c",
".",
"ChangeDir",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"currentDir",
",",
"e... | // RemoveDirRecur deletes a non-empty folder recursively using
// RemoveDir and Delete | [
"RemoveDirRecur",
"deletes",
"a",
"non",
"-",
"empty",
"folder",
"recursively",
"using",
"RemoveDir",
"and",
"Delete"
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L631-L667 |
27,124 | jlaffaye/ftp | ftp.go | MakeDir | func (c *ServerConn) MakeDir(path string) error {
_, _, err := c.cmd(StatusPathCreated, "MKD %s", path)
return err
} | go | func (c *ServerConn) MakeDir(path string) error {
_, _, err := c.cmd(StatusPathCreated, "MKD %s", path)
return err
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"MakeDir",
"(",
"path",
"string",
")",
"error",
"{",
"_",
",",
"_",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"StatusPathCreated",
",",
"\"",
"\"",
",",
"path",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // MakeDir issues a MKD FTP command to create the specified directory on the
// remote FTP server. | [
"MakeDir",
"issues",
"a",
"MKD",
"FTP",
"command",
"to",
"create",
"the",
"specified",
"directory",
"on",
"the",
"remote",
"FTP",
"server",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L671-L674 |
27,125 | jlaffaye/ftp | ftp.go | NoOp | func (c *ServerConn) NoOp() error {
_, _, err := c.cmd(StatusCommandOK, "NOOP")
return err
} | go | func (c *ServerConn) NoOp() error {
_, _, err := c.cmd(StatusCommandOK, "NOOP")
return err
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"NoOp",
"(",
")",
"error",
"{",
"_",
",",
"_",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"StatusCommandOK",
",",
"\"",
"\"",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // NoOp issues a NOOP FTP command.
// NOOP has no effects and is usually used to prevent the remote FTP server to
// close the otherwise idle connection. | [
"NoOp",
"issues",
"a",
"NOOP",
"FTP",
"command",
".",
"NOOP",
"has",
"no",
"effects",
"and",
"is",
"usually",
"used",
"to",
"prevent",
"the",
"remote",
"FTP",
"server",
"to",
"close",
"the",
"otherwise",
"idle",
"connection",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L686-L689 |
27,126 | jlaffaye/ftp | ftp.go | Logout | func (c *ServerConn) Logout() error {
_, _, err := c.cmd(StatusReady, "REIN")
return err
} | go | func (c *ServerConn) Logout() error {
_, _, err := c.cmd(StatusReady, "REIN")
return err
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"Logout",
"(",
")",
"error",
"{",
"_",
",",
"_",
",",
"err",
":=",
"c",
".",
"cmd",
"(",
"StatusReady",
",",
"\"",
"\"",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Logout issues a REIN FTP command to logout the current user. | [
"Logout",
"issues",
"a",
"REIN",
"FTP",
"command",
"to",
"logout",
"the",
"current",
"user",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L692-L695 |
27,127 | jlaffaye/ftp | ftp.go | Quit | func (c *ServerConn) Quit() error {
c.conn.Cmd("QUIT")
return c.conn.Close()
} | go | func (c *ServerConn) Quit() error {
c.conn.Cmd("QUIT")
return c.conn.Close()
} | [
"func",
"(",
"c",
"*",
"ServerConn",
")",
"Quit",
"(",
")",
"error",
"{",
"c",
".",
"conn",
".",
"Cmd",
"(",
"\"",
"\"",
")",
"\n",
"return",
"c",
".",
"conn",
".",
"Close",
"(",
")",
"\n",
"}"
] | // Quit issues a QUIT FTP command to properly close the connection from the
// remote FTP server. | [
"Quit",
"issues",
"a",
"QUIT",
"FTP",
"command",
"to",
"properly",
"close",
"the",
"connection",
"from",
"the",
"remote",
"FTP",
"server",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L699-L702 |
27,128 | jlaffaye/ftp | ftp.go | Read | func (r *Response) Read(buf []byte) (int, error) {
return r.conn.Read(buf)
} | go | func (r *Response) Read(buf []byte) (int, error) {
return r.conn.Read(buf)
} | [
"func",
"(",
"r",
"*",
"Response",
")",
"Read",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"r",
".",
"conn",
".",
"Read",
"(",
"buf",
")",
"\n",
"}"
] | // Read implements the io.Reader interface on a FTP data connection. | [
"Read",
"implements",
"the",
"io",
".",
"Reader",
"interface",
"on",
"a",
"FTP",
"data",
"connection",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L705-L707 |
27,129 | jlaffaye/ftp | ftp.go | Close | func (r *Response) Close() error {
if r.closed {
return nil
}
err := r.conn.Close()
_, _, err2 := r.c.conn.ReadResponse(StatusClosingDataConnection)
if err2 != nil {
err = err2
}
r.closed = true
return err
} | go | func (r *Response) Close() error {
if r.closed {
return nil
}
err := r.conn.Close()
_, _, err2 := r.c.conn.ReadResponse(StatusClosingDataConnection)
if err2 != nil {
err = err2
}
r.closed = true
return err
} | [
"func",
"(",
"r",
"*",
"Response",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"r",
".",
"closed",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"err",
":=",
"r",
".",
"conn",
".",
"Close",
"(",
")",
"\n",
"_",
",",
"_",
",",
"err2",
":=",
"r",
".... | // Close implements the io.Closer interface on a FTP data connection.
// After the first call, Close will do nothing and return nil. | [
"Close",
"implements",
"the",
"io",
".",
"Closer",
"interface",
"on",
"a",
"FTP",
"data",
"connection",
".",
"After",
"the",
"first",
"call",
"Close",
"will",
"do",
"nothing",
"and",
"return",
"nil",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L711-L722 |
27,130 | jlaffaye/ftp | ftp.go | SetDeadline | func (r *Response) SetDeadline(t time.Time) error {
return r.conn.SetDeadline(t)
} | go | func (r *Response) SetDeadline(t time.Time) error {
return r.conn.SetDeadline(t)
} | [
"func",
"(",
"r",
"*",
"Response",
")",
"SetDeadline",
"(",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"return",
"r",
".",
"conn",
".",
"SetDeadline",
"(",
"t",
")",
"\n",
"}"
] | // SetDeadline sets the deadlines associated with the connection. | [
"SetDeadline",
"sets",
"the",
"deadlines",
"associated",
"with",
"the",
"connection",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/ftp.go#L725-L727 |
27,131 | jlaffaye/ftp | parse.go | parseRFC3659ListLine | func parseRFC3659ListLine(line string, now time.Time, loc *time.Location) (*Entry, error) {
iSemicolon := strings.Index(line, ";")
iWhitespace := strings.Index(line, " ")
if iSemicolon < 0 || iSemicolon > iWhitespace {
return nil, errUnsupportedListLine
}
e := &Entry{
Name: line[iWhitespace+1:],
}
for _, ... | go | func parseRFC3659ListLine(line string, now time.Time, loc *time.Location) (*Entry, error) {
iSemicolon := strings.Index(line, ";")
iWhitespace := strings.Index(line, " ")
if iSemicolon < 0 || iSemicolon > iWhitespace {
return nil, errUnsupportedListLine
}
e := &Entry{
Name: line[iWhitespace+1:],
}
for _, ... | [
"func",
"parseRFC3659ListLine",
"(",
"line",
"string",
",",
"now",
"time",
".",
"Time",
",",
"loc",
"*",
"time",
".",
"Location",
")",
"(",
"*",
"Entry",
",",
"error",
")",
"{",
"iSemicolon",
":=",
"strings",
".",
"Index",
"(",
"line",
",",
"\"",
"\"... | // parseRFC3659ListLine parses the style of directory line defined in RFC 3659. | [
"parseRFC3659ListLine",
"parses",
"the",
"style",
"of",
"directory",
"line",
"defined",
"in",
"RFC",
"3659",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/parse.go#L30-L70 |
27,132 | jlaffaye/ftp | parse.go | parseLsListLine | func parseLsListLine(line string, now time.Time, loc *time.Location) (*Entry, error) {
// Has the first field a length of 10 bytes?
if strings.IndexByte(line, ' ') != 10 {
return nil, errUnsupportedListLine
}
scanner := newScanner(line)
fields := scanner.NextFields(6)
if len(fields) < 6 {
return nil, errUn... | go | func parseLsListLine(line string, now time.Time, loc *time.Location) (*Entry, error) {
// Has the first field a length of 10 bytes?
if strings.IndexByte(line, ' ') != 10 {
return nil, errUnsupportedListLine
}
scanner := newScanner(line)
fields := scanner.NextFields(6)
if len(fields) < 6 {
return nil, errUn... | [
"func",
"parseLsListLine",
"(",
"line",
"string",
",",
"now",
"time",
".",
"Time",
",",
"loc",
"*",
"time",
".",
"Location",
")",
"(",
"*",
"Entry",
",",
"error",
")",
"{",
"// Has the first field a length of 10 bytes?",
"if",
"strings",
".",
"IndexByte",
"(... | // parseLsListLine parses a directory line in a format based on the output of
// the UNIX ls command. | [
"parseLsListLine",
"parses",
"a",
"directory",
"line",
"in",
"a",
"format",
"based",
"on",
"the",
"output",
"of",
"the",
"UNIX",
"ls",
"command",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/parse.go#L74-L145 |
27,133 | jlaffaye/ftp | parse.go | parseDirListLine | func parseDirListLine(line string, now time.Time, loc *time.Location) (*Entry, error) {
e := &Entry{}
var err error
// Try various time formats that DIR might use, and stop when one works.
for _, format := range dirTimeFormats {
if len(line) > len(format) {
e.Time, err = time.ParseInLocation(format, line[:len... | go | func parseDirListLine(line string, now time.Time, loc *time.Location) (*Entry, error) {
e := &Entry{}
var err error
// Try various time formats that DIR might use, and stop when one works.
for _, format := range dirTimeFormats {
if len(line) > len(format) {
e.Time, err = time.ParseInLocation(format, line[:len... | [
"func",
"parseDirListLine",
"(",
"line",
"string",
",",
"now",
"time",
".",
"Time",
",",
"loc",
"*",
"time",
".",
"Location",
")",
"(",
"*",
"Entry",
",",
"error",
")",
"{",
"e",
":=",
"&",
"Entry",
"{",
"}",
"\n",
"var",
"err",
"error",
"\n\n",
... | // parseDirListLine parses a directory line in a format based on the output of
// the MS-DOS DIR command. | [
"parseDirListLine",
"parses",
"a",
"directory",
"line",
"in",
"a",
"format",
"based",
"on",
"the",
"output",
"of",
"the",
"MS",
"-",
"DOS",
"DIR",
"command",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/parse.go#L149-L187 |
27,134 | jlaffaye/ftp | parse.go | parseListLine | func parseListLine(line string, now time.Time, loc *time.Location) (*Entry, error) {
for _, f := range listLineParsers {
e, err := f(line, now, loc)
if err != errUnsupportedListLine {
return e, err
}
}
return nil, errUnsupportedListLine
} | go | func parseListLine(line string, now time.Time, loc *time.Location) (*Entry, error) {
for _, f := range listLineParsers {
e, err := f(line, now, loc)
if err != errUnsupportedListLine {
return e, err
}
}
return nil, errUnsupportedListLine
} | [
"func",
"parseListLine",
"(",
"line",
"string",
",",
"now",
"time",
".",
"Time",
",",
"loc",
"*",
"time",
".",
"Location",
")",
"(",
"*",
"Entry",
",",
"error",
")",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"listLineParsers",
"{",
"e",
",",
"err",... | // parseListLine parses the various non-standard format returned by the LIST
// FTP command. | [
"parseListLine",
"parses",
"the",
"various",
"non",
"-",
"standard",
"format",
"returned",
"by",
"the",
"LIST",
"FTP",
"command",
"."
] | 6a014d5e22e6a0b7c1fcb65f59872e4dd1227111 | https://github.com/jlaffaye/ftp/blob/6a014d5e22e6a0b7c1fcb65f59872e4dd1227111/parse.go#L212-L220 |
27,135 | Shopify/ejson | ejson.go | GenerateKeypair | func GenerateKeypair() (pub string, priv string, err error) {
var kp crypto.Keypair
if err := kp.Generate(); err != nil {
return "", "", err
}
return kp.PublicString(), kp.PrivateString(), nil
} | go | func GenerateKeypair() (pub string, priv string, err error) {
var kp crypto.Keypair
if err := kp.Generate(); err != nil {
return "", "", err
}
return kp.PublicString(), kp.PrivateString(), nil
} | [
"func",
"GenerateKeypair",
"(",
")",
"(",
"pub",
"string",
",",
"priv",
"string",
",",
"err",
"error",
")",
"{",
"var",
"kp",
"crypto",
".",
"Keypair",
"\n",
"if",
"err",
":=",
"kp",
".",
"Generate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return"... | // GenerateKeypair is used to create a new ejson keypair. It returns the keys as
// hex-encoded strings, suitable for printing to the screen. hex.DecodeString
// can be used to load the true representation if necessary. | [
"GenerateKeypair",
"is",
"used",
"to",
"create",
"a",
"new",
"ejson",
"keypair",
".",
"It",
"returns",
"the",
"keys",
"as",
"hex",
"-",
"encoded",
"strings",
"suitable",
"for",
"printing",
"to",
"the",
"screen",
".",
"hex",
".",
"DecodeString",
"can",
"be"... | 9d2ed221270221cf82616946316a0a62dca4a4a9 | https://github.com/Shopify/ejson/blob/9d2ed221270221cf82616946316a0a62dca4a4a9/ejson.go#L22-L28 |
27,136 | Shopify/ejson | ejson.go | Encrypt | func Encrypt(in io.Reader, out io.Writer) (int, error) {
data, err := ioutil.ReadAll(in)
if err != nil {
return -1, err
}
var myKP crypto.Keypair
if err = myKP.Generate(); err != nil {
return -1, err
}
pubkey, err := json.ExtractPublicKey(data)
if err != nil {
return -1, err
}
encrypter := myKP.Encry... | go | func Encrypt(in io.Reader, out io.Writer) (int, error) {
data, err := ioutil.ReadAll(in)
if err != nil {
return -1, err
}
var myKP crypto.Keypair
if err = myKP.Generate(); err != nil {
return -1, err
}
pubkey, err := json.ExtractPublicKey(data)
if err != nil {
return -1, err
}
encrypter := myKP.Encry... | [
"func",
"Encrypt",
"(",
"in",
"io",
".",
"Reader",
",",
"out",
"io",
".",
"Writer",
")",
"(",
"int",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"in",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",... | // Encrypt reads all contents from 'in', extracts the pubkey
// and performs the requested encryption operation, writing
// the resulting data to 'out'.
// Returns the number of bytes written and any error that might have
// occurred. | [
"Encrypt",
"reads",
"all",
"contents",
"from",
"in",
"extracts",
"the",
"pubkey",
"and",
"performs",
"the",
"requested",
"encryption",
"operation",
"writing",
"the",
"resulting",
"data",
"to",
"out",
".",
"Returns",
"the",
"number",
"of",
"bytes",
"written",
"... | 9d2ed221270221cf82616946316a0a62dca4a4a9 | https://github.com/Shopify/ejson/blob/9d2ed221270221cf82616946316a0a62dca4a4a9/ejson.go#L35-L62 |
27,137 | Shopify/ejson | ejson.go | Decrypt | func Decrypt(in io.Reader, out io.Writer, keydir string, userSuppliedPrivateKey string) error {
data, err := ioutil.ReadAll(in)
if err != nil {
return err
}
pubkey, err := json.ExtractPublicKey(data)
if err != nil {
return err
}
privkey, err := findPrivateKey(pubkey, keydir, userSuppliedPrivateKey)
if err... | go | func Decrypt(in io.Reader, out io.Writer, keydir string, userSuppliedPrivateKey string) error {
data, err := ioutil.ReadAll(in)
if err != nil {
return err
}
pubkey, err := json.ExtractPublicKey(data)
if err != nil {
return err
}
privkey, err := findPrivateKey(pubkey, keydir, userSuppliedPrivateKey)
if err... | [
"func",
"Decrypt",
"(",
"in",
"io",
".",
"Reader",
",",
"out",
"io",
".",
"Writer",
",",
"keydir",
"string",
",",
"userSuppliedPrivateKey",
"string",
")",
"error",
"{",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"in",
")",
"\n",
"if",
"... | // Decrypt reads an ejson stream from 'in' and writes the decrypted data to 'out'.
// The private key is expected to be under 'keydir'.
// Returns error upon failure, or nil on success. | [
"Decrypt",
"reads",
"an",
"ejson",
"stream",
"from",
"in",
"and",
"writes",
"the",
"decrypted",
"data",
"to",
"out",
".",
"The",
"private",
"key",
"is",
"expected",
"to",
"be",
"under",
"keydir",
".",
"Returns",
"error",
"upon",
"failure",
"or",
"nil",
"... | 9d2ed221270221cf82616946316a0a62dca4a4a9 | https://github.com/Shopify/ejson/blob/9d2ed221270221cf82616946316a0a62dca4a4a9/ejson.go#L103-L137 |
27,138 | Shopify/ejson | ejson.go | DecryptFile | func DecryptFile(filePath, keydir string, userSuppliedPrivateKey string) ([]byte, error) {
if _, err := os.Stat(filePath); err != nil {
return nil, err
}
file, err := os.Open(filePath)
if err != nil {
return nil, err
}
defer file.Close()
var outBuffer bytes.Buffer
err = Decrypt(file, &outBuffer, keydir, ... | go | func DecryptFile(filePath, keydir string, userSuppliedPrivateKey string) ([]byte, error) {
if _, err := os.Stat(filePath); err != nil {
return nil, err
}
file, err := os.Open(filePath)
if err != nil {
return nil, err
}
defer file.Close()
var outBuffer bytes.Buffer
err = Decrypt(file, &outBuffer, keydir, ... | [
"func",
"DecryptFile",
"(",
"filePath",
",",
"keydir",
"string",
",",
"userSuppliedPrivateKey",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filePath",
")",
";",
"err",
"!=",
"nil... | // DecryptFile takes a path to an encrypted EJSON file and returns the data
// decrypted. The public key used to encrypt the values is embedded in the
// referenced document, and the matching private key is searched for in keydir.
// There must exist a file in keydir whose name is the public key from the
// EJSON docum... | [
"DecryptFile",
"takes",
"a",
"path",
"to",
"an",
"encrypted",
"EJSON",
"file",
"and",
"returns",
"the",
"data",
"decrypted",
".",
"The",
"public",
"key",
"used",
"to",
"encrypt",
"the",
"values",
"is",
"embedded",
"in",
"the",
"referenced",
"document",
"and"... | 9d2ed221270221cf82616946316a0a62dca4a4a9 | https://github.com/Shopify/ejson/blob/9d2ed221270221cf82616946316a0a62dca4a4a9/ejson.go#L145-L161 |
27,139 | Shopify/ejson | crypto/boxed_message.go | Dump | func (b *boxedMessage) Dump() []byte {
pub := base64.StdEncoding.EncodeToString(b.EncrypterPublic[:])
nonce := base64.StdEncoding.EncodeToString(b.Nonce[:])
box := base64.StdEncoding.EncodeToString(b.Box)
str := fmt.Sprintf("EJ[%d:%s:%s:%s]",
b.SchemaVersion, pub, nonce, box)
return []byte(str)
} | go | func (b *boxedMessage) Dump() []byte {
pub := base64.StdEncoding.EncodeToString(b.EncrypterPublic[:])
nonce := base64.StdEncoding.EncodeToString(b.Nonce[:])
box := base64.StdEncoding.EncodeToString(b.Box)
str := fmt.Sprintf("EJ[%d:%s:%s:%s]",
b.SchemaVersion, pub, nonce, box)
return []byte(str)
} | [
"func",
"(",
"b",
"*",
"boxedMessage",
")",
"Dump",
"(",
")",
"[",
"]",
"byte",
"{",
"pub",
":=",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"b",
".",
"EncrypterPublic",
"[",
":",
"]",
")",
"\n",
"nonce",
":=",
"base64",
".",
"StdEncod... | // Dump dumps to the wire format | [
"Dump",
"dumps",
"to",
"the",
"wire",
"format"
] | 9d2ed221270221cf82616946316a0a62dca4a4a9 | https://github.com/Shopify/ejson/blob/9d2ed221270221cf82616946316a0a62dca4a4a9/crypto/boxed_message.go#L39-L47 |
27,140 | Shopify/ejson | crypto/boxed_message.go | Load | func (b *boxedMessage) Load(from []byte) error {
var ssver, spub, snonce, sbox string
var err error
allMatches := messageParser.FindAllStringSubmatch(string(from), -1) // -> [][][]byte
if len(allMatches) != 1 {
return fmt.Errorf("invalid message format")
}
matches := allMatches[0]
if len(matches) != 5 {
ret... | go | func (b *boxedMessage) Load(from []byte) error {
var ssver, spub, snonce, sbox string
var err error
allMatches := messageParser.FindAllStringSubmatch(string(from), -1) // -> [][][]byte
if len(allMatches) != 1 {
return fmt.Errorf("invalid message format")
}
matches := allMatches[0]
if len(matches) != 5 {
ret... | [
"func",
"(",
"b",
"*",
"boxedMessage",
")",
"Load",
"(",
"from",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"ssver",
",",
"spub",
",",
"snonce",
",",
"sbox",
"string",
"\n",
"var",
"err",
"error",
"\n\n",
"allMatches",
":=",
"messageParser",
".",
"F... | // Load restores from the wire format. | [
"Load",
"restores",
"from",
"the",
"wire",
"format",
"."
] | 9d2ed221270221cf82616946316a0a62dca4a4a9 | https://github.com/Shopify/ejson/blob/9d2ed221270221cf82616946316a0a62dca4a4a9/crypto/boxed_message.go#L50-L104 |
27,141 | Shopify/ejson | json/walker.go | quoteBytes | func quoteBytes(in []byte) ([]byte, error) {
data := []string{string(in)}
out, err := json.Marshal(data)
if err != nil {
return nil, err
}
return out[1 : len(out)-1], nil
} | go | func quoteBytes(in []byte) ([]byte, error) {
data := []string{string(in)}
out, err := json.Marshal(data)
if err != nil {
return nil, err
}
return out[1 : len(out)-1], nil
} | [
"func",
"quoteBytes",
"(",
"in",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"data",
":=",
"[",
"]",
"string",
"{",
"string",
"(",
"in",
")",
"}",
"\n",
"out",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"data",
"... | // probably a better way to do this, but... | [
"probably",
"a",
"better",
"way",
"to",
"do",
"this",
"but",
"..."
] | 9d2ed221270221cf82616946316a0a62dca4a4a9 | https://github.com/Shopify/ejson/blob/9d2ed221270221cf82616946316a0a62dca4a4a9/json/walker.go#L126-L133 |
27,142 | Shopify/ejson | json/key.go | ExtractPublicKey | func ExtractPublicKey(data []byte) (key [32]byte, err error) {
var (
obj map[string]interface{}
ks string
ok bool
bs []byte
)
err = json.Unmarshal(data, &obj)
if err != nil {
return
}
k, ok := obj[PublicKeyField]
if !ok {
goto missing
}
ks, ok = k.(string)
if !ok {
goto invalid
}
if len(ks)... | go | func ExtractPublicKey(data []byte) (key [32]byte, err error) {
var (
obj map[string]interface{}
ks string
ok bool
bs []byte
)
err = json.Unmarshal(data, &obj)
if err != nil {
return
}
k, ok := obj[PublicKeyField]
if !ok {
goto missing
}
ks, ok = k.(string)
if !ok {
goto invalid
}
if len(ks)... | [
"func",
"ExtractPublicKey",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"key",
"[",
"32",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"(",
"obj",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"ks",
"string",
"\n",
"ok",
"bool",
"\n"... | // ExtractPublicKey finds the _public_key value in an EJSON document and
// parses it into a key usable with the crypto library. | [
"ExtractPublicKey",
"finds",
"the",
"_public_key",
"value",
"in",
"an",
"EJSON",
"document",
"and",
"parses",
"it",
"into",
"a",
"key",
"usable",
"with",
"the",
"crypto",
"library",
"."
] | 9d2ed221270221cf82616946316a0a62dca4a4a9 | https://github.com/Shopify/ejson/blob/9d2ed221270221cf82616946316a0a62dca4a4a9/json/key.go#L25-L62 |
27,143 | Shopify/ejson | crypto/crypto.go | NewEncrypter | func NewEncrypter(kp *Keypair, peerPublic [32]byte) *Encrypter {
var shared [32]byte
box.Precompute(&shared, &peerPublic, &kp.Private)
return &Encrypter{
Keypair: kp,
PeerPublic: peerPublic,
SharedKey: shared,
}
} | go | func NewEncrypter(kp *Keypair, peerPublic [32]byte) *Encrypter {
var shared [32]byte
box.Precompute(&shared, &peerPublic, &kp.Private)
return &Encrypter{
Keypair: kp,
PeerPublic: peerPublic,
SharedKey: shared,
}
} | [
"func",
"NewEncrypter",
"(",
"kp",
"*",
"Keypair",
",",
"peerPublic",
"[",
"32",
"]",
"byte",
")",
"*",
"Encrypter",
"{",
"var",
"shared",
"[",
"32",
"]",
"byte",
"\n",
"box",
".",
"Precompute",
"(",
"&",
"shared",
",",
"&",
"peerPublic",
",",
"&",
... | // NewEncrypter instantiates an Encrypter after pre-computing the shared key for
// the owned keypair and the given decrypter public key. | [
"NewEncrypter",
"instantiates",
"an",
"Encrypter",
"after",
"pre",
"-",
"computing",
"the",
"shared",
"key",
"for",
"the",
"owned",
"keypair",
"and",
"the",
"given",
"decrypter",
"public",
"key",
"."
] | 9d2ed221270221cf82616946316a0a62dca4a4a9 | https://github.com/Shopify/ejson/blob/9d2ed221270221cf82616946316a0a62dca4a4a9/crypto/crypto.go#L88-L96 |
27,144 | soheilhy/cmux | cmux.go | New | func New(l net.Listener) CMux {
return &cMux{
root: l,
bufLen: 1024,
errh: func(_ error) bool { return true },
donec: make(chan struct{}),
readTimeout: noTimeout,
}
} | go | func New(l net.Listener) CMux {
return &cMux{
root: l,
bufLen: 1024,
errh: func(_ error) bool { return true },
donec: make(chan struct{}),
readTimeout: noTimeout,
}
} | [
"func",
"New",
"(",
"l",
"net",
".",
"Listener",
")",
"CMux",
"{",
"return",
"&",
"cMux",
"{",
"root",
":",
"l",
",",
"bufLen",
":",
"1024",
",",
"errh",
":",
"func",
"(",
"_",
"error",
")",
"bool",
"{",
"return",
"true",
"}",
",",
"donec",
":"... | // New instantiates a new connection multiplexer. | [
"New",
"instantiates",
"a",
"new",
"connection",
"multiplexer",
"."
] | 8a8ea3c53959009183d7914522833c1ed8835020 | https://github.com/soheilhy/cmux/blob/8a8ea3c53959009183d7914522833c1ed8835020/cmux.go#L68-L76 |
27,145 | soheilhy/cmux | matchers.go | HTTP1 | func HTTP1() Matcher {
return func(r io.Reader) bool {
br := bufio.NewReader(&io.LimitedReader{R: r, N: maxHTTPRead})
l, part, err := br.ReadLine()
if err != nil || part {
return false
}
_, _, proto, ok := parseRequestLine(string(l))
if !ok {
return false
}
v, _, ok := http.ParseHTTPVersion(pro... | go | func HTTP1() Matcher {
return func(r io.Reader) bool {
br := bufio.NewReader(&io.LimitedReader{R: r, N: maxHTTPRead})
l, part, err := br.ReadLine()
if err != nil || part {
return false
}
_, _, proto, ok := parseRequestLine(string(l))
if !ok {
return false
}
v, _, ok := http.ParseHTTPVersion(pro... | [
"func",
"HTTP1",
"(",
")",
"Matcher",
"{",
"return",
"func",
"(",
"r",
"io",
".",
"Reader",
")",
"bool",
"{",
"br",
":=",
"bufio",
".",
"NewReader",
"(",
"&",
"io",
".",
"LimitedReader",
"{",
"R",
":",
"r",
",",
"N",
":",
"maxHTTPRead",
"}",
")",... | // HTTP1 parses the first line or upto 4096 bytes of the request to see if
// the conection contains an HTTP request. | [
"HTTP1",
"parses",
"the",
"first",
"line",
"or",
"upto",
"4096",
"bytes",
"of",
"the",
"request",
"to",
"see",
"if",
"the",
"conection",
"contains",
"an",
"HTTP",
"request",
"."
] | 8a8ea3c53959009183d7914522833c1ed8835020 | https://github.com/soheilhy/cmux/blob/8a8ea3c53959009183d7914522833c1ed8835020/matchers.go#L91-L107 |
27,146 | soheilhy/cmux | matchers.go | HTTP1HeaderField | func HTTP1HeaderField(name, value string) Matcher {
return func(r io.Reader) bool {
return matchHTTP1Field(r, name, func(gotValue string) bool {
return gotValue == value
})
}
} | go | func HTTP1HeaderField(name, value string) Matcher {
return func(r io.Reader) bool {
return matchHTTP1Field(r, name, func(gotValue string) bool {
return gotValue == value
})
}
} | [
"func",
"HTTP1HeaderField",
"(",
"name",
",",
"value",
"string",
")",
"Matcher",
"{",
"return",
"func",
"(",
"r",
"io",
".",
"Reader",
")",
"bool",
"{",
"return",
"matchHTTP1Field",
"(",
"r",
",",
"name",
",",
"func",
"(",
"gotValue",
"string",
")",
"b... | // HTTP1HeaderField returns a matcher matching the header fields of the first
// request of an HTTP 1 connection. | [
"HTTP1HeaderField",
"returns",
"a",
"matcher",
"matching",
"the",
"header",
"fields",
"of",
"the",
"first",
"request",
"of",
"an",
"HTTP",
"1",
"connection",
"."
] | 8a8ea3c53959009183d7914522833c1ed8835020 | https://github.com/soheilhy/cmux/blob/8a8ea3c53959009183d7914522833c1ed8835020/matchers.go#L128-L134 |
27,147 | soheilhy/cmux | matchers.go | HTTP1HeaderFieldPrefix | func HTTP1HeaderFieldPrefix(name, valuePrefix string) Matcher {
return func(r io.Reader) bool {
return matchHTTP1Field(r, name, func(gotValue string) bool {
return strings.HasPrefix(gotValue, valuePrefix)
})
}
} | go | func HTTP1HeaderFieldPrefix(name, valuePrefix string) Matcher {
return func(r io.Reader) bool {
return matchHTTP1Field(r, name, func(gotValue string) bool {
return strings.HasPrefix(gotValue, valuePrefix)
})
}
} | [
"func",
"HTTP1HeaderFieldPrefix",
"(",
"name",
",",
"valuePrefix",
"string",
")",
"Matcher",
"{",
"return",
"func",
"(",
"r",
"io",
".",
"Reader",
")",
"bool",
"{",
"return",
"matchHTTP1Field",
"(",
"r",
",",
"name",
",",
"func",
"(",
"gotValue",
"string",... | // HTTP1HeaderFieldPrefix returns a matcher matching the header fields of the
// first request of an HTTP 1 connection. If the header with key name has a
// value prefixed with valuePrefix, this will match. | [
"HTTP1HeaderFieldPrefix",
"returns",
"a",
"matcher",
"matching",
"the",
"header",
"fields",
"of",
"the",
"first",
"request",
"of",
"an",
"HTTP",
"1",
"connection",
".",
"If",
"the",
"header",
"with",
"key",
"name",
"has",
"a",
"value",
"prefixed",
"with",
"v... | 8a8ea3c53959009183d7914522833c1ed8835020 | https://github.com/soheilhy/cmux/blob/8a8ea3c53959009183d7914522833c1ed8835020/matchers.go#L139-L145 |
27,148 | soheilhy/cmux | matchers.go | HTTP2HeaderField | func HTTP2HeaderField(name, value string) Matcher {
return func(r io.Reader) bool {
return matchHTTP2Field(ioutil.Discard, r, name, func(gotValue string) bool {
return gotValue == value
})
}
} | go | func HTTP2HeaderField(name, value string) Matcher {
return func(r io.Reader) bool {
return matchHTTP2Field(ioutil.Discard, r, name, func(gotValue string) bool {
return gotValue == value
})
}
} | [
"func",
"HTTP2HeaderField",
"(",
"name",
",",
"value",
"string",
")",
"Matcher",
"{",
"return",
"func",
"(",
"r",
"io",
".",
"Reader",
")",
"bool",
"{",
"return",
"matchHTTP2Field",
"(",
"ioutil",
".",
"Discard",
",",
"r",
",",
"name",
",",
"func",
"("... | // HTTP2HeaderField returns a matcher matching the header fields of the first
// headers frame. | [
"HTTP2HeaderField",
"returns",
"a",
"matcher",
"matching",
"the",
"header",
"fields",
"of",
"the",
"first",
"headers",
"frame",
"."
] | 8a8ea3c53959009183d7914522833c1ed8835020 | https://github.com/soheilhy/cmux/blob/8a8ea3c53959009183d7914522833c1ed8835020/matchers.go#L149-L155 |
27,149 | soheilhy/cmux | matchers.go | HTTP2HeaderFieldPrefix | func HTTP2HeaderFieldPrefix(name, valuePrefix string) Matcher {
return func(r io.Reader) bool {
return matchHTTP2Field(ioutil.Discard, r, name, func(gotValue string) bool {
return strings.HasPrefix(gotValue, valuePrefix)
})
}
} | go | func HTTP2HeaderFieldPrefix(name, valuePrefix string) Matcher {
return func(r io.Reader) bool {
return matchHTTP2Field(ioutil.Discard, r, name, func(gotValue string) bool {
return strings.HasPrefix(gotValue, valuePrefix)
})
}
} | [
"func",
"HTTP2HeaderFieldPrefix",
"(",
"name",
",",
"valuePrefix",
"string",
")",
"Matcher",
"{",
"return",
"func",
"(",
"r",
"io",
".",
"Reader",
")",
"bool",
"{",
"return",
"matchHTTP2Field",
"(",
"ioutil",
".",
"Discard",
",",
"r",
",",
"name",
",",
"... | // HTTP2HeaderFieldPrefix returns a matcher matching the header fields of the
// first headers frame. If the header with key name has a value prefixed with
// valuePrefix, this will match. | [
"HTTP2HeaderFieldPrefix",
"returns",
"a",
"matcher",
"matching",
"the",
"header",
"fields",
"of",
"the",
"first",
"headers",
"frame",
".",
"If",
"the",
"header",
"with",
"key",
"name",
"has",
"a",
"value",
"prefixed",
"with",
"valuePrefix",
"this",
"will",
"ma... | 8a8ea3c53959009183d7914522833c1ed8835020 | https://github.com/soheilhy/cmux/blob/8a8ea3c53959009183d7914522833c1ed8835020/matchers.go#L160-L166 |
27,150 | soheilhy/cmux | matchers.go | HTTP2MatchHeaderFieldSendSettings | func HTTP2MatchHeaderFieldSendSettings(name, value string) MatchWriter {
return func(w io.Writer, r io.Reader) bool {
return matchHTTP2Field(w, r, name, func(gotValue string) bool {
return gotValue == value
})
}
} | go | func HTTP2MatchHeaderFieldSendSettings(name, value string) MatchWriter {
return func(w io.Writer, r io.Reader) bool {
return matchHTTP2Field(w, r, name, func(gotValue string) bool {
return gotValue == value
})
}
} | [
"func",
"HTTP2MatchHeaderFieldSendSettings",
"(",
"name",
",",
"value",
"string",
")",
"MatchWriter",
"{",
"return",
"func",
"(",
"w",
"io",
".",
"Writer",
",",
"r",
"io",
".",
"Reader",
")",
"bool",
"{",
"return",
"matchHTTP2Field",
"(",
"w",
",",
"r",
... | // HTTP2MatchHeaderFieldSendSettings matches the header field and writes the
// settings to the server. Prefer HTTP2HeaderField over this one, if the client
// does not block on receiving a SETTING frame. | [
"HTTP2MatchHeaderFieldSendSettings",
"matches",
"the",
"header",
"field",
"and",
"writes",
"the",
"settings",
"to",
"the",
"server",
".",
"Prefer",
"HTTP2HeaderField",
"over",
"this",
"one",
"if",
"the",
"client",
"does",
"not",
"block",
"on",
"receiving",
"a",
... | 8a8ea3c53959009183d7914522833c1ed8835020 | https://github.com/soheilhy/cmux/blob/8a8ea3c53959009183d7914522833c1ed8835020/matchers.go#L171-L177 |
27,151 | soheilhy/cmux | matchers.go | HTTP2MatchHeaderFieldPrefixSendSettings | func HTTP2MatchHeaderFieldPrefixSendSettings(name, valuePrefix string) MatchWriter {
return func(w io.Writer, r io.Reader) bool {
return matchHTTP2Field(w, r, name, func(gotValue string) bool {
return strings.HasPrefix(gotValue, valuePrefix)
})
}
} | go | func HTTP2MatchHeaderFieldPrefixSendSettings(name, valuePrefix string) MatchWriter {
return func(w io.Writer, r io.Reader) bool {
return matchHTTP2Field(w, r, name, func(gotValue string) bool {
return strings.HasPrefix(gotValue, valuePrefix)
})
}
} | [
"func",
"HTTP2MatchHeaderFieldPrefixSendSettings",
"(",
"name",
",",
"valuePrefix",
"string",
")",
"MatchWriter",
"{",
"return",
"func",
"(",
"w",
"io",
".",
"Writer",
",",
"r",
"io",
".",
"Reader",
")",
"bool",
"{",
"return",
"matchHTTP2Field",
"(",
"w",
",... | // HTTP2MatchHeaderFieldPrefixSendSettings matches the header field prefix
// and writes the settings to the server. Prefer HTTP2HeaderFieldPrefix over
// this one, if the client does not block on receiving a SETTING frame. | [
"HTTP2MatchHeaderFieldPrefixSendSettings",
"matches",
"the",
"header",
"field",
"prefix",
"and",
"writes",
"the",
"settings",
"to",
"the",
"server",
".",
"Prefer",
"HTTP2HeaderFieldPrefix",
"over",
"this",
"one",
"if",
"the",
"client",
"does",
"not",
"block",
"on",
... | 8a8ea3c53959009183d7914522833c1ed8835020 | https://github.com/soheilhy/cmux/blob/8a8ea3c53959009183d7914522833c1ed8835020/matchers.go#L182-L188 |
27,152 | getlantern/systray | systray_windows.go | SetTooltip | func SetTooltip(tooltip string) {
if err := wt.setTooltip(tooltip); err != nil {
log.Errorf("Unable to set tooltip: %v", err)
return
}
} | go | func SetTooltip(tooltip string) {
if err := wt.setTooltip(tooltip); err != nil {
log.Errorf("Unable to set tooltip: %v", err)
return
}
} | [
"func",
"SetTooltip",
"(",
"tooltip",
"string",
")",
"{",
"if",
"err",
":=",
"wt",
".",
"setTooltip",
"(",
"tooltip",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"}"
... | // SetTooltip sets the systray tooltip to display on mouse hover of the tray icon,
// only available on Mac and Windows. | [
"SetTooltip",
"sets",
"the",
"systray",
"tooltip",
"to",
"display",
"on",
"mouse",
"hover",
"of",
"the",
"tray",
"icon",
"only",
"available",
"on",
"Mac",
"and",
"Windows",
"."
] | 26d5b920200dbc1869c4bfde4571497082f83caa | https://github.com/getlantern/systray/blob/26d5b920200dbc1869c4bfde4571497082f83caa/systray_windows.go#L688-L693 |
27,153 | getlantern/systray | systray.go | AddMenuItem | func AddMenuItem(title string, tooltip string) *MenuItem {
id := atomic.AddInt32(¤tID, 1)
item := &MenuItem{nil, id, title, tooltip, false, false}
item.ClickedCh = make(chan struct{})
item.update()
return item
} | go | func AddMenuItem(title string, tooltip string) *MenuItem {
id := atomic.AddInt32(¤tID, 1)
item := &MenuItem{nil, id, title, tooltip, false, false}
item.ClickedCh = make(chan struct{})
item.update()
return item
} | [
"func",
"AddMenuItem",
"(",
"title",
"string",
",",
"tooltip",
"string",
")",
"*",
"MenuItem",
"{",
"id",
":=",
"atomic",
".",
"AddInt32",
"(",
"&",
"currentID",
",",
"1",
")",
"\n",
"item",
":=",
"&",
"MenuItem",
"{",
"nil",
",",
"id",
",",
"title",... | // AddMenuItem adds menu item with designated title and tooltip, returning a channel
// that notifies whenever that menu item is clicked.
//
// It can be safely invoked from different goroutines. | [
"AddMenuItem",
"adds",
"menu",
"item",
"with",
"designated",
"title",
"and",
"tooltip",
"returning",
"a",
"channel",
"that",
"notifies",
"whenever",
"that",
"menu",
"item",
"is",
"clicked",
".",
"It",
"can",
"be",
"safely",
"invoked",
"from",
"different",
"gor... | 26d5b920200dbc1869c4bfde4571497082f83caa | https://github.com/getlantern/systray/blob/26d5b920200dbc1869c4bfde4571497082f83caa/systray.go#L95-L101 |
27,154 | getlantern/systray | systray.go | SetTitle | func (item *MenuItem) SetTitle(title string) {
item.title = title
item.update()
} | go | func (item *MenuItem) SetTitle(title string) {
item.title = title
item.update()
} | [
"func",
"(",
"item",
"*",
"MenuItem",
")",
"SetTitle",
"(",
"title",
"string",
")",
"{",
"item",
".",
"title",
"=",
"title",
"\n",
"item",
".",
"update",
"(",
")",
"\n",
"}"
] | // SetTitle set the text to display on a menu item | [
"SetTitle",
"set",
"the",
"text",
"to",
"display",
"on",
"a",
"menu",
"item"
] | 26d5b920200dbc1869c4bfde4571497082f83caa | https://github.com/getlantern/systray/blob/26d5b920200dbc1869c4bfde4571497082f83caa/systray.go#L109-L112 |
27,155 | getlantern/systray | systray.go | SetTooltip | func (item *MenuItem) SetTooltip(tooltip string) {
item.tooltip = tooltip
item.update()
} | go | func (item *MenuItem) SetTooltip(tooltip string) {
item.tooltip = tooltip
item.update()
} | [
"func",
"(",
"item",
"*",
"MenuItem",
")",
"SetTooltip",
"(",
"tooltip",
"string",
")",
"{",
"item",
".",
"tooltip",
"=",
"tooltip",
"\n",
"item",
".",
"update",
"(",
")",
"\n",
"}"
] | // SetTooltip set the tooltip to show when mouse hover | [
"SetTooltip",
"set",
"the",
"tooltip",
"to",
"show",
"when",
"mouse",
"hover"
] | 26d5b920200dbc1869c4bfde4571497082f83caa | https://github.com/getlantern/systray/blob/26d5b920200dbc1869c4bfde4571497082f83caa/systray.go#L115-L118 |
27,156 | getlantern/systray | systray.go | update | func (item *MenuItem) update() {
menuItemsLock.Lock()
defer menuItemsLock.Unlock()
menuItems[item.id] = item
addOrUpdateMenuItem(item)
} | go | func (item *MenuItem) update() {
menuItemsLock.Lock()
defer menuItemsLock.Unlock()
menuItems[item.id] = item
addOrUpdateMenuItem(item)
} | [
"func",
"(",
"item",
"*",
"MenuItem",
")",
"update",
"(",
")",
"{",
"menuItemsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"menuItemsLock",
".",
"Unlock",
"(",
")",
"\n",
"menuItems",
"[",
"item",
".",
"id",
"]",
"=",
"item",
"\n",
"addOrUpdateMenuItem... | // update propogates changes on a menu item to systray | [
"update",
"propogates",
"changes",
"on",
"a",
"menu",
"item",
"to",
"systray"
] | 26d5b920200dbc1869c4bfde4571497082f83caa | https://github.com/getlantern/systray/blob/26d5b920200dbc1869c4bfde4571497082f83caa/systray.go#L165-L170 |
27,157 | go-redsync/redsync | redsync.go | NewMutex | func (r *Redsync) NewMutex(name string, options ...Option) *Mutex {
m := &Mutex{
name: name,
expiry: 8 * time.Second,
tries: 32,
delayFunc: func(tries int) time.Duration { return 500 * time.Millisecond },
genValueFunc: genValue,
factor: 0.01,
quorum: len(r.pools)/2 + 1... | go | func (r *Redsync) NewMutex(name string, options ...Option) *Mutex {
m := &Mutex{
name: name,
expiry: 8 * time.Second,
tries: 32,
delayFunc: func(tries int) time.Duration { return 500 * time.Millisecond },
genValueFunc: genValue,
factor: 0.01,
quorum: len(r.pools)/2 + 1... | [
"func",
"(",
"r",
"*",
"Redsync",
")",
"NewMutex",
"(",
"name",
"string",
",",
"options",
"...",
"Option",
")",
"*",
"Mutex",
"{",
"m",
":=",
"&",
"Mutex",
"{",
"name",
":",
"name",
",",
"expiry",
":",
"8",
"*",
"time",
".",
"Second",
",",
"tries... | // NewMutex returns a new distributed mutex with given name. | [
"NewMutex",
"returns",
"a",
"new",
"distributed",
"mutex",
"with",
"given",
"name",
"."
] | aba0a125bc554b826ae0f194e00af531c967bcd6 | https://github.com/go-redsync/redsync/blob/aba0a125bc554b826ae0f194e00af531c967bcd6/redsync.go#L18-L33 |
27,158 | go-redsync/redsync | redsync.go | SetExpiry | func SetExpiry(expiry time.Duration) Option {
return OptionFunc(func(m *Mutex) {
m.expiry = expiry
})
} | go | func SetExpiry(expiry time.Duration) Option {
return OptionFunc(func(m *Mutex) {
m.expiry = expiry
})
} | [
"func",
"SetExpiry",
"(",
"expiry",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"OptionFunc",
"(",
"func",
"(",
"m",
"*",
"Mutex",
")",
"{",
"m",
".",
"expiry",
"=",
"expiry",
"\n",
"}",
")",
"\n",
"}"
] | // SetExpiry can be used to set the expiry of a mutex to the given value. | [
"SetExpiry",
"can",
"be",
"used",
"to",
"set",
"the",
"expiry",
"of",
"a",
"mutex",
"to",
"the",
"given",
"value",
"."
] | aba0a125bc554b826ae0f194e00af531c967bcd6 | https://github.com/go-redsync/redsync/blob/aba0a125bc554b826ae0f194e00af531c967bcd6/redsync.go#L49-L53 |
27,159 | go-redsync/redsync | redsync.go | SetTries | func SetTries(tries int) Option {
return OptionFunc(func(m *Mutex) {
m.tries = tries
})
} | go | func SetTries(tries int) Option {
return OptionFunc(func(m *Mutex) {
m.tries = tries
})
} | [
"func",
"SetTries",
"(",
"tries",
"int",
")",
"Option",
"{",
"return",
"OptionFunc",
"(",
"func",
"(",
"m",
"*",
"Mutex",
")",
"{",
"m",
".",
"tries",
"=",
"tries",
"\n",
"}",
")",
"\n",
"}"
] | // SetTries can be used to set the number of times lock acquire is attempted. | [
"SetTries",
"can",
"be",
"used",
"to",
"set",
"the",
"number",
"of",
"times",
"lock",
"acquire",
"is",
"attempted",
"."
] | aba0a125bc554b826ae0f194e00af531c967bcd6 | https://github.com/go-redsync/redsync/blob/aba0a125bc554b826ae0f194e00af531c967bcd6/redsync.go#L56-L60 |
27,160 | go-redsync/redsync | redsync.go | SetRetryDelay | func SetRetryDelay(delay time.Duration) Option {
return OptionFunc(func(m *Mutex) {
m.delayFunc = func(tries int) time.Duration {
return delay
}
})
} | go | func SetRetryDelay(delay time.Duration) Option {
return OptionFunc(func(m *Mutex) {
m.delayFunc = func(tries int) time.Duration {
return delay
}
})
} | [
"func",
"SetRetryDelay",
"(",
"delay",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"OptionFunc",
"(",
"func",
"(",
"m",
"*",
"Mutex",
")",
"{",
"m",
".",
"delayFunc",
"=",
"func",
"(",
"tries",
"int",
")",
"time",
".",
"Duration",
"{",
"re... | // SetRetryDelay can be used to set the amount of time to wait between retries. | [
"SetRetryDelay",
"can",
"be",
"used",
"to",
"set",
"the",
"amount",
"of",
"time",
"to",
"wait",
"between",
"retries",
"."
] | aba0a125bc554b826ae0f194e00af531c967bcd6 | https://github.com/go-redsync/redsync/blob/aba0a125bc554b826ae0f194e00af531c967bcd6/redsync.go#L63-L69 |
27,161 | go-redsync/redsync | redsync.go | SetRetryDelayFunc | func SetRetryDelayFunc(delayFunc DelayFunc) Option {
return OptionFunc(func(m *Mutex) {
m.delayFunc = delayFunc
})
} | go | func SetRetryDelayFunc(delayFunc DelayFunc) Option {
return OptionFunc(func(m *Mutex) {
m.delayFunc = delayFunc
})
} | [
"func",
"SetRetryDelayFunc",
"(",
"delayFunc",
"DelayFunc",
")",
"Option",
"{",
"return",
"OptionFunc",
"(",
"func",
"(",
"m",
"*",
"Mutex",
")",
"{",
"m",
".",
"delayFunc",
"=",
"delayFunc",
"\n",
"}",
")",
"\n",
"}"
] | // SetRetryDelayFunc can be used to override default delay behavior. | [
"SetRetryDelayFunc",
"can",
"be",
"used",
"to",
"override",
"default",
"delay",
"behavior",
"."
] | aba0a125bc554b826ae0f194e00af531c967bcd6 | https://github.com/go-redsync/redsync/blob/aba0a125bc554b826ae0f194e00af531c967bcd6/redsync.go#L72-L76 |
27,162 | go-redsync/redsync | redsync.go | SetDriftFactor | func SetDriftFactor(factor float64) Option {
return OptionFunc(func(m *Mutex) {
m.factor = factor
})
} | go | func SetDriftFactor(factor float64) Option {
return OptionFunc(func(m *Mutex) {
m.factor = factor
})
} | [
"func",
"SetDriftFactor",
"(",
"factor",
"float64",
")",
"Option",
"{",
"return",
"OptionFunc",
"(",
"func",
"(",
"m",
"*",
"Mutex",
")",
"{",
"m",
".",
"factor",
"=",
"factor",
"\n",
"}",
")",
"\n",
"}"
] | // SetDriftFactor can be used to set the clock drift factor. | [
"SetDriftFactor",
"can",
"be",
"used",
"to",
"set",
"the",
"clock",
"drift",
"factor",
"."
] | aba0a125bc554b826ae0f194e00af531c967bcd6 | https://github.com/go-redsync/redsync/blob/aba0a125bc554b826ae0f194e00af531c967bcd6/redsync.go#L79-L83 |
27,163 | go-redsync/redsync | redsync.go | SetGenValueFunc | func SetGenValueFunc(genValueFunc func() (string, error)) Option {
return OptionFunc(func(m *Mutex) {
m.genValueFunc = genValueFunc
})
} | go | func SetGenValueFunc(genValueFunc func() (string, error)) Option {
return OptionFunc(func(m *Mutex) {
m.genValueFunc = genValueFunc
})
} | [
"func",
"SetGenValueFunc",
"(",
"genValueFunc",
"func",
"(",
")",
"(",
"string",
",",
"error",
")",
")",
"Option",
"{",
"return",
"OptionFunc",
"(",
"func",
"(",
"m",
"*",
"Mutex",
")",
"{",
"m",
".",
"genValueFunc",
"=",
"genValueFunc",
"\n",
"}",
")"... | // SetGenValueFunc can be used to set the custom value generator. | [
"SetGenValueFunc",
"can",
"be",
"used",
"to",
"set",
"the",
"custom",
"value",
"generator",
"."
] | aba0a125bc554b826ae0f194e00af531c967bcd6 | https://github.com/go-redsync/redsync/blob/aba0a125bc554b826ae0f194e00af531c967bcd6/redsync.go#L86-L90 |
27,164 | go-redsync/redsync | mutex.go | Unlock | func (m *Mutex) Unlock() bool {
n := m.actOnPoolsAsync(func(pool Pool) bool {
return m.release(pool, m.value)
})
return n >= m.quorum
} | go | func (m *Mutex) Unlock() bool {
n := m.actOnPoolsAsync(func(pool Pool) bool {
return m.release(pool, m.value)
})
return n >= m.quorum
} | [
"func",
"(",
"m",
"*",
"Mutex",
")",
"Unlock",
"(",
")",
"bool",
"{",
"n",
":=",
"m",
".",
"actOnPoolsAsync",
"(",
"func",
"(",
"pool",
"Pool",
")",
"bool",
"{",
"return",
"m",
".",
"release",
"(",
"pool",
",",
"m",
".",
"value",
")",
"\n",
"}"... | // Unlock unlocks m and returns the status of unlock. | [
"Unlock",
"unlocks",
"m",
"and",
"returns",
"the",
"status",
"of",
"unlock",
"."
] | aba0a125bc554b826ae0f194e00af531c967bcd6 | https://github.com/go-redsync/redsync/blob/aba0a125bc554b826ae0f194e00af531c967bcd6/mutex.go#L66-L71 |
27,165 | go-redsync/redsync | mutex.go | Extend | func (m *Mutex) Extend() bool {
n := m.actOnPoolsAsync(func(pool Pool) bool {
return m.touch(pool, m.value, int(m.expiry/time.Millisecond))
})
return n >= m.quorum
} | go | func (m *Mutex) Extend() bool {
n := m.actOnPoolsAsync(func(pool Pool) bool {
return m.touch(pool, m.value, int(m.expiry/time.Millisecond))
})
return n >= m.quorum
} | [
"func",
"(",
"m",
"*",
"Mutex",
")",
"Extend",
"(",
")",
"bool",
"{",
"n",
":=",
"m",
".",
"actOnPoolsAsync",
"(",
"func",
"(",
"pool",
"Pool",
")",
"bool",
"{",
"return",
"m",
".",
"touch",
"(",
"pool",
",",
"m",
".",
"value",
",",
"int",
"(",... | // Extend resets the mutex's expiry and returns the status of expiry extension. | [
"Extend",
"resets",
"the",
"mutex",
"s",
"expiry",
"and",
"returns",
"the",
"status",
"of",
"expiry",
"extension",
"."
] | aba0a125bc554b826ae0f194e00af531c967bcd6 | https://github.com/go-redsync/redsync/blob/aba0a125bc554b826ae0f194e00af531c967bcd6/mutex.go#L74-L79 |
27,166 | cesanta/docker_auth | auth_server/authn/tokendb.go | NewTokenDB | func NewTokenDB(file string) (TokenDB, error) {
db, err := leveldb.OpenFile(file, nil)
return &TokenDBImpl{
DB: db,
}, err
} | go | func NewTokenDB(file string) (TokenDB, error) {
db, err := leveldb.OpenFile(file, nil)
return &TokenDBImpl{
DB: db,
}, err
} | [
"func",
"NewTokenDB",
"(",
"file",
"string",
")",
"(",
"TokenDB",
",",
"error",
")",
"{",
"db",
",",
"err",
":=",
"leveldb",
".",
"OpenFile",
"(",
"file",
",",
"nil",
")",
"\n",
"return",
"&",
"TokenDBImpl",
"{",
"DB",
":",
"db",
",",
"}",
",",
"... | // NewTokenDB returns a new TokenDB structure | [
"NewTokenDB",
"returns",
"a",
"new",
"TokenDB",
"structure"
] | b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf | https://github.com/cesanta/docker_auth/blob/b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf/auth_server/authn/tokendb.go#L77-L82 |
27,167 | cesanta/docker_auth | auth_server/authz/acl_mongo.go | NewACLMongoAuthorizer | func NewACLMongoAuthorizer(c *ACLMongoConfig) (Authorizer, error) {
// Attempt to create new MongoDB session.
session, err := mgo_session.New(c.MongoConfig)
if err != nil {
return nil, err
}
authorizer := &aclMongoAuthorizer{
config: c,
session: session,
updateTicker: time.NewTicker(c.CacheTTL)... | go | func NewACLMongoAuthorizer(c *ACLMongoConfig) (Authorizer, error) {
// Attempt to create new MongoDB session.
session, err := mgo_session.New(c.MongoConfig)
if err != nil {
return nil, err
}
authorizer := &aclMongoAuthorizer{
config: c,
session: session,
updateTicker: time.NewTicker(c.CacheTTL)... | [
"func",
"NewACLMongoAuthorizer",
"(",
"c",
"*",
"ACLMongoConfig",
")",
"(",
"Authorizer",
",",
"error",
")",
"{",
"// Attempt to create new MongoDB session.",
"session",
",",
"err",
":=",
"mgo_session",
".",
"New",
"(",
"c",
".",
"MongoConfig",
")",
"\n",
"if",
... | // NewACLMongoAuthorizer creates a new ACL MongoDB authorizer | [
"NewACLMongoAuthorizer",
"creates",
"a",
"new",
"ACL",
"MongoDB",
"authorizer"
] | b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf | https://github.com/cesanta/docker_auth/blob/b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf/auth_server/authz/acl_mongo.go#L40-L61 |
27,168 | cesanta/docker_auth | auth_server/authz/acl_mongo.go | continuouslyUpdateACLCache | func (ma *aclMongoAuthorizer) continuouslyUpdateACLCache() {
var tick time.Time
for ; true; tick = <-ma.updateTicker.C {
aclAge := time.Now().Sub(ma.lastCacheUpdate)
glog.V(2).Infof("Updating ACL at %s (ACL age: %s. CacheTTL: %s)", tick, aclAge, ma.config.CacheTTL)
for true {
err := ma.updateACLCache()
i... | go | func (ma *aclMongoAuthorizer) continuouslyUpdateACLCache() {
var tick time.Time
for ; true; tick = <-ma.updateTicker.C {
aclAge := time.Now().Sub(ma.lastCacheUpdate)
glog.V(2).Infof("Updating ACL at %s (ACL age: %s. CacheTTL: %s)", tick, aclAge, ma.config.CacheTTL)
for true {
err := ma.updateACLCache()
i... | [
"func",
"(",
"ma",
"*",
"aclMongoAuthorizer",
")",
"continuouslyUpdateACLCache",
"(",
")",
"{",
"var",
"tick",
"time",
".",
"Time",
"\n",
"for",
";",
"true",
";",
"tick",
"=",
"<-",
"ma",
".",
"updateTicker",
".",
"C",
"{",
"aclAge",
":=",
"time",
".",... | // continuouslyUpdateACLCache checks if the ACL cache has expired and depending
// on the the result it updates the cache with the ACL from the MongoDB server.
// The ACL will be stored inside the static authorizer instance which we use
// to minimize duplication of code and maximize reuse of existing code. | [
"continuouslyUpdateACLCache",
"checks",
"if",
"the",
"ACL",
"cache",
"has",
"expired",
"and",
"depending",
"on",
"the",
"the",
"result",
"it",
"updates",
"the",
"cache",
"with",
"the",
"ACL",
"from",
"the",
"MongoDB",
"server",
".",
"The",
"ACL",
"will",
"be... | b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf | https://github.com/cesanta/docker_auth/blob/b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf/auth_server/authz/acl_mongo.go#L112-L133 |
27,169 | cesanta/docker_auth | auth_server/mgo_session/mgo_session.go | Validate | func (c *Config) Validate(configKey string) error {
if len(c.DialInfo.Addrs) == 0 {
return fmt.Errorf("At least one element in %s.dial_info.addrs is required", configKey)
}
if c.DialInfo.Timeout == 0 {
c.DialInfo.Timeout = 10 * time.Second
}
if c.DialInfo.Database == "" {
return fmt.Errorf("%s.dial_info.data... | go | func (c *Config) Validate(configKey string) error {
if len(c.DialInfo.Addrs) == 0 {
return fmt.Errorf("At least one element in %s.dial_info.addrs is required", configKey)
}
if c.DialInfo.Timeout == 0 {
c.DialInfo.Timeout = 10 * time.Second
}
if c.DialInfo.Database == "" {
return fmt.Errorf("%s.dial_info.data... | [
"func",
"(",
"c",
"*",
"Config",
")",
"Validate",
"(",
"configKey",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"c",
".",
"DialInfo",
".",
"Addrs",
")",
"==",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"configKey",
")",
"\... | // Validate ensures the most common fields inside the mgo.DialInfo portion of
// a Config are set correctly as well as other fields inside the
// Config itself. | [
"Validate",
"ensures",
"the",
"most",
"common",
"fields",
"inside",
"the",
"mgo",
".",
"DialInfo",
"portion",
"of",
"a",
"Config",
"are",
"set",
"correctly",
"as",
"well",
"as",
"other",
"fields",
"inside",
"the",
"Config",
"itself",
"."
] | b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf | https://github.com/cesanta/docker_auth/blob/b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf/auth_server/mgo_session/mgo_session.go#L41-L52 |
27,170 | cesanta/docker_auth | auth_server/authz/acl.go | NewACLAuthorizer | func NewACLAuthorizer(acl ACL) (Authorizer, error) {
if err := ValidateACL(acl); err != nil {
return nil, err
}
glog.V(1).Infof("Created ACL Authorizer with %d entries", len(acl))
return &aclAuthorizer{acl: acl}, nil
} | go | func NewACLAuthorizer(acl ACL) (Authorizer, error) {
if err := ValidateACL(acl); err != nil {
return nil, err
}
glog.V(1).Infof("Created ACL Authorizer with %d entries", len(acl))
return &aclAuthorizer{acl: acl}, nil
} | [
"func",
"NewACLAuthorizer",
"(",
"acl",
"ACL",
")",
"(",
"Authorizer",
",",
"error",
")",
"{",
"if",
"err",
":=",
"ValidateACL",
"(",
"acl",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"glog",
".",
"V",
"(",
"... | // NewACLAuthorizer Creates a new static authorizer with ACL that have been read from the config file | [
"NewACLAuthorizer",
"Creates",
"a",
"new",
"static",
"authorizer",
"with",
"ACL",
"that",
"have",
"been",
"read",
"from",
"the",
"config",
"file"
] | b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf | https://github.com/cesanta/docker_auth/blob/b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf/auth_server/authz/acl.go#L104-L110 |
27,171 | cesanta/docker_auth | auth_server/authn/ldap_auth.go | ldapSearch | func (la *LDAPAuth) ldapSearch(l *ldap.Conn, baseDN *string, filter *string, attrs *[]string) (string, map[string][]string, error) {
if l == nil {
return "", nil, fmt.Errorf("No ldap connection!")
}
glog.V(2).Infof("Searching...basedDN:%s, filter:%s", *baseDN, *filter)
searchRequest := ldap.NewSearchRequest(
*b... | go | func (la *LDAPAuth) ldapSearch(l *ldap.Conn, baseDN *string, filter *string, attrs *[]string) (string, map[string][]string, error) {
if l == nil {
return "", nil, fmt.Errorf("No ldap connection!")
}
glog.V(2).Infof("Searching...basedDN:%s, filter:%s", *baseDN, *filter)
searchRequest := ldap.NewSearchRequest(
*b... | [
"func",
"(",
"la",
"*",
"LDAPAuth",
")",
"ldapSearch",
"(",
"l",
"*",
"ldap",
".",
"Conn",
",",
"baseDN",
"*",
"string",
",",
"filter",
"*",
"string",
",",
"attrs",
"*",
"[",
"]",
"string",
")",
"(",
"string",
",",
"map",
"[",
"string",
"]",
"[",... | //ldap search and return required attributes' value from searched entries
//default return entry's DN value if you leave attrs array empty | [
"ldap",
"search",
"and",
"return",
"required",
"attributes",
"value",
"from",
"searched",
"entries",
"default",
"return",
"entry",
"s",
"DN",
"value",
"if",
"you",
"leave",
"attrs",
"array",
"empty"
] | b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf | https://github.com/cesanta/docker_auth/blob/b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf/auth_server/authn/ldap_auth.go#L204-L242 |
27,172 | cesanta/docker_auth | auth_server/authn/github_auth.go | removeSubstringsFromString | func removeSubstringsFromString(sourceStr string, stringsToStrip []string) string {
theNewString := sourceStr
for _, i := range stringsToStrip {
theNewString = strings.Replace(theNewString, i, "", -1)
}
return theNewString
} | go | func removeSubstringsFromString(sourceStr string, stringsToStrip []string) string {
theNewString := sourceStr
for _, i := range stringsToStrip {
theNewString = strings.Replace(theNewString, i, "", -1)
}
return theNewString
} | [
"func",
"removeSubstringsFromString",
"(",
"sourceStr",
"string",
",",
"stringsToStrip",
"[",
"]",
"string",
")",
"string",
"{",
"theNewString",
":=",
"sourceStr",
"\n",
"for",
"_",
",",
"i",
":=",
"range",
"stringsToStrip",
"{",
"theNewString",
"=",
"strings",
... | // removeSubstringsFromString removes all occurences of stringsToStrip from sourceStr
// | [
"removeSubstringsFromString",
"removes",
"all",
"occurences",
"of",
"stringsToStrip",
"from",
"sourceStr"
] | b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf | https://github.com/cesanta/docker_auth/blob/b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf/auth_server/authn/github_auth.go#L123-L129 |
27,173 | cesanta/docker_auth | auth_server/authn/tokendb_gcs.go | GetValue | func (db *gcsTokenDB) GetValue(user string) (*TokenDBValue, error) {
rd, err := db.gcs.Bucket(db.bucket).Object(user).NewReader(context.Background())
if err == storage.ErrObjectNotExist {
return nil, nil
}
if err != nil {
return nil, fmt.Errorf("could not retrieved token for user '%s' due: %v", user, err)
}
d... | go | func (db *gcsTokenDB) GetValue(user string) (*TokenDBValue, error) {
rd, err := db.gcs.Bucket(db.bucket).Object(user).NewReader(context.Background())
if err == storage.ErrObjectNotExist {
return nil, nil
}
if err != nil {
return nil, fmt.Errorf("could not retrieved token for user '%s' due: %v", user, err)
}
d... | [
"func",
"(",
"db",
"*",
"gcsTokenDB",
")",
"GetValue",
"(",
"user",
"string",
")",
"(",
"*",
"TokenDBValue",
",",
"error",
")",
"{",
"rd",
",",
"err",
":=",
"db",
".",
"gcs",
".",
"Bucket",
"(",
"db",
".",
"bucket",
")",
".",
"Object",
"(",
"user... | // GetValue gets token value associated with the provided user. Each user
// in the bucket is having it's own file for tokens and it's recomanded bucket
// to not be shared with other apps | [
"GetValue",
"gets",
"token",
"value",
"associated",
"with",
"the",
"provided",
"user",
".",
"Each",
"user",
"in",
"the",
"bucket",
"is",
"having",
"it",
"s",
"own",
"file",
"for",
"tokens",
"and",
"it",
"s",
"recomanded",
"bucket",
"to",
"not",
"be",
"sh... | b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf | https://github.com/cesanta/docker_auth/blob/b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf/auth_server/authn/tokendb_gcs.go#L48-L65 |
27,174 | cesanta/docker_auth | auth_server/authn/tokendb_gcs.go | StoreToken | func (db *gcsTokenDB) StoreToken(user string, v *TokenDBValue, updatePassword bool) (dp string, err error) {
if updatePassword {
dp = uniuri.New()
dph, _ := bcrypt.GenerateFromPassword([]byte(dp), bcrypt.DefaultCost)
v.DockerPassword = string(dph)
}
wr := db.gcs.Bucket(db.bucket).Object(user).NewWriter(contex... | go | func (db *gcsTokenDB) StoreToken(user string, v *TokenDBValue, updatePassword bool) (dp string, err error) {
if updatePassword {
dp = uniuri.New()
dph, _ := bcrypt.GenerateFromPassword([]byte(dp), bcrypt.DefaultCost)
v.DockerPassword = string(dph)
}
wr := db.gcs.Bucket(db.bucket).Object(user).NewWriter(contex... | [
"func",
"(",
"db",
"*",
"gcsTokenDB",
")",
"StoreToken",
"(",
"user",
"string",
",",
"v",
"*",
"TokenDBValue",
",",
"updatePassword",
"bool",
")",
"(",
"dp",
"string",
",",
"err",
"error",
")",
"{",
"if",
"updatePassword",
"{",
"dp",
"=",
"uniuri",
"."... | // StoreToken stores token in the GCS file in a JSON format. Note that separate file is
// used for each user | [
"StoreToken",
"stores",
"token",
"in",
"the",
"GCS",
"file",
"in",
"a",
"JSON",
"format",
".",
"Note",
"that",
"separate",
"file",
"is",
"used",
"for",
"each",
"user"
] | b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf | https://github.com/cesanta/docker_auth/blob/b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf/auth_server/authn/tokendb_gcs.go#L69-L85 |
27,175 | cesanta/docker_auth | auth_server/authn/tokendb_gcs.go | DeleteToken | func (db *gcsTokenDB) DeleteToken(user string) error {
ctx := context.Background()
err := db.gcs.Bucket(db.bucket).Object(user).Delete(ctx)
if err == storage.ErrObjectNotExist {
return nil
}
return err
} | go | func (db *gcsTokenDB) DeleteToken(user string) error {
ctx := context.Background()
err := db.gcs.Bucket(db.bucket).Object(user).Delete(ctx)
if err == storage.ErrObjectNotExist {
return nil
}
return err
} | [
"func",
"(",
"db",
"*",
"gcsTokenDB",
")",
"DeleteToken",
"(",
"user",
"string",
")",
"error",
"{",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n",
"err",
":=",
"db",
".",
"gcs",
".",
"Bucket",
"(",
"db",
".",
"bucket",
")",
".",
"Object... | // DeleteToken deletes the GCS file that is associated with the provided user. | [
"DeleteToken",
"deletes",
"the",
"GCS",
"file",
"that",
"is",
"associated",
"with",
"the",
"provided",
"user",
"."
] | b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf | https://github.com/cesanta/docker_auth/blob/b89dec9a4f0098fb0f71d9b94e44d1710c1fe5cf/auth_server/authn/tokendb_gcs.go#L109-L116 |
27,176 | square/certstrap | depot/depot.go | NewFileDepot | func NewFileDepot(dir string) (*FileDepot, error) {
dirpath, err := filepath.Abs(dir)
if err != nil {
return nil, err
}
return &FileDepot{dirpath}, nil
} | go | func NewFileDepot(dir string) (*FileDepot, error) {
dirpath, err := filepath.Abs(dir)
if err != nil {
return nil, err
}
return &FileDepot{dirpath}, nil
} | [
"func",
"NewFileDepot",
"(",
"dir",
"string",
")",
"(",
"*",
"FileDepot",
",",
"error",
")",
"{",
"dirpath",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"dir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"... | // NewFileDepot creates a new Depot at the specified path | [
"NewFileDepot",
"creates",
"a",
"new",
"Depot",
"at",
"the",
"specified",
"path"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/depot.go#L60-L67 |
27,177 | square/certstrap | depot/depot.go | Put | func (d *FileDepot) Put(tag *Tag, data []byte) error {
if data == nil {
return errors.New("data is nil")
}
if err := os.MkdirAll(d.dirPath, 0755); err != nil {
return err
}
name := d.path(tag.name)
perm := tag.perm
file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm)
if err != nil {
... | go | func (d *FileDepot) Put(tag *Tag, data []byte) error {
if data == nil {
return errors.New("data is nil")
}
if err := os.MkdirAll(d.dirPath, 0755); err != nil {
return err
}
name := d.path(tag.name)
perm := tag.perm
file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm)
if err != nil {
... | [
"func",
"(",
"d",
"*",
"FileDepot",
")",
"Put",
"(",
"tag",
"*",
"Tag",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"data",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":... | // Put inserts the data into the file specified by the tag | [
"Put",
"inserts",
"the",
"data",
"into",
"the",
"file",
"specified",
"by",
"the",
"tag"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/depot.go#L74-L99 |
27,178 | square/certstrap | depot/depot.go | Check | func (d *FileDepot) Check(tag *Tag) bool {
name := d.path(tag.name)
if fi, err := os.Stat(name); err == nil && ^fi.Mode()&tag.perm == 0 {
return true
}
return false
} | go | func (d *FileDepot) Check(tag *Tag) bool {
name := d.path(tag.name)
if fi, err := os.Stat(name); err == nil && ^fi.Mode()&tag.perm == 0 {
return true
}
return false
} | [
"func",
"(",
"d",
"*",
"FileDepot",
")",
"Check",
"(",
"tag",
"*",
"Tag",
")",
"bool",
"{",
"name",
":=",
"d",
".",
"path",
"(",
"tag",
".",
"name",
")",
"\n",
"if",
"fi",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"name",
")",
";",
"err",
"... | // Check returns whether the file at the tag location exists and has the correct permissions | [
"Check",
"returns",
"whether",
"the",
"file",
"at",
"the",
"tag",
"location",
"exists",
"and",
"has",
"the",
"correct",
"permissions"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/depot.go#L102-L108 |
27,179 | square/certstrap | depot/depot.go | Get | func (d *FileDepot) Get(tag *Tag) ([]byte, error) {
if err := d.check(tag); err != nil {
return nil, err
}
return ioutil.ReadFile(d.path(tag.name))
} | go | func (d *FileDepot) Get(tag *Tag) ([]byte, error) {
if err := d.check(tag); err != nil {
return nil, err
}
return ioutil.ReadFile(d.path(tag.name))
} | [
"func",
"(",
"d",
"*",
"FileDepot",
")",
"Get",
"(",
"tag",
"*",
"Tag",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"err",
":=",
"d",
".",
"check",
"(",
"tag",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\... | // Get reads the file specified by the tag | [
"Get",
"reads",
"the",
"file",
"specified",
"by",
"the",
"tag"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/depot.go#L123-L128 |
27,180 | square/certstrap | depot/depot.go | Delete | func (d *FileDepot) Delete(tag *Tag) error {
return os.Remove(d.path(tag.name))
} | go | func (d *FileDepot) Delete(tag *Tag) error {
return os.Remove(d.path(tag.name))
} | [
"func",
"(",
"d",
"*",
"FileDepot",
")",
"Delete",
"(",
"tag",
"*",
"Tag",
")",
"error",
"{",
"return",
"os",
".",
"Remove",
"(",
"d",
".",
"path",
"(",
"tag",
".",
"name",
")",
")",
"\n",
"}"
] | // Delete removes the file specified by the tag | [
"Delete",
"removes",
"the",
"file",
"specified",
"by",
"the",
"tag"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/depot.go#L131-L133 |
27,181 | square/certstrap | depot/depot.go | List | func (d *FileDepot) List() []*Tag {
var tags = make([]*Tag, 0)
filepath.Walk(d.dirPath, func(path string, info os.FileInfo, err error) error {
if err != nil {
return nil
}
if info.IsDir() {
return nil
}
rel, err := filepath.Rel(d.dirPath, path)
if err != nil {
return nil
}
if rel != info.Nam... | go | func (d *FileDepot) List() []*Tag {
var tags = make([]*Tag, 0)
filepath.Walk(d.dirPath, func(path string, info os.FileInfo, err error) error {
if err != nil {
return nil
}
if info.IsDir() {
return nil
}
rel, err := filepath.Rel(d.dirPath, path)
if err != nil {
return nil
}
if rel != info.Nam... | [
"func",
"(",
"d",
"*",
"FileDepot",
")",
"List",
"(",
")",
"[",
"]",
"*",
"Tag",
"{",
"var",
"tags",
"=",
"make",
"(",
"[",
"]",
"*",
"Tag",
",",
"0",
")",
"\n\n",
"filepath",
".",
"Walk",
"(",
"d",
".",
"dirPath",
",",
"func",
"(",
"path",
... | // List returns all tags in the specified depot | [
"List",
"returns",
"all",
"tags",
"in",
"the",
"specified",
"depot"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/depot.go#L136-L158 |
27,182 | square/certstrap | depot/depot.go | GetFile | func (d *FileDepot) GetFile(tag *Tag) (*File, error) {
if err := d.check(tag); err != nil {
return nil, err
}
fi, err := os.Stat(d.path(tag.name))
if err != nil {
return nil, err
}
b, err := ioutil.ReadFile(d.path(tag.name))
return &File{fi, b}, err
} | go | func (d *FileDepot) GetFile(tag *Tag) (*File, error) {
if err := d.check(tag); err != nil {
return nil, err
}
fi, err := os.Stat(d.path(tag.name))
if err != nil {
return nil, err
}
b, err := ioutil.ReadFile(d.path(tag.name))
return &File{fi, b}, err
} | [
"func",
"(",
"d",
"*",
"FileDepot",
")",
"GetFile",
"(",
"tag",
"*",
"Tag",
")",
"(",
"*",
"File",
",",
"error",
")",
"{",
"if",
"err",
":=",
"d",
".",
"check",
"(",
"tag",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",... | // GetFile returns the File at the specified tag in the given depot | [
"GetFile",
"returns",
"the",
"File",
"at",
"the",
"specified",
"tag",
"in",
"the",
"given",
"depot"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/depot.go#L167-L177 |
27,183 | square/certstrap | cmd/revoke.go | NewRevokeCommand | func NewRevokeCommand() cli.Command {
return cli.Command{
Name: "revoke",
Usage: "Revoke certificate",
Description: "Add certificate to the CA's CRL.",
Flags: []cli.Flag{
cli.StringFlag{
Name: "CN",
Usage: "Common Name (CN) of certificate to revoke",
},
cli.StringFlag{
Name: ... | go | func NewRevokeCommand() cli.Command {
return cli.Command{
Name: "revoke",
Usage: "Revoke certificate",
Description: "Add certificate to the CA's CRL.",
Flags: []cli.Flag{
cli.StringFlag{
Name: "CN",
Usage: "Common Name (CN) of certificate to revoke",
},
cli.StringFlag{
Name: ... | [
"func",
"NewRevokeCommand",
"(",
")",
"cli",
".",
"Command",
"{",
"return",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",
"Description",
":",
"\"",
"\"",
",",
"Flags",
":",
"[",
"]",
"cli",
".",
"Flag",
... | // NewRevokeCommand revokes the given certificate by adding it to the CA's CRL. | [
"NewRevokeCommand",
"revokes",
"the",
"given",
"certificate",
"by",
"adding",
"it",
"to",
"the",
"CA",
"s",
"CRL",
"."
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/cmd/revoke.go#L23-L40 |
27,184 | square/certstrap | cmd/sign.go | NewSignCommand | func NewSignCommand() cli.Command {
return cli.Command{
Name: "sign",
Usage: "Sign certificate request",
Description: "Sign certificate request with CA, and generate certificate for the host.",
Flags: []cli.Flag{
cli.StringFlag{
Name: "passphrase",
Usage: "Passphrase to decrypt private... | go | func NewSignCommand() cli.Command {
return cli.Command{
Name: "sign",
Usage: "Sign certificate request",
Description: "Sign certificate request with CA, and generate certificate for the host.",
Flags: []cli.Flag{
cli.StringFlag{
Name: "passphrase",
Usage: "Passphrase to decrypt private... | [
"func",
"NewSignCommand",
"(",
")",
"cli",
".",
"Command",
"{",
"return",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",
"Description",
":",
"\"",
"\"",
",",
"Flags",
":",
"[",
"]",
"cli",
".",
"Flag",
"{... | // NewSignCommand sets up a "sign" command to sign a CSR with a given CA for a new certificate | [
"NewSignCommand",
"sets",
"up",
"a",
"sign",
"command",
"to",
"sign",
"a",
"CSR",
"with",
"a",
"given",
"CA",
"for",
"a",
"new",
"certificate"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/cmd/sign.go#L31-L65 |
27,185 | square/certstrap | pkix/crl.go | NewCertificateRevocationListFromPEM | func NewCertificateRevocationListFromPEM(data []byte) (*CertificateRevocationList, error) {
pemBlock, _ := pem.Decode(data)
if pemBlock == nil {
return nil, errors.New("cannot find the next PEM formatted block")
}
if pemBlock.Type != crlPEMBlockType || len(pemBlock.Headers) != 0 {
return nil, errors.New("unmatc... | go | func NewCertificateRevocationListFromPEM(data []byte) (*CertificateRevocationList, error) {
pemBlock, _ := pem.Decode(data)
if pemBlock == nil {
return nil, errors.New("cannot find the next PEM formatted block")
}
if pemBlock.Type != crlPEMBlockType || len(pemBlock.Headers) != 0 {
return nil, errors.New("unmatc... | [
"func",
"NewCertificateRevocationListFromPEM",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"*",
"CertificateRevocationList",
",",
"error",
")",
"{",
"pemBlock",
",",
"_",
":=",
"pem",
".",
"Decode",
"(",
"data",
")",
"\n",
"if",
"pemBlock",
"==",
"nil",
"{",
... | // NewCertificateRevocationListFromPEM inits CertificateRevocationList from PEM-format bytes | [
"NewCertificateRevocationListFromPEM",
"inits",
"CertificateRevocationList",
"from",
"PEM",
"-",
"format",
"bytes"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/pkix/crl.go#L62-L71 |
27,186 | square/certstrap | pkix/cert.go | NewCertificateFromPEM | func NewCertificateFromPEM(data []byte) (c *Certificate, err error) {
pemBlock, _ := pem.Decode(data)
if pemBlock == nil {
err = errors.New("cannot find the next PEM formatted block")
return
}
if pemBlock.Type != certificatePEMBlockType || len(pemBlock.Headers) != 0 {
err = errors.New("unmatched type or heade... | go | func NewCertificateFromPEM(data []byte) (c *Certificate, err error) {
pemBlock, _ := pem.Decode(data)
if pemBlock == nil {
err = errors.New("cannot find the next PEM formatted block")
return
}
if pemBlock.Type != certificatePEMBlockType || len(pemBlock.Headers) != 0 {
err = errors.New("unmatched type or heade... | [
"func",
"NewCertificateFromPEM",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"c",
"*",
"Certificate",
",",
"err",
"error",
")",
"{",
"pemBlock",
",",
"_",
":=",
"pem",
".",
"Decode",
"(",
"data",
")",
"\n",
"if",
"pemBlock",
"==",
"nil",
"{",
"err",
"... | // NewCertificateFromPEM inits Certificate from PEM-format bytes
// data should contain at most one certificate | [
"NewCertificateFromPEM",
"inits",
"Certificate",
"from",
"PEM",
"-",
"format",
"bytes",
"data",
"should",
"contain",
"at",
"most",
"one",
"certificate"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/pkix/cert.go#L48-L60 |
27,187 | square/certstrap | pkix/cert.go | buildX509Certificate | func (c *Certificate) buildX509Certificate() error {
if c.crt != nil {
return nil
}
crts, err := x509.ParseCertificates(c.derBytes)
if err != nil {
return err
}
if len(crts) != 1 {
return errors.New("unsupported multiple certificates in a block")
}
c.crt = crts[0]
return nil
} | go | func (c *Certificate) buildX509Certificate() error {
if c.crt != nil {
return nil
}
crts, err := x509.ParseCertificates(c.derBytes)
if err != nil {
return err
}
if len(crts) != 1 {
return errors.New("unsupported multiple certificates in a block")
}
c.crt = crts[0]
return nil
} | [
"func",
"(",
"c",
"*",
"Certificate",
")",
"buildX509Certificate",
"(",
")",
"error",
"{",
"if",
"c",
".",
"crt",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"crts",
",",
"err",
":=",
"x509",
".",
"ParseCertificates",
"(",
"c",
".",
"derByt... | // build crt field if needed | [
"build",
"crt",
"field",
"if",
"needed"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/pkix/cert.go#L63-L77 |
27,188 | square/certstrap | pkix/cert.go | GetRawCertificate | func (c *Certificate) GetRawCertificate() (*x509.Certificate, error) {
if err := c.buildX509Certificate(); err != nil {
return nil, err
}
return c.crt, nil
} | go | func (c *Certificate) GetRawCertificate() (*x509.Certificate, error) {
if err := c.buildX509Certificate(); err != nil {
return nil, err
}
return c.crt, nil
} | [
"func",
"(",
"c",
"*",
"Certificate",
")",
"GetRawCertificate",
"(",
")",
"(",
"*",
"x509",
".",
"Certificate",
",",
"error",
")",
"{",
"if",
"err",
":=",
"c",
".",
"buildX509Certificate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",... | // GetRawCertificate returns a copy of this certificate as an x509.Certificate | [
"GetRawCertificate",
"returns",
"a",
"copy",
"of",
"this",
"certificate",
"as",
"an",
"x509",
".",
"Certificate"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/pkix/cert.go#L80-L85 |
27,189 | square/certstrap | pkix/cert.go | GetExpirationDuration | func (c *Certificate) GetExpirationDuration() time.Duration {
if err := c.buildX509Certificate(); err != nil {
return time.Unix(0, 0).Sub(time.Now())
}
return c.crt.NotAfter.Sub(time.Now())
} | go | func (c *Certificate) GetExpirationDuration() time.Duration {
if err := c.buildX509Certificate(); err != nil {
return time.Unix(0, 0).Sub(time.Now())
}
return c.crt.NotAfter.Sub(time.Now())
} | [
"func",
"(",
"c",
"*",
"Certificate",
")",
"GetExpirationDuration",
"(",
")",
"time",
".",
"Duration",
"{",
"if",
"err",
":=",
"c",
".",
"buildX509Certificate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"time",
".",
"Unix",
"(",
"0",
",",
"0"... | // GetExpirationDuration gets time duration before expiration | [
"GetExpirationDuration",
"gets",
"time",
"duration",
"before",
"expiration"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/pkix/cert.go#L88-L93 |
27,190 | square/certstrap | pkix/cert.go | CheckAuthority | func (c *Certificate) CheckAuthority() error {
if err := c.buildX509Certificate(); err != nil {
return err
}
return c.crt.CheckSignatureFrom(c.crt)
} | go | func (c *Certificate) CheckAuthority() error {
if err := c.buildX509Certificate(); err != nil {
return err
}
return c.crt.CheckSignatureFrom(c.crt)
} | [
"func",
"(",
"c",
"*",
"Certificate",
")",
"CheckAuthority",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"buildX509Certificate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"c",
".",
"crt",
".",
"Che... | // CheckAuthority checks the authority of certificate against itself.
// It only ensures that certificate is self-explanatory, and
// cannot promise the validity and security. | [
"CheckAuthority",
"checks",
"the",
"authority",
"of",
"certificate",
"against",
"itself",
".",
"It",
"only",
"ensures",
"that",
"certificate",
"is",
"self",
"-",
"explanatory",
"and",
"cannot",
"promise",
"the",
"validity",
"and",
"security",
"."
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/pkix/cert.go#L98-L103 |
27,191 | square/certstrap | pkix/cert.go | Export | func (c *Certificate) Export() ([]byte, error) {
pemBlock := &pem.Block{
Type: certificatePEMBlockType,
Headers: nil,
Bytes: c.derBytes,
}
buf := new(bytes.Buffer)
if err := pem.Encode(buf, pemBlock); err != nil {
return nil, err
}
return buf.Bytes(), nil
} | go | func (c *Certificate) Export() ([]byte, error) {
pemBlock := &pem.Block{
Type: certificatePEMBlockType,
Headers: nil,
Bytes: c.derBytes,
}
buf := new(bytes.Buffer)
if err := pem.Encode(buf, pemBlock); err != nil {
return nil, err
}
return buf.Bytes(), nil
} | [
"func",
"(",
"c",
"*",
"Certificate",
")",
"Export",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"pemBlock",
":=",
"&",
"pem",
".",
"Block",
"{",
"Type",
":",
"certificatePEMBlockType",
",",
"Headers",
":",
"nil",
",",
"Bytes",
":",
"c... | // Export returns PEM-format bytes | [
"Export",
"returns",
"PEM",
"-",
"format",
"bytes"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/pkix/cert.go#L151-L163 |
27,192 | square/certstrap | pkix/cert_auth.go | CreateCertificateAuthority | func CreateCertificateAuthority(key *Key, organizationalUnit string, expiry time.Time, organization string, country string, province string, locality string, commonName string) (*Certificate, error) {
subjectKeyID, err := GenerateSubjectKeyID(key.Public)
if err != nil {
return nil, err
}
authTemplate.SubjectKeyId... | go | func CreateCertificateAuthority(key *Key, organizationalUnit string, expiry time.Time, organization string, country string, province string, locality string, commonName string) (*Certificate, error) {
subjectKeyID, err := GenerateSubjectKeyID(key.Public)
if err != nil {
return nil, err
}
authTemplate.SubjectKeyId... | [
"func",
"CreateCertificateAuthority",
"(",
"key",
"*",
"Key",
",",
"organizationalUnit",
"string",
",",
"expiry",
"time",
".",
"Time",
",",
"organization",
"string",
",",
"country",
"string",
",",
"province",
"string",
",",
"locality",
"string",
",",
"commonName... | // CreateCertificateAuthority creates Certificate Authority using existing key.
// CertificateAuthorityInfo returned is the extra infomation required by Certificate Authority. | [
"CreateCertificateAuthority",
"creates",
"Certificate",
"Authority",
"using",
"existing",
"key",
".",
"CertificateAuthorityInfo",
"returned",
"is",
"the",
"extra",
"infomation",
"required",
"by",
"Certificate",
"Authority",
"."
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/pkix/cert_auth.go#L80-L112 |
27,193 | square/certstrap | pkix/cert_auth.go | CreateIntermediateCertificateAuthority | func CreateIntermediateCertificateAuthority(crtAuth *Certificate, keyAuth *Key, csr *CertificateSigningRequest, proposedExpiry time.Time) (*Certificate, error) {
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
if err != nil {
return nil, err
... | go | func CreateIntermediateCertificateAuthority(crtAuth *Certificate, keyAuth *Key, csr *CertificateSigningRequest, proposedExpiry time.Time) (*Certificate, error) {
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
if err != nil {
return nil, err
... | [
"func",
"CreateIntermediateCertificateAuthority",
"(",
"crtAuth",
"*",
"Certificate",
",",
"keyAuth",
"*",
"Key",
",",
"csr",
"*",
"CertificateSigningRequest",
",",
"proposedExpiry",
"time",
".",
"Time",
")",
"(",
"*",
"Certificate",
",",
"error",
")",
"{",
"ser... | // CreateIntermediateCertificateAuthority creates an intermediate
// CA certificate signed by the given authority. | [
"CreateIntermediateCertificateAuthority",
"creates",
"an",
"intermediate",
"CA",
"certificate",
"signed",
"by",
"the",
"given",
"authority",
"."
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/pkix/cert_auth.go#L116-L160 |
27,194 | square/certstrap | depot/pkix.go | GetNameFromCrtTag | func GetNameFromCrtTag(tag *Tag) string {
name := strings.TrimSuffix(tag.name, crtSuffix)
if name == tag.name {
return ""
}
return name
} | go | func GetNameFromCrtTag(tag *Tag) string {
name := strings.TrimSuffix(tag.name, crtSuffix)
if name == tag.name {
return ""
}
return name
} | [
"func",
"GetNameFromCrtTag",
"(",
"tag",
"*",
"Tag",
")",
"string",
"{",
"name",
":=",
"strings",
".",
"TrimSuffix",
"(",
"tag",
".",
"name",
",",
"crtSuffix",
")",
"\n",
"if",
"name",
"==",
"tag",
".",
"name",
"{",
"return",
"\"",
"\"",
"\n",
"}",
... | // GetNameFromCrtTag returns the host name from a certificate file tag | [
"GetNameFromCrtTag",
"returns",
"the",
"host",
"name",
"from",
"a",
"certificate",
"file",
"tag"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/pkix.go#L59-L65 |
27,195 | square/certstrap | depot/pkix.go | PutCertificate | func PutCertificate(d Depot, name string, crt *pkix.Certificate) error {
b, err := crt.Export()
if err != nil {
return err
}
return d.Put(CrtTag(name), b)
} | go | func PutCertificate(d Depot, name string, crt *pkix.Certificate) error {
b, err := crt.Export()
if err != nil {
return err
}
return d.Put(CrtTag(name), b)
} | [
"func",
"PutCertificate",
"(",
"d",
"Depot",
",",
"name",
"string",
",",
"crt",
"*",
"pkix",
".",
"Certificate",
")",
"error",
"{",
"b",
",",
"err",
":=",
"crt",
".",
"Export",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
... | // PutCertificate creates a certificate file for a given CA name in the depot | [
"PutCertificate",
"creates",
"a",
"certificate",
"file",
"for",
"a",
"given",
"CA",
"name",
"in",
"the",
"depot"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/pkix.go#L68-L74 |
27,196 | square/certstrap | depot/pkix.go | CheckCertificate | func CheckCertificate(d Depot, name string) bool {
return d.Check(CrtTag(name))
} | go | func CheckCertificate(d Depot, name string) bool {
return d.Check(CrtTag(name))
} | [
"func",
"CheckCertificate",
"(",
"d",
"Depot",
",",
"name",
"string",
")",
"bool",
"{",
"return",
"d",
".",
"Check",
"(",
"CrtTag",
"(",
"name",
")",
")",
"\n",
"}"
] | // CheckCertificate checks the depot for existence of a certificate file for a given CA name | [
"CheckCertificate",
"checks",
"the",
"depot",
"for",
"existence",
"of",
"a",
"certificate",
"file",
"for",
"a",
"given",
"CA",
"name"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/pkix.go#L77-L79 |
27,197 | square/certstrap | depot/pkix.go | GetCertificate | func GetCertificate(d Depot, name string) (crt *pkix.Certificate, err error) {
b, err := d.Get(CrtTag(name))
if err != nil {
return nil, err
}
return pkix.NewCertificateFromPEM(b)
} | go | func GetCertificate(d Depot, name string) (crt *pkix.Certificate, err error) {
b, err := d.Get(CrtTag(name))
if err != nil {
return nil, err
}
return pkix.NewCertificateFromPEM(b)
} | [
"func",
"GetCertificate",
"(",
"d",
"Depot",
",",
"name",
"string",
")",
"(",
"crt",
"*",
"pkix",
".",
"Certificate",
",",
"err",
"error",
")",
"{",
"b",
",",
"err",
":=",
"d",
".",
"Get",
"(",
"CrtTag",
"(",
"name",
")",
")",
"\n",
"if",
"err",
... | // GetCertificate retrieves a certificate file for a given name from the depot | [
"GetCertificate",
"retrieves",
"a",
"certificate",
"file",
"for",
"a",
"given",
"name",
"from",
"the",
"depot"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/pkix.go#L82-L88 |
27,198 | square/certstrap | depot/pkix.go | DeleteCertificate | func DeleteCertificate(d Depot, name string) error {
return d.Delete(CrtTag(name))
} | go | func DeleteCertificate(d Depot, name string) error {
return d.Delete(CrtTag(name))
} | [
"func",
"DeleteCertificate",
"(",
"d",
"Depot",
",",
"name",
"string",
")",
"error",
"{",
"return",
"d",
".",
"Delete",
"(",
"CrtTag",
"(",
"name",
")",
")",
"\n",
"}"
] | // DeleteCertificate removes a certificate file for a given name from the depot | [
"DeleteCertificate",
"removes",
"a",
"certificate",
"file",
"for",
"a",
"given",
"name",
"from",
"the",
"depot"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/pkix.go#L91-L93 |
27,199 | square/certstrap | depot/pkix.go | PutCertificateSigningRequest | func PutCertificateSigningRequest(d Depot, name string, csr *pkix.CertificateSigningRequest) error {
b, err := csr.Export()
if err != nil {
return err
}
return d.Put(CsrTag(name), b)
} | go | func PutCertificateSigningRequest(d Depot, name string, csr *pkix.CertificateSigningRequest) error {
b, err := csr.Export()
if err != nil {
return err
}
return d.Put(CsrTag(name), b)
} | [
"func",
"PutCertificateSigningRequest",
"(",
"d",
"Depot",
",",
"name",
"string",
",",
"csr",
"*",
"pkix",
".",
"CertificateSigningRequest",
")",
"error",
"{",
"b",
",",
"err",
":=",
"csr",
".",
"Export",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // PutCertificateSigningRequest creates a certificate signing request file for a given name and csr in the depot | [
"PutCertificateSigningRequest",
"creates",
"a",
"certificate",
"signing",
"request",
"file",
"for",
"a",
"given",
"name",
"and",
"csr",
"in",
"the",
"depot"
] | 350df15b3713d535548735ea754726228b00c742 | https://github.com/square/certstrap/blob/350df15b3713d535548735ea754726228b00c742/depot/pkix.go#L96-L102 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.