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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
26,300 | google/seesaw | watchdog/core.go | Walk | func (w *Watchdog) Walk() {
log.Info("Seesaw watchdog starting...")
w.mapDependencies()
for _, svc := range w.services {
go svc.run()
}
<-w.shutdown
for _, svc := range w.services {
go svc.stop()
}
for _, svc := range w.services {
stopped := <-svc.stopped
svc.stopped <- stopped
}
} | go | func (w *Watchdog) Walk() {
log.Info("Seesaw watchdog starting...")
w.mapDependencies()
for _, svc := range w.services {
go svc.run()
}
<-w.shutdown
for _, svc := range w.services {
go svc.stop()
}
for _, svc := range w.services {
stopped := <-svc.stopped
svc.stopped <- stopped
}
} | [
"func",
"(",
"w",
"*",
"Watchdog",
")",
"Walk",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"w",
".",
"mapDependencies",
"(",
")",
"\n\n",
"for",
"_",
",",
"svc",
":=",
"range",
"w",
".",
"services",
"{",
"go",
"svc",
".",
... | // Walk takes the watchdog component for a walk so that it can run the
// configured services. | [
"Walk",
"takes",
"the",
"watchdog",
"component",
"for",
"a",
"walk",
"so",
"that",
"it",
"can",
"run",
"the",
"configured",
"services",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/watchdog/core.go#L66-L82 |
26,301 | google/seesaw | watchdog/core.go | mapDependencies | func (w *Watchdog) mapDependencies() {
for name := range w.services {
svc := w.services[name]
for depName := range svc.dependencies {
dep, ok := w.services[depName]
if !ok {
log.Fatalf("Failed to find dependency %q for service %q", depName, name)
}
svc.dependencies[depName] = dep
dep.dependents[... | go | func (w *Watchdog) mapDependencies() {
for name := range w.services {
svc := w.services[name]
for depName := range svc.dependencies {
dep, ok := w.services[depName]
if !ok {
log.Fatalf("Failed to find dependency %q for service %q", depName, name)
}
svc.dependencies[depName] = dep
dep.dependents[... | [
"func",
"(",
"w",
"*",
"Watchdog",
")",
"mapDependencies",
"(",
")",
"{",
"for",
"name",
":=",
"range",
"w",
".",
"services",
"{",
"svc",
":=",
"w",
".",
"services",
"[",
"name",
"]",
"\n",
"for",
"depName",
":=",
"range",
"svc",
".",
"dependencies",... | // mapDependencies maps service dependency names to configured services. | [
"mapDependencies",
"maps",
"service",
"dependency",
"names",
"to",
"configured",
"services",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/watchdog/core.go#L85-L97 |
26,302 | google/seesaw | ecu/control.go | VLANs | func (s *SeesawECU) VLANs(ctx *ipc.Context, reply *seesaw.VLANs) error {
s.trace("VLANs", ctx)
authConn, err := s.ecu.authConnect(ctx)
if err != nil {
return err
}
defer authConn.Close()
vlans, err := authConn.VLANs()
if err != nil {
return err
}
if reply != nil {
*reply = *vlans
}
return nil
} | go | func (s *SeesawECU) VLANs(ctx *ipc.Context, reply *seesaw.VLANs) error {
s.trace("VLANs", ctx)
authConn, err := s.ecu.authConnect(ctx)
if err != nil {
return err
}
defer authConn.Close()
vlans, err := authConn.VLANs()
if err != nil {
return err
}
if reply != nil {
*reply = *vlans
}
return nil
} | [
"func",
"(",
"s",
"*",
"SeesawECU",
")",
"VLANs",
"(",
"ctx",
"*",
"ipc",
".",
"Context",
",",
"reply",
"*",
"seesaw",
".",
"VLANs",
")",
"error",
"{",
"s",
".",
"trace",
"(",
"\"",
"\"",
",",
"ctx",
")",
"\n\n",
"authConn",
",",
"err",
":=",
"... | // VLANs returns a list of currently configured VLANs. | [
"VLANs",
"returns",
"a",
"list",
"of",
"currently",
"configured",
"VLANs",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ecu/control.go#L184-L202 |
26,303 | google/seesaw | healthcheck/dns.go | DNSType | func DNSType(name string) (uint16, error) {
dt, ok := dns.StringToType[strings.ToUpper(name)]
if !ok {
return 0, fmt.Errorf("unknown DNS type %q", name)
}
return dt, nil
} | go | func DNSType(name string) (uint16, error) {
dt, ok := dns.StringToType[strings.ToUpper(name)]
if !ok {
return 0, fmt.Errorf("unknown DNS type %q", name)
}
return dt, nil
} | [
"func",
"DNSType",
"(",
"name",
"string",
")",
"(",
"uint16",
",",
"error",
")",
"{",
"dt",
",",
"ok",
":=",
"dns",
".",
"StringToType",
"[",
"strings",
".",
"ToUpper",
"(",
"name",
")",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"0",
",",
"fmt",... | // DNSType returns the dnsType that corresponds with the given name. | [
"DNSType",
"returns",
"the",
"dnsType",
"that",
"corresponds",
"with",
"the",
"given",
"name",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/dns.go#L37-L43 |
26,304 | google/seesaw | healthcheck/dns.go | NewDNSChecker | func NewDNSChecker(ip net.IP, port int) *DNSChecker {
return &DNSChecker{
Target: Target{
IP: ip,
Port: port,
Proto: seesaw.IPProtoUDP,
},
Question: dns.Question{
Qclass: dns.ClassINET,
Qtype: dns.TypeA,
},
}
} | go | func NewDNSChecker(ip net.IP, port int) *DNSChecker {
return &DNSChecker{
Target: Target{
IP: ip,
Port: port,
Proto: seesaw.IPProtoUDP,
},
Question: dns.Question{
Qclass: dns.ClassINET,
Qtype: dns.TypeA,
},
}
} | [
"func",
"NewDNSChecker",
"(",
"ip",
"net",
".",
"IP",
",",
"port",
"int",
")",
"*",
"DNSChecker",
"{",
"return",
"&",
"DNSChecker",
"{",
"Target",
":",
"Target",
"{",
"IP",
":",
"ip",
",",
"Port",
":",
"port",
",",
"Proto",
":",
"seesaw",
".",
"IPP... | // NewDNSChecker returns an initialised DNSChecker. | [
"NewDNSChecker",
"returns",
"an",
"initialised",
"DNSChecker",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/dns.go#L53-L65 |
26,305 | google/seesaw | healthcheck/dns.go | String | func (hc *DNSChecker) String() string {
return fmt.Sprintf("DNS %s %s", questionToString(hc.Question), hc.Target)
} | go | func (hc *DNSChecker) String() string {
return fmt.Sprintf("DNS %s %s", questionToString(hc.Question), hc.Target)
} | [
"func",
"(",
"hc",
"*",
"DNSChecker",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"questionToString",
"(",
"hc",
".",
"Question",
")",
",",
"hc",
".",
"Target",
")",
"\n",
"}"
] | // String returns the string representation of a DNS healthcheck. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"DNS",
"healthcheck",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/dns.go#L72-L74 |
26,306 | google/seesaw | quagga/vty.go | NewVTY | func NewVTY(socket string) *VTY {
return &VTY{
socket: socket,
readTimeout: 1 * time.Second,
writeTimeout: 1 * time.Second,
}
} | go | func NewVTY(socket string) *VTY {
return &VTY{
socket: socket,
readTimeout: 1 * time.Second,
writeTimeout: 1 * time.Second,
}
} | [
"func",
"NewVTY",
"(",
"socket",
"string",
")",
"*",
"VTY",
"{",
"return",
"&",
"VTY",
"{",
"socket",
":",
"socket",
",",
"readTimeout",
":",
"1",
"*",
"time",
".",
"Second",
",",
"writeTimeout",
":",
"1",
"*",
"time",
".",
"Second",
",",
"}",
"\n"... | // NewVTY returns an initialised VTY struct. | [
"NewVTY",
"returns",
"an",
"initialised",
"VTY",
"struct",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/vty.go#L49-L55 |
26,307 | google/seesaw | quagga/vty.go | Dial | func (v *VTY) Dial() error {
if v.conn != nil {
return fmt.Errorf("connection already established")
}
conn, err := net.Dial("unix", v.socket)
if err != nil {
return err
}
v.conn = conn
return nil
} | go | func (v *VTY) Dial() error {
if v.conn != nil {
return fmt.Errorf("connection already established")
}
conn, err := net.Dial("unix", v.socket)
if err != nil {
return err
}
v.conn = conn
return nil
} | [
"func",
"(",
"v",
"*",
"VTY",
")",
"Dial",
"(",
")",
"error",
"{",
"if",
"v",
".",
"conn",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"conn",
",",
"err",
":=",
"net",
".",
"Dial",
"(",
"\"",
"\"... | // Dial establishes a connection to a Quagga VTY socket. | [
"Dial",
"establishes",
"a",
"connection",
"to",
"a",
"Quagga",
"VTY",
"socket",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/vty.go#L58-L68 |
26,308 | google/seesaw | quagga/vty.go | Close | func (v *VTY) Close() error {
if v.conn == nil {
return fmt.Errorf("No connection established")
}
err := v.conn.Close()
v.conn = nil
return err
} | go | func (v *VTY) Close() error {
if v.conn == nil {
return fmt.Errorf("No connection established")
}
err := v.conn.Close()
v.conn = nil
return err
} | [
"func",
"(",
"v",
"*",
"VTY",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"v",
".",
"conn",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"err",
":=",
"v",
".",
"conn",
".",
"Close",
"(",
")",
"\n"... | // Close closes a connection to a Quagga VTY socket. | [
"Close",
"closes",
"a",
"connection",
"to",
"a",
"Quagga",
"VTY",
"socket",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/vty.go#L71-L78 |
26,309 | google/seesaw | quagga/vty.go | Commands | func (v *VTY) Commands(cmds []string) error {
for _, cmd := range cmds {
if _, err := v.Command(cmd); err != nil {
return err
}
}
return nil
} | go | func (v *VTY) Commands(cmds []string) error {
for _, cmd := range cmds {
if _, err := v.Command(cmd); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"v",
"*",
"VTY",
")",
"Commands",
"(",
"cmds",
"[",
"]",
"string",
")",
"error",
"{",
"for",
"_",
",",
"cmd",
":=",
"range",
"cmds",
"{",
"if",
"_",
",",
"err",
":=",
"v",
".",
"Command",
"(",
"cmd",
")",
";",
"err",
"!=",
"nil",... | // Commands issues a sequence of commands over the Quagga VTY, discarding
// responses. | [
"Commands",
"issues",
"a",
"sequence",
"of",
"commands",
"over",
"the",
"Quagga",
"VTY",
"discarding",
"responses",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/vty.go#L82-L89 |
26,310 | google/seesaw | quagga/vty.go | Command | func (v *VTY) Command(cmd string) (string, error) {
if err := v.write(cmd); err != nil {
return "", err
}
r, s, err := v.read()
if err != nil {
return "", err
}
if s != 0 {
return "", VTYError{r, s}
}
return r, nil
} | go | func (v *VTY) Command(cmd string) (string, error) {
if err := v.write(cmd); err != nil {
return "", err
}
r, s, err := v.read()
if err != nil {
return "", err
}
if s != 0 {
return "", VTYError{r, s}
}
return r, nil
} | [
"func",
"(",
"v",
"*",
"VTY",
")",
"Command",
"(",
"cmd",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"err",
":=",
"v",
".",
"write",
"(",
"cmd",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
... | // Command issues the given command over the Quagga VTY and reads the response. | [
"Command",
"issues",
"the",
"given",
"command",
"over",
"the",
"Quagga",
"VTY",
"and",
"reads",
"the",
"response",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/vty.go#L92-L104 |
26,311 | google/seesaw | common/ipc/ipc.go | String | func (at AuthType) String() string {
if name, ok := authTypeNames[at]; ok {
return name
}
return "(unknown)"
} | go | func (at AuthType) String() string {
if name, ok := authTypeNames[at]; ok {
return name
}
return "(unknown)"
} | [
"func",
"(",
"at",
"AuthType",
")",
"String",
"(",
")",
"string",
"{",
"if",
"name",
",",
"ok",
":=",
"authTypeNames",
"[",
"at",
"]",
";",
"ok",
"{",
"return",
"name",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // String returns the string representation of an AuthType. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"an",
"AuthType",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/ipc/ipc.go#L48-L53 |
26,312 | google/seesaw | common/ipc/ipc.go | NewContext | func NewContext(component seesaw.Component) *Context {
return &Context{
AuthType: ATNone,
Peer: Peer{
Component: component,
Identity: fmt.Sprintf("%s [pid %d]", component, os.Getpid()),
},
}
} | go | func NewContext(component seesaw.Component) *Context {
return &Context{
AuthType: ATNone,
Peer: Peer{
Component: component,
Identity: fmt.Sprintf("%s [pid %d]", component, os.Getpid()),
},
}
} | [
"func",
"NewContext",
"(",
"component",
"seesaw",
".",
"Component",
")",
"*",
"Context",
"{",
"return",
"&",
"Context",
"{",
"AuthType",
":",
"ATNone",
",",
"Peer",
":",
"Peer",
"{",
"Component",
":",
"component",
",",
"Identity",
":",
"fmt",
".",
"Sprin... | // NewContext returns a new context for the given component. | [
"NewContext",
"returns",
"a",
"new",
"context",
"for",
"the",
"given",
"component",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/ipc/ipc.go#L72-L80 |
26,313 | google/seesaw | common/ipc/ipc.go | NewAuthContext | func NewAuthContext(component seesaw.Component, token string) *Context {
ctx := NewContext(component)
ctx.AuthToken = token
ctx.AuthType = ATUntrusted
return ctx
} | go | func NewAuthContext(component seesaw.Component, token string) *Context {
ctx := NewContext(component)
ctx.AuthToken = token
ctx.AuthType = ATUntrusted
return ctx
} | [
"func",
"NewAuthContext",
"(",
"component",
"seesaw",
".",
"Component",
",",
"token",
"string",
")",
"*",
"Context",
"{",
"ctx",
":=",
"NewContext",
"(",
"component",
")",
"\n",
"ctx",
".",
"AuthToken",
"=",
"token",
"\n",
"ctx",
".",
"AuthType",
"=",
"A... | // NewAuthContext returns a new authenticated context for the given component. | [
"NewAuthContext",
"returns",
"a",
"new",
"authenticated",
"context",
"for",
"the",
"given",
"component",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/ipc/ipc.go#L83-L88 |
26,314 | google/seesaw | common/ipc/ipc.go | NewTrustedContext | func NewTrustedContext(component seesaw.Component) *Context {
ctx := NewContext(component)
ctx.AuthType = ATTrusted
if u, err := user.Current(); err == nil {
ctx.User = fmt.Sprintf("%s [uid %s]", u.Username, u.Uid)
} else {
ctx.User = fmt.Sprintf("(unknown) [uid %d]", os.Getuid())
}
return ctx
} | go | func NewTrustedContext(component seesaw.Component) *Context {
ctx := NewContext(component)
ctx.AuthType = ATTrusted
if u, err := user.Current(); err == nil {
ctx.User = fmt.Sprintf("%s [uid %s]", u.Username, u.Uid)
} else {
ctx.User = fmt.Sprintf("(unknown) [uid %d]", os.Getuid())
}
return ctx
} | [
"func",
"NewTrustedContext",
"(",
"component",
"seesaw",
".",
"Component",
")",
"*",
"Context",
"{",
"ctx",
":=",
"NewContext",
"(",
"component",
")",
"\n",
"ctx",
".",
"AuthType",
"=",
"ATTrusted",
"\n",
"if",
"u",
",",
"err",
":=",
"user",
".",
"Curren... | // NewTrustedContext returns a new trusted context for the given component. | [
"NewTrustedContext",
"returns",
"a",
"new",
"trusted",
"context",
"for",
"the",
"given",
"component",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/ipc/ipc.go#L91-L100 |
26,315 | google/seesaw | common/ipc/ipc.go | String | func (ctx *Context) String() string {
if ctx == nil {
return "(nil context)"
}
var s []string
if ctx.Peer.Component != seesaw.SCNone {
s = append(s, fmt.Sprintf("peer %s", ctx.Peer.Identity))
}
if ctx.Proxy.Component != seesaw.SCNone {
s = append(s, fmt.Sprintf("via %s", ctx.Proxy.Identity))
}
s = append... | go | func (ctx *Context) String() string {
if ctx == nil {
return "(nil context)"
}
var s []string
if ctx.Peer.Component != seesaw.SCNone {
s = append(s, fmt.Sprintf("peer %s", ctx.Peer.Identity))
}
if ctx.Proxy.Component != seesaw.SCNone {
s = append(s, fmt.Sprintf("via %s", ctx.Proxy.Identity))
}
s = append... | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"String",
"(",
")",
"string",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"var",
"s",
"[",
"]",
"string",
"\n",
"if",
"ctx",
".",
"Peer",
".",
"Component",
"!=",
"seesaw",
... | // String returns the string representation of a context. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"context",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/ipc/ipc.go#L103-L117 |
26,316 | google/seesaw | ecu/core.go | NewECU | func NewECU(cfg *ECUConfig) *ECU {
if cfg == nil {
defaultCfg := DefaultECUConfig()
cfg = &defaultCfg
}
return &ECU{
cfg: cfg,
shutdown: make(chan bool),
shutdownControl: make(chan bool),
shutdownMonitor: make(chan bool),
}
} | go | func NewECU(cfg *ECUConfig) *ECU {
if cfg == nil {
defaultCfg := DefaultECUConfig()
cfg = &defaultCfg
}
return &ECU{
cfg: cfg,
shutdown: make(chan bool),
shutdownControl: make(chan bool),
shutdownMonitor: make(chan bool),
}
} | [
"func",
"NewECU",
"(",
"cfg",
"*",
"ECUConfig",
")",
"*",
"ECU",
"{",
"if",
"cfg",
"==",
"nil",
"{",
"defaultCfg",
":=",
"DefaultECUConfig",
"(",
")",
"\n",
"cfg",
"=",
"&",
"defaultCfg",
"\n",
"}",
"\n",
"return",
"&",
"ECU",
"{",
"cfg",
":",
"cfg... | // NewECU returns an initialised ECU struct. | [
"NewECU",
"returns",
"an",
"initialised",
"ECU",
"struct",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ecu/core.go#L77-L88 |
26,317 | google/seesaw | ecu/core.go | Run | func (e *ECU) Run() {
if err := e.authInit(); err != nil {
log.Warningf("Failed to initialise authentication, remote control will likely fail: %v", err)
}
stats := newECUStats(e)
go stats.run()
go e.control()
go e.monitoring()
<-e.shutdown
e.shutdownControl <- true
e.shutdownMonitor <- true
<-e.shutdownC... | go | func (e *ECU) Run() {
if err := e.authInit(); err != nil {
log.Warningf("Failed to initialise authentication, remote control will likely fail: %v", err)
}
stats := newECUStats(e)
go stats.run()
go e.control()
go e.monitoring()
<-e.shutdown
e.shutdownControl <- true
e.shutdownMonitor <- true
<-e.shutdownC... | [
"func",
"(",
"e",
"*",
"ECU",
")",
"Run",
"(",
")",
"{",
"if",
"err",
":=",
"e",
".",
"authInit",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"stats",
":=",
"newECUStats... | // Run starts the ECU. | [
"Run",
"starts",
"the",
"ECU",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ecu/core.go#L91-L107 |
26,318 | google/seesaw | ecu/core.go | monitoring | func (e *ECU) monitoring() {
ln, err := net.Listen("tcp", e.cfg.MonitorAddress)
if err != nil {
log.Fatal("listen error:", err)
}
monitorHTTP := &http.Server{
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
MaxHeaderBytes: 1 << 20,
}
go monitorHTTP.Serve(ln)
<-e.shutdownMonitor
ln.... | go | func (e *ECU) monitoring() {
ln, err := net.Listen("tcp", e.cfg.MonitorAddress)
if err != nil {
log.Fatal("listen error:", err)
}
monitorHTTP := &http.Server{
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
MaxHeaderBytes: 1 << 20,
}
go monitorHTTP.Serve(ln)
<-e.shutdownMonitor
ln.... | [
"func",
"(",
"e",
"*",
"ECU",
")",
"monitoring",
"(",
")",
"{",
"ln",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"e",
".",
"cfg",
".",
"MonitorAddress",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatal",
"(",
"\... | // monitoring starts an HTTP server for monitoring purposes. | [
"monitoring",
"starts",
"an",
"HTTP",
"server",
"for",
"monitoring",
"purposes",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ecu/core.go#L115-L131 |
26,319 | google/seesaw | ecu/core.go | controlTLSConfig | func (e *ECU) controlTLSConfig() (*tls.Config, error) {
rootCACerts := x509.NewCertPool()
data, err := ioutil.ReadFile(e.cfg.CACertsFile)
if err != nil {
return nil, fmt.Errorf("failed to read CA cert file: %v", err)
}
if ok := rootCACerts.AppendCertsFromPEM(data); !ok {
return nil, errors.New("failed to load ... | go | func (e *ECU) controlTLSConfig() (*tls.Config, error) {
rootCACerts := x509.NewCertPool()
data, err := ioutil.ReadFile(e.cfg.CACertsFile)
if err != nil {
return nil, fmt.Errorf("failed to read CA cert file: %v", err)
}
if ok := rootCACerts.AppendCertsFromPEM(data); !ok {
return nil, errors.New("failed to load ... | [
"func",
"(",
"e",
"*",
"ECU",
")",
"controlTLSConfig",
"(",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"rootCACerts",
":=",
"x509",
".",
"NewCertPool",
"(",
")",
"\n",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"e",... | // controlTLSConfig returns a TLS configuration for use by the control server. | [
"controlTLSConfig",
"returns",
"a",
"TLS",
"configuration",
"for",
"use",
"by",
"the",
"control",
"server",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ecu/core.go#L134-L154 |
26,320 | google/seesaw | ecu/core.go | control | func (e *ECU) control() {
tlsConfig, err := e.controlTLSConfig()
if err != nil {
log.Errorf("Disabling ECU control server: %v", err)
<-e.shutdownControl
e.shutdownControl <- true
return
}
ln, err := net.Listen("tcp", e.cfg.ControlAddress)
if err != nil {
log.Fatal("listen error:", err)
}
seesawRPC :=... | go | func (e *ECU) control() {
tlsConfig, err := e.controlTLSConfig()
if err != nil {
log.Errorf("Disabling ECU control server: %v", err)
<-e.shutdownControl
e.shutdownControl <- true
return
}
ln, err := net.Listen("tcp", e.cfg.ControlAddress)
if err != nil {
log.Fatal("listen error:", err)
}
seesawRPC :=... | [
"func",
"(",
"e",
"*",
"ECU",
")",
"control",
"(",
")",
"{",
"tlsConfig",
",",
"err",
":=",
"e",
".",
"controlTLSConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"<-",
"e",
... | // control starts an HTTP server to handle control RPC via a TCP socket. This
// interface is used to control the Seesaw Node via the CLI or web console. | [
"control",
"starts",
"an",
"HTTP",
"server",
"to",
"handle",
"control",
"RPC",
"via",
"a",
"TCP",
"socket",
".",
"This",
"interface",
"is",
"used",
"to",
"control",
"the",
"Seesaw",
"Node",
"via",
"the",
"CLI",
"or",
"web",
"console",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ecu/core.go#L158-L180 |
26,321 | google/seesaw | ncc/sysctl.go | sysctlInitLB | func sysctlInitLB(nodeIface, lbIface *net.Interface) error {
// System level sysctls.
for _, ctl := range seesawSysctls {
if _, err := sysctl(ctl.name, ctl.value); err != nil {
return err
}
}
// Interface level sysctls.
ifaces := []string{"all", "default", nodeIface.Name, lbIface.Name}
for _, iface := ra... | go | func sysctlInitLB(nodeIface, lbIface *net.Interface) error {
// System level sysctls.
for _, ctl := range seesawSysctls {
if _, err := sysctl(ctl.name, ctl.value); err != nil {
return err
}
}
// Interface level sysctls.
ifaces := []string{"all", "default", nodeIface.Name, lbIface.Name}
for _, iface := ra... | [
"func",
"sysctlInitLB",
"(",
"nodeIface",
",",
"lbIface",
"*",
"net",
".",
"Interface",
")",
"error",
"{",
"// System level sysctls.",
"for",
"_",
",",
"ctl",
":=",
"range",
"seesawSysctls",
"{",
"if",
"_",
",",
"err",
":=",
"sysctl",
"(",
"ctl",
".",
"n... | // sysctlInitLB initialises sysctls required for load balancing. | [
"sysctlInitLB",
"initialises",
"sysctls",
"required",
"for",
"load",
"balancing",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/sysctl.go#L91-L108 |
26,322 | google/seesaw | ncc/sysctl.go | sysctlInitIface | func sysctlInitIface(iface string) error {
for _, ctl := range seesawIfaceSysctls {
if err := sysctlIface(iface, ctl.af, ctl.name, ctl.value); err != nil {
return err
}
}
return nil
} | go | func sysctlInitIface(iface string) error {
for _, ctl := range seesawIfaceSysctls {
if err := sysctlIface(iface, ctl.af, ctl.name, ctl.value); err != nil {
return err
}
}
return nil
} | [
"func",
"sysctlInitIface",
"(",
"iface",
"string",
")",
"error",
"{",
"for",
"_",
",",
"ctl",
":=",
"range",
"seesawIfaceSysctls",
"{",
"if",
"err",
":=",
"sysctlIface",
"(",
"iface",
",",
"ctl",
".",
"af",
",",
"ctl",
".",
"name",
",",
"ctl",
".",
"... | // sysctlInitIface initialises sysctls required for a load balancing interface. | [
"sysctlInitIface",
"initialises",
"sysctls",
"required",
"for",
"a",
"load",
"balancing",
"interface",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/sysctl.go#L111-L118 |
26,323 | google/seesaw | ncc/sysctl.go | sysctlIface | func sysctlIface(iface string, af seesaw.AF, name, value string) error {
components := []string{
"net", strings.ToLower(af.String()), "conf", iface, name,
}
_, err := sysctlByComponents(components, value)
return err
} | go | func sysctlIface(iface string, af seesaw.AF, name, value string) error {
components := []string{
"net", strings.ToLower(af.String()), "conf", iface, name,
}
_, err := sysctlByComponents(components, value)
return err
} | [
"func",
"sysctlIface",
"(",
"iface",
"string",
",",
"af",
"seesaw",
".",
"AF",
",",
"name",
",",
"value",
"string",
")",
"error",
"{",
"components",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"strings",
".",
"ToLower",
"(",
"af",
".",
"String",
... | // sysctlIface sets a sysctl for a given address family and network interface. | [
"sysctlIface",
"sets",
"a",
"sysctl",
"for",
"a",
"given",
"address",
"family",
"and",
"network",
"interface",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/sysctl.go#L121-L127 |
26,324 | google/seesaw | ncc/sysctl.go | sysctl | func sysctl(name, value string) (string, error) {
return sysctlByComponents(strings.Split(name, "."), value)
} | go | func sysctl(name, value string) (string, error) {
return sysctlByComponents(strings.Split(name, "."), value)
} | [
"func",
"sysctl",
"(",
"name",
",",
"value",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"sysctlByComponents",
"(",
"strings",
".",
"Split",
"(",
"name",
",",
"\"",
"\"",
")",
",",
"value",
")",
"\n",
"}"
] | // sysctl sets the named sysctl to the value specified and returns its
// original value as a string. Note that this cannot be used if a sysctl
// component includes a period it its name - in that case use
// sysctlByComponents instead. | [
"sysctl",
"sets",
"the",
"named",
"sysctl",
"to",
"the",
"value",
"specified",
"and",
"returns",
"its",
"original",
"value",
"as",
"a",
"string",
".",
"Note",
"that",
"this",
"cannot",
"be",
"used",
"if",
"a",
"sysctl",
"component",
"includes",
"a",
"perio... | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/sysctl.go#L133-L135 |
26,325 | google/seesaw | ncc/sysctl.go | sysctlByComponents | func sysctlByComponents(components []string, value string) (string, error) {
components = append([]string{sysctlPath}, components...)
f, err := os.OpenFile(path.Join(components...), os.O_RDWR, 0)
if err != nil {
return "", err
}
defer f.Close()
b, err := ioutil.ReadAll(f)
if err != nil {
return "", err
}
i... | go | func sysctlByComponents(components []string, value string) (string, error) {
components = append([]string{sysctlPath}, components...)
f, err := os.OpenFile(path.Join(components...), os.O_RDWR, 0)
if err != nil {
return "", err
}
defer f.Close()
b, err := ioutil.ReadAll(f)
if err != nil {
return "", err
}
i... | [
"func",
"sysctlByComponents",
"(",
"components",
"[",
"]",
"string",
",",
"value",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"components",
"=",
"append",
"(",
"[",
"]",
"string",
"{",
"sysctlPath",
"}",
",",
"components",
"...",
")",
"\n",
... | // sysctlByComponents sets the sysctl specified by the individual components
// to the value specified and returns its original value as a string. | [
"sysctlByComponents",
"sets",
"the",
"sysctl",
"specified",
"by",
"the",
"individual",
"components",
"to",
"the",
"value",
"specified",
"and",
"returns",
"its",
"original",
"value",
"as",
"a",
"string",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/sysctl.go#L139-L157 |
26,326 | google/seesaw | ncc/iptables.go | newIPTRuleTemplate | func newIPTRuleTemplate(action iptAction, tmpl string) *iptRuleTemplate {
t, err := template.New("").Parse(tmpl)
if err != nil {
panic(fmt.Sprintf("Failed to parse iptables template: %q: %v", tmpl, err))
}
return &iptRuleTemplate{action, t}
} | go | func newIPTRuleTemplate(action iptAction, tmpl string) *iptRuleTemplate {
t, err := template.New("").Parse(tmpl)
if err != nil {
panic(fmt.Sprintf("Failed to parse iptables template: %q: %v", tmpl, err))
}
return &iptRuleTemplate{action, t}
} | [
"func",
"newIPTRuleTemplate",
"(",
"action",
"iptAction",
",",
"tmpl",
"string",
")",
"*",
"iptRuleTemplate",
"{",
"t",
",",
"err",
":=",
"template",
".",
"New",
"(",
"\"",
"\"",
")",
".",
"Parse",
"(",
"tmpl",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{... | // newIPTRuleTemplate creates a new iptRuleTemplate. | [
"newIPTRuleTemplate",
"creates",
"a",
"new",
"iptRuleTemplate",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/iptables.go#L77-L83 |
26,327 | google/seesaw | ncc/iptables.go | execute | func (te *iptTemplateExecuter) execute() ([]*iptRule, error) {
rules := make([]*iptRule, 0, len(te.templates))
for _, t := range te.templates {
w := new(bytes.Buffer)
if err := t.Template.Execute(w, te.data); err != nil {
return nil, err
}
af := seesaw.IPv6
if te.data.ServiceVIP.To4() != nil {
af = se... | go | func (te *iptTemplateExecuter) execute() ([]*iptRule, error) {
rules := make([]*iptRule, 0, len(te.templates))
for _, t := range te.templates {
w := new(bytes.Buffer)
if err := t.Template.Execute(w, te.data); err != nil {
return nil, err
}
af := seesaw.IPv6
if te.data.ServiceVIP.To4() != nil {
af = se... | [
"func",
"(",
"te",
"*",
"iptTemplateExecuter",
")",
"execute",
"(",
")",
"(",
"[",
"]",
"*",
"iptRule",
",",
"error",
")",
"{",
"rules",
":=",
"make",
"(",
"[",
"]",
"*",
"iptRule",
",",
"0",
",",
"len",
"(",
"te",
".",
"templates",
")",
")",
"... | // execute generates the list of iptRules for this iptTemplateExecuter. | [
"execute",
"generates",
"the",
"list",
"of",
"iptRules",
"for",
"this",
"iptTemplateExecuter",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/iptables.go#L103-L122 |
26,328 | google/seesaw | ncc/iptables.go | initIPTRuleTemplates | func initIPTRuleTemplates() {
// Allow traffic for VIP services.
svcRules = append(svcRules, newIPTRuleTemplate(iptAppend,
"INPUT -p {{.Proto}} -d {{.ServiceVIP}}{{with .Port}} --dport {{.}}{{end}} -j ACCEPT"))
// Mark packets for firemark based VIPs.
fwmRule := "PREROUTING -t mangle -p {{.Proto}} -d {{.ServiceV... | go | func initIPTRuleTemplates() {
// Allow traffic for VIP services.
svcRules = append(svcRules, newIPTRuleTemplate(iptAppend,
"INPUT -p {{.Proto}} -d {{.ServiceVIP}}{{with .Port}} --dport {{.}}{{end}} -j ACCEPT"))
// Mark packets for firemark based VIPs.
fwmRule := "PREROUTING -t mangle -p {{.Proto}} -d {{.ServiceV... | [
"func",
"initIPTRuleTemplates",
"(",
")",
"{",
"// Allow traffic for VIP services.",
"svcRules",
"=",
"append",
"(",
"svcRules",
",",
"newIPTRuleTemplate",
"(",
"iptAppend",
",",
"\"",
"\"",
")",
")",
"\n\n",
"// Mark packets for firemark based VIPs.",
"fwmRule",
":=",
... | // initIPTRuleTemplates initialises the iptRuleTemplates. | [
"initIPTRuleTemplates",
"initialises",
"the",
"iptRuleTemplates",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/iptables.go#L132-L162 |
26,329 | google/seesaw | ncc/iptables.go | iptablesInit | func iptablesInit(clusterVIP seesaw.Host) error {
if err := iptablesFlush(); err != nil {
return err
}
for _, af := range seesaw.AFs() {
// Allow connections to port 10257 for all VIPs.
if err := iptablesRun(af, "-I INPUT -p tcp --dport 10257 -j ACCEPT"); err != nil {
return err
}
// conntrack is only ... | go | func iptablesInit(clusterVIP seesaw.Host) error {
if err := iptablesFlush(); err != nil {
return err
}
for _, af := range seesaw.AFs() {
// Allow connections to port 10257 for all VIPs.
if err := iptablesRun(af, "-I INPUT -p tcp --dport 10257 -j ACCEPT"); err != nil {
return err
}
// conntrack is only ... | [
"func",
"iptablesInit",
"(",
"clusterVIP",
"seesaw",
".",
"Host",
")",
"error",
"{",
"if",
"err",
":=",
"iptablesFlush",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"for",
"_",
",",
"af",
":=",
"range",
"seesaw",
".",
... | // iptablesInit initialises the iptables rules for a Seesaw Node. | [
"iptablesInit",
"initialises",
"the",
"iptables",
"rules",
"for",
"a",
"Seesaw",
"Node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/iptables.go#L216-L239 |
26,330 | google/seesaw | ncc/iptables.go | iptablesFlush | func iptablesFlush() error {
for _, af := range seesaw.AFs() {
for _, table := range []string{"filter", "mangle", "raw"} {
if err := iptablesRun(af, fmt.Sprintf("--flush -t %v", table)); err != nil {
return err
}
}
}
// NAT is IPv4-only until linux kernel version 3.7.
// TODO(angusc): Support IPv6 NAT... | go | func iptablesFlush() error {
for _, af := range seesaw.AFs() {
for _, table := range []string{"filter", "mangle", "raw"} {
if err := iptablesRun(af, fmt.Sprintf("--flush -t %v", table)); err != nil {
return err
}
}
}
// NAT is IPv4-only until linux kernel version 3.7.
// TODO(angusc): Support IPv6 NAT... | [
"func",
"iptablesFlush",
"(",
")",
"error",
"{",
"for",
"_",
",",
"af",
":=",
"range",
"seesaw",
".",
"AFs",
"(",
")",
"{",
"for",
"_",
",",
"table",
":=",
"range",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"... | // iptablesFlush removes all IPv4 and IPv6 iptables rules. | [
"iptablesFlush",
"removes",
"all",
"IPv4",
"and",
"IPv6",
"iptables",
"rules",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/iptables.go#L242-L256 |
26,331 | google/seesaw | ncc/iptables.go | iptablesRules | func iptablesRules(v *seesaw.Vserver, clusterVIP seesaw.Host, af seesaw.AF) ([]*iptRule, error) {
var clusterIP, serviceIP net.IP
switch af {
case seesaw.IPv4:
clusterIP = clusterVIP.IPv4Addr
serviceIP = v.IPv4Addr
case seesaw.IPv6:
clusterIP = clusterVIP.IPv6Addr
serviceIP = v.IPv6Addr
}
if clusterIP == ... | go | func iptablesRules(v *seesaw.Vserver, clusterVIP seesaw.Host, af seesaw.AF) ([]*iptRule, error) {
var clusterIP, serviceIP net.IP
switch af {
case seesaw.IPv4:
clusterIP = clusterVIP.IPv4Addr
serviceIP = v.IPv4Addr
case seesaw.IPv6:
clusterIP = clusterVIP.IPv6Addr
serviceIP = v.IPv6Addr
}
if clusterIP == ... | [
"func",
"iptablesRules",
"(",
"v",
"*",
"seesaw",
".",
"Vserver",
",",
"clusterVIP",
"seesaw",
".",
"Host",
",",
"af",
"seesaw",
".",
"AF",
")",
"(",
"[",
"]",
"*",
"iptRule",
",",
"error",
")",
"{",
"var",
"clusterIP",
",",
"serviceIP",
"net",
".",
... | // iptablesRules returns the list of iptRules for a Vserver. | [
"iptablesRules",
"returns",
"the",
"list",
"of",
"iptRules",
"for",
"a",
"Vserver",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/iptables.go#L259-L313 |
26,332 | google/seesaw | ncc/iptables.go | iptablesAddRules | func iptablesAddRules(v *seesaw.Vserver, clusterVIP seesaw.Host, af seesaw.AF) error {
rules, err := iptablesRules(v, clusterVIP, af)
if err != nil {
return err
}
for _, r := range rules {
if err := iptablesRun(r.AF, string(r.action)+" "+r.rule); err != nil {
return err
}
}
return nil
} | go | func iptablesAddRules(v *seesaw.Vserver, clusterVIP seesaw.Host, af seesaw.AF) error {
rules, err := iptablesRules(v, clusterVIP, af)
if err != nil {
return err
}
for _, r := range rules {
if err := iptablesRun(r.AF, string(r.action)+" "+r.rule); err != nil {
return err
}
}
return nil
} | [
"func",
"iptablesAddRules",
"(",
"v",
"*",
"seesaw",
".",
"Vserver",
",",
"clusterVIP",
"seesaw",
".",
"Host",
",",
"af",
"seesaw",
".",
"AF",
")",
"error",
"{",
"rules",
",",
"err",
":=",
"iptablesRules",
"(",
"v",
",",
"clusterVIP",
",",
"af",
")",
... | // iptablesAddRules installs the iptables rules for a given Vserver and Seesaw
// Cluster VIP. | [
"iptablesAddRules",
"installs",
"the",
"iptables",
"rules",
"for",
"a",
"given",
"Vserver",
"and",
"Seesaw",
"Cluster",
"VIP",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/iptables.go#L317-L328 |
26,333 | google/seesaw | ncc/ipvs.go | initIPVS | func initIPVS() {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
log.Infof("Initialising IPVS...")
if err := ipvs.Init(); err != nil {
// TODO(jsing): modprobe ip_vs and try again.
log.Fatalf("IPVS initialisation failed: %v", err)
}
log.Infof("IPVS version %s", ipvs.Version())
} | go | func initIPVS() {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
log.Infof("Initialising IPVS...")
if err := ipvs.Init(); err != nil {
// TODO(jsing): modprobe ip_vs and try again.
log.Fatalf("IPVS initialisation failed: %v", err)
}
log.Infof("IPVS version %s", ipvs.Version())
} | [
"func",
"initIPVS",
"(",
")",
"{",
"ipvsMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ipvsMutex",
".",
"Unlock",
"(",
")",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"ipvs",
".",
"Init",
"(",
")",
";",
"err",
"!=... | // initIPVS initialises the IPVS sub-component. | [
"initIPVS",
"initialises",
"the",
"IPVS",
"sub",
"-",
"component",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ipvs.go#L34-L43 |
26,334 | google/seesaw | ncc/ipvs.go | IPVSFlush | func (ncc *SeesawNCC) IPVSFlush(in int, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.Flush()
} | go | func (ncc *SeesawNCC) IPVSFlush(in int, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.Flush()
} | [
"func",
"(",
"ncc",
"*",
"SeesawNCC",
")",
"IPVSFlush",
"(",
"in",
"int",
",",
"out",
"*",
"int",
")",
"error",
"{",
"ipvsMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ipvsMutex",
".",
"Unlock",
"(",
")",
"\n",
"return",
"ipvs",
".",
"Flush",
"(",... | // IPVSFlush flushes all services and destinations from the IPVS table. | [
"IPVSFlush",
"flushes",
"all",
"services",
"and",
"destinations",
"from",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ipvs.go#L46-L50 |
26,335 | google/seesaw | ncc/ipvs.go | IPVSGetServices | func (ncc *SeesawNCC) IPVSGetServices(in int, s *ncctypes.IPVSServices) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
svcs, err := ipvs.GetServices()
if err != nil {
return err
}
s.Services = nil
for _, svc := range svcs {
s.Services = append(s.Services, svc)
}
return nil
} | go | func (ncc *SeesawNCC) IPVSGetServices(in int, s *ncctypes.IPVSServices) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
svcs, err := ipvs.GetServices()
if err != nil {
return err
}
s.Services = nil
for _, svc := range svcs {
s.Services = append(s.Services, svc)
}
return nil
} | [
"func",
"(",
"ncc",
"*",
"SeesawNCC",
")",
"IPVSGetServices",
"(",
"in",
"int",
",",
"s",
"*",
"ncctypes",
".",
"IPVSServices",
")",
"error",
"{",
"ipvsMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ipvsMutex",
".",
"Unlock",
"(",
")",
"\n",
"svcs",
... | // IPVSGetServices gets the currently configured services from the IPVS table. | [
"IPVSGetServices",
"gets",
"the",
"currently",
"configured",
"services",
"from",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ipvs.go#L53-L65 |
26,336 | google/seesaw | ncc/ipvs.go | IPVSGetService | func (ncc *SeesawNCC) IPVSGetService(si *ipvs.Service, s *ncctypes.IPVSServices) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
so, err := ipvs.GetService(si)
if err != nil {
return err
}
s.Services = []*ipvs.Service{so}
return nil
} | go | func (ncc *SeesawNCC) IPVSGetService(si *ipvs.Service, s *ncctypes.IPVSServices) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
so, err := ipvs.GetService(si)
if err != nil {
return err
}
s.Services = []*ipvs.Service{so}
return nil
} | [
"func",
"(",
"ncc",
"*",
"SeesawNCC",
")",
"IPVSGetService",
"(",
"si",
"*",
"ipvs",
".",
"Service",
",",
"s",
"*",
"ncctypes",
".",
"IPVSServices",
")",
"error",
"{",
"ipvsMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ipvsMutex",
".",
"Unlock",
"(",
... | // IPVSGetService gets the currently configured service from the IPVS table,
// which matches the specified service. | [
"IPVSGetService",
"gets",
"the",
"currently",
"configured",
"service",
"from",
"the",
"IPVS",
"table",
"which",
"matches",
"the",
"specified",
"service",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ipvs.go#L69-L78 |
26,337 | google/seesaw | ncc/ipvs.go | IPVSAddService | func (ncc *SeesawNCC) IPVSAddService(svc *ipvs.Service, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.AddService(*svc)
} | go | func (ncc *SeesawNCC) IPVSAddService(svc *ipvs.Service, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.AddService(*svc)
} | [
"func",
"(",
"ncc",
"*",
"SeesawNCC",
")",
"IPVSAddService",
"(",
"svc",
"*",
"ipvs",
".",
"Service",
",",
"out",
"*",
"int",
")",
"error",
"{",
"ipvsMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ipvsMutex",
".",
"Unlock",
"(",
")",
"\n",
"return",
... | // IPVSAddService adds the specified service to the IPVS table. | [
"IPVSAddService",
"adds",
"the",
"specified",
"service",
"to",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ipvs.go#L81-L85 |
26,338 | google/seesaw | ncc/ipvs.go | IPVSUpdateService | func (ncc *SeesawNCC) IPVSUpdateService(svc *ipvs.Service, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.UpdateService(*svc)
} | go | func (ncc *SeesawNCC) IPVSUpdateService(svc *ipvs.Service, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.UpdateService(*svc)
} | [
"func",
"(",
"ncc",
"*",
"SeesawNCC",
")",
"IPVSUpdateService",
"(",
"svc",
"*",
"ipvs",
".",
"Service",
",",
"out",
"*",
"int",
")",
"error",
"{",
"ipvsMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ipvsMutex",
".",
"Unlock",
"(",
")",
"\n",
"return... | // IPVSUpdateService updates the specified service in the IPVS table. | [
"IPVSUpdateService",
"updates",
"the",
"specified",
"service",
"in",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ipvs.go#L88-L92 |
26,339 | google/seesaw | ncc/ipvs.go | IPVSDeleteService | func (ncc *SeesawNCC) IPVSDeleteService(svc *ipvs.Service, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.DeleteService(*svc)
} | go | func (ncc *SeesawNCC) IPVSDeleteService(svc *ipvs.Service, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.DeleteService(*svc)
} | [
"func",
"(",
"ncc",
"*",
"SeesawNCC",
")",
"IPVSDeleteService",
"(",
"svc",
"*",
"ipvs",
".",
"Service",
",",
"out",
"*",
"int",
")",
"error",
"{",
"ipvsMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ipvsMutex",
".",
"Unlock",
"(",
")",
"\n",
"return... | // IPVSDeleteService deletes the specified service from the IPVS table. | [
"IPVSDeleteService",
"deletes",
"the",
"specified",
"service",
"from",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ipvs.go#L95-L99 |
26,340 | google/seesaw | ncc/ipvs.go | IPVSAddDestination | func (ncc *SeesawNCC) IPVSAddDestination(dst *ncctypes.IPVSDestination, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.AddDestination(*dst.Service, *dst.Destination)
} | go | func (ncc *SeesawNCC) IPVSAddDestination(dst *ncctypes.IPVSDestination, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.AddDestination(*dst.Service, *dst.Destination)
} | [
"func",
"(",
"ncc",
"*",
"SeesawNCC",
")",
"IPVSAddDestination",
"(",
"dst",
"*",
"ncctypes",
".",
"IPVSDestination",
",",
"out",
"*",
"int",
")",
"error",
"{",
"ipvsMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ipvsMutex",
".",
"Unlock",
"(",
")",
"\... | // IPVSAddDestination adds the specified destination to the IPVS table. | [
"IPVSAddDestination",
"adds",
"the",
"specified",
"destination",
"to",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ipvs.go#L102-L106 |
26,341 | google/seesaw | ncc/ipvs.go | IPVSUpdateDestination | func (ncc *SeesawNCC) IPVSUpdateDestination(dst *ncctypes.IPVSDestination, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.UpdateDestination(*dst.Service, *dst.Destination)
} | go | func (ncc *SeesawNCC) IPVSUpdateDestination(dst *ncctypes.IPVSDestination, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.UpdateDestination(*dst.Service, *dst.Destination)
} | [
"func",
"(",
"ncc",
"*",
"SeesawNCC",
")",
"IPVSUpdateDestination",
"(",
"dst",
"*",
"ncctypes",
".",
"IPVSDestination",
",",
"out",
"*",
"int",
")",
"error",
"{",
"ipvsMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ipvsMutex",
".",
"Unlock",
"(",
")",
... | // IPVSUpdateDestination updates the specified destination in the IPVS table. | [
"IPVSUpdateDestination",
"updates",
"the",
"specified",
"destination",
"in",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ipvs.go#L109-L113 |
26,342 | google/seesaw | ncc/ipvs.go | IPVSDeleteDestination | func (ncc *SeesawNCC) IPVSDeleteDestination(dst *ncctypes.IPVSDestination, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.DeleteDestination(*dst.Service, *dst.Destination)
} | go | func (ncc *SeesawNCC) IPVSDeleteDestination(dst *ncctypes.IPVSDestination, out *int) error {
ipvsMutex.Lock()
defer ipvsMutex.Unlock()
return ipvs.DeleteDestination(*dst.Service, *dst.Destination)
} | [
"func",
"(",
"ncc",
"*",
"SeesawNCC",
")",
"IPVSDeleteDestination",
"(",
"dst",
"*",
"ncctypes",
".",
"IPVSDestination",
",",
"out",
"*",
"int",
")",
"error",
"{",
"ipvsMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ipvsMutex",
".",
"Unlock",
"(",
")",
... | // IPVSDeleteDestination deletes the specified destination from the IPVS table. | [
"IPVSDeleteDestination",
"deletes",
"the",
"specified",
"destination",
"from",
"the",
"IPVS",
"table",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/ipvs.go#L116-L120 |
26,343 | google/seesaw | common/seesaw/util.go | Copy | func (n *Node) Copy(c *Node) {
n.State = c.State
n.Priority = c.Priority
n.Host.Copy(&c.Host)
n.VserversEnabled = c.VserversEnabled
} | go | func (n *Node) Copy(c *Node) {
n.State = c.State
n.Priority = c.Priority
n.Host.Copy(&c.Host)
n.VserversEnabled = c.VserversEnabled
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Copy",
"(",
"c",
"*",
"Node",
")",
"{",
"n",
".",
"State",
"=",
"c",
".",
"State",
"\n",
"n",
".",
"Priority",
"=",
"c",
".",
"Priority",
"\n",
"n",
".",
"Host",
".",
"Copy",
"(",
"&",
"c",
".",
"Host",
... | // Copy deep copies from the given Seesaw Node. | [
"Copy",
"deep",
"copies",
"from",
"the",
"given",
"Seesaw",
"Node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L38-L43 |
26,344 | google/seesaw | common/seesaw/util.go | Clone | func (n *Node) Clone() *Node {
var c Node
c.Copy(n)
return &c
} | go | func (n *Node) Clone() *Node {
var c Node
c.Copy(n)
return &c
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Clone",
"(",
")",
"*",
"Node",
"{",
"var",
"c",
"Node",
"\n",
"c",
".",
"Copy",
"(",
"n",
")",
"\n",
"return",
"&",
"c",
"\n",
"}"
] | // Clone creates an identical copy of the given Seesaw Node. | [
"Clone",
"creates",
"an",
"identical",
"copy",
"of",
"the",
"given",
"Seesaw",
"Node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L46-L50 |
26,345 | google/seesaw | common/seesaw/util.go | Copy | func (h *Host) Copy(c *Host) {
h.Hostname = c.Hostname
h.IPv4Addr = copyIP(c.IPv4Addr)
h.IPv4Mask = copyIPMask(c.IPv4Mask)
h.IPv6Addr = copyIP(c.IPv6Addr)
h.IPv6Mask = copyIPMask(c.IPv6Mask)
} | go | func (h *Host) Copy(c *Host) {
h.Hostname = c.Hostname
h.IPv4Addr = copyIP(c.IPv4Addr)
h.IPv4Mask = copyIPMask(c.IPv4Mask)
h.IPv6Addr = copyIP(c.IPv6Addr)
h.IPv6Mask = copyIPMask(c.IPv6Mask)
} | [
"func",
"(",
"h",
"*",
"Host",
")",
"Copy",
"(",
"c",
"*",
"Host",
")",
"{",
"h",
".",
"Hostname",
"=",
"c",
".",
"Hostname",
"\n",
"h",
".",
"IPv4Addr",
"=",
"copyIP",
"(",
"c",
".",
"IPv4Addr",
")",
"\n",
"h",
".",
"IPv4Mask",
"=",
"copyIPMas... | // Copy deep copies from the given Seesaw Host. | [
"Copy",
"deep",
"copies",
"from",
"the",
"given",
"Seesaw",
"Host",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L75-L81 |
26,346 | google/seesaw | common/seesaw/util.go | Clone | func (h *Host) Clone() *Host {
var c Host
c.Copy(h)
return &c
} | go | func (h *Host) Clone() *Host {
var c Host
c.Copy(h)
return &c
} | [
"func",
"(",
"h",
"*",
"Host",
")",
"Clone",
"(",
")",
"*",
"Host",
"{",
"var",
"c",
"Host",
"\n",
"c",
".",
"Copy",
"(",
"h",
")",
"\n",
"return",
"&",
"c",
"\n",
"}"
] | // Clone creates an identical copy of the given Seesaw Host. | [
"Clone",
"creates",
"an",
"identical",
"copy",
"of",
"the",
"given",
"Seesaw",
"Host",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L84-L88 |
26,347 | google/seesaw | common/seesaw/util.go | Equal | func (h *Host) Equal(other *Host) bool {
return reflect.DeepEqual(h, other)
} | go | func (h *Host) Equal(other *Host) bool {
return reflect.DeepEqual(h, other)
} | [
"func",
"(",
"h",
"*",
"Host",
")",
"Equal",
"(",
"other",
"*",
"Host",
")",
"bool",
"{",
"return",
"reflect",
".",
"DeepEqual",
"(",
"h",
",",
"other",
")",
"\n",
"}"
] | // Equal returns whether two hosts are equal. | [
"Equal",
"returns",
"whether",
"two",
"hosts",
"are",
"equal",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L91-L93 |
26,348 | google/seesaw | common/seesaw/util.go | IPv4Net | func (h *Host) IPv4Net() *net.IPNet {
return &net.IPNet{IP: h.IPv4Addr, Mask: h.IPv4Mask}
} | go | func (h *Host) IPv4Net() *net.IPNet {
return &net.IPNet{IP: h.IPv4Addr, Mask: h.IPv4Mask}
} | [
"func",
"(",
"h",
"*",
"Host",
")",
"IPv4Net",
"(",
")",
"*",
"net",
".",
"IPNet",
"{",
"return",
"&",
"net",
".",
"IPNet",
"{",
"IP",
":",
"h",
".",
"IPv4Addr",
",",
"Mask",
":",
"h",
".",
"IPv4Mask",
"}",
"\n",
"}"
] | // IPv4Net returns a net.IPNet for the host's IPv4 address. | [
"IPv4Net",
"returns",
"a",
"net",
".",
"IPNet",
"for",
"the",
"host",
"s",
"IPv4",
"address",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L96-L98 |
26,349 | google/seesaw | common/seesaw/util.go | IPv6Net | func (h *Host) IPv6Net() *net.IPNet {
return &net.IPNet{IP: h.IPv6Addr, Mask: h.IPv6Mask}
} | go | func (h *Host) IPv6Net() *net.IPNet {
return &net.IPNet{IP: h.IPv6Addr, Mask: h.IPv6Mask}
} | [
"func",
"(",
"h",
"*",
"Host",
")",
"IPv6Net",
"(",
")",
"*",
"net",
".",
"IPNet",
"{",
"return",
"&",
"net",
".",
"IPNet",
"{",
"IP",
":",
"h",
".",
"IPv6Addr",
",",
"Mask",
":",
"h",
".",
"IPv6Mask",
"}",
"\n",
"}"
] | // IPv6Net returns a net.IPNet for the host's IPv6 address. | [
"IPv6Net",
"returns",
"a",
"net",
".",
"IPNet",
"for",
"the",
"host",
"s",
"IPv6",
"address",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L101-L103 |
26,350 | google/seesaw | common/seesaw/util.go | IPv4Printable | func (h *Host) IPv4Printable() string {
if h.IPv4Addr == nil {
return "<not configured>"
}
return h.IPv4Net().String()
} | go | func (h *Host) IPv4Printable() string {
if h.IPv4Addr == nil {
return "<not configured>"
}
return h.IPv4Net().String()
} | [
"func",
"(",
"h",
"*",
"Host",
")",
"IPv4Printable",
"(",
")",
"string",
"{",
"if",
"h",
".",
"IPv4Addr",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"h",
".",
"IPv4Net",
"(",
")",
".",
"String",
"(",
")",
"\n",
"}"
] | // IPv4Printable returns a printable representation of the host's IPv4 address. | [
"IPv4Printable",
"returns",
"a",
"printable",
"representation",
"of",
"the",
"host",
"s",
"IPv4",
"address",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L106-L111 |
26,351 | google/seesaw | common/seesaw/util.go | IPv6Printable | func (h *Host) IPv6Printable() string {
if h.IPv6Addr == nil {
return "<not configured>"
}
return h.IPv6Net().String()
} | go | func (h *Host) IPv6Printable() string {
if h.IPv6Addr == nil {
return "<not configured>"
}
return h.IPv6Net().String()
} | [
"func",
"(",
"h",
"*",
"Host",
")",
"IPv6Printable",
"(",
")",
"string",
"{",
"if",
"h",
".",
"IPv6Addr",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"h",
".",
"IPv6Net",
"(",
")",
".",
"String",
"(",
")",
"\n",
"}"
] | // IPv6Printable returns a printable representation of the host's IPv4 address. | [
"IPv6Printable",
"returns",
"a",
"printable",
"representation",
"of",
"the",
"host",
"s",
"IPv4",
"address",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L114-L119 |
26,352 | google/seesaw | common/seesaw/util.go | Copy | func (b *Backend) Copy(c *Backend) {
b.Enabled = c.Enabled
b.InService = c.InService
b.Weight = c.Weight
b.Host.Copy(&c.Host)
} | go | func (b *Backend) Copy(c *Backend) {
b.Enabled = c.Enabled
b.InService = c.InService
b.Weight = c.Weight
b.Host.Copy(&c.Host)
} | [
"func",
"(",
"b",
"*",
"Backend",
")",
"Copy",
"(",
"c",
"*",
"Backend",
")",
"{",
"b",
".",
"Enabled",
"=",
"c",
".",
"Enabled",
"\n",
"b",
".",
"InService",
"=",
"c",
".",
"InService",
"\n",
"b",
".",
"Weight",
"=",
"c",
".",
"Weight",
"\n",
... | // Copy deep copies from the given Seesaw Backend. | [
"Copy",
"deep",
"copies",
"from",
"the",
"given",
"Seesaw",
"Backend",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L122-L127 |
26,353 | google/seesaw | common/seesaw/util.go | Clone | func (b *Backend) Clone() *Backend {
var c Backend
c.Copy(b)
return &c
} | go | func (b *Backend) Clone() *Backend {
var c Backend
c.Copy(b)
return &c
} | [
"func",
"(",
"b",
"*",
"Backend",
")",
"Clone",
"(",
")",
"*",
"Backend",
"{",
"var",
"c",
"Backend",
"\n",
"c",
".",
"Copy",
"(",
"b",
")",
"\n",
"return",
"&",
"c",
"\n",
"}"
] | // Clone creates an identical copy of the given Seesaw Backend. | [
"Clone",
"creates",
"an",
"identical",
"copy",
"of",
"the",
"given",
"Seesaw",
"Backend",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L130-L134 |
26,354 | google/seesaw | common/seesaw/util.go | Copy | func (h *HAConfig) Copy(c *HAConfig) {
h.Enabled = c.Enabled
h.LocalAddr = copyIP(c.LocalAddr)
h.RemoteAddr = copyIP(c.RemoteAddr)
h.Priority = c.Priority
h.VRID = c.VRID
} | go | func (h *HAConfig) Copy(c *HAConfig) {
h.Enabled = c.Enabled
h.LocalAddr = copyIP(c.LocalAddr)
h.RemoteAddr = copyIP(c.RemoteAddr)
h.Priority = c.Priority
h.VRID = c.VRID
} | [
"func",
"(",
"h",
"*",
"HAConfig",
")",
"Copy",
"(",
"c",
"*",
"HAConfig",
")",
"{",
"h",
".",
"Enabled",
"=",
"c",
".",
"Enabled",
"\n",
"h",
".",
"LocalAddr",
"=",
"copyIP",
"(",
"c",
".",
"LocalAddr",
")",
"\n",
"h",
".",
"RemoteAddr",
"=",
... | // Copy deep copies from the given Seesaw HAConfig. | [
"Copy",
"deep",
"copies",
"from",
"the",
"given",
"Seesaw",
"HAConfig",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L142-L148 |
26,355 | google/seesaw | common/seesaw/util.go | Clone | func (h *HAConfig) Clone() *HAConfig {
var c HAConfig
c.Copy(h)
return &c
} | go | func (h *HAConfig) Clone() *HAConfig {
var c HAConfig
c.Copy(h)
return &c
} | [
"func",
"(",
"h",
"*",
"HAConfig",
")",
"Clone",
"(",
")",
"*",
"HAConfig",
"{",
"var",
"c",
"HAConfig",
"\n",
"c",
".",
"Copy",
"(",
"h",
")",
"\n",
"return",
"&",
"c",
"\n",
"}"
] | // Clone creates an identical copy of the given Seesaw HAConfig. | [
"Clone",
"creates",
"an",
"identical",
"copy",
"of",
"the",
"given",
"Seesaw",
"HAConfig",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L151-L155 |
26,356 | google/seesaw | common/seesaw/util.go | Equal | func (h *HAConfig) Equal(other *HAConfig) bool {
return h.Enabled == other.Enabled &&
h.LocalAddr.Equal(other.LocalAddr) &&
h.RemoteAddr.Equal(other.RemoteAddr) &&
h.Priority == other.Priority &&
h.VRID == other.VRID
} | go | func (h *HAConfig) Equal(other *HAConfig) bool {
return h.Enabled == other.Enabled &&
h.LocalAddr.Equal(other.LocalAddr) &&
h.RemoteAddr.Equal(other.RemoteAddr) &&
h.Priority == other.Priority &&
h.VRID == other.VRID
} | [
"func",
"(",
"h",
"*",
"HAConfig",
")",
"Equal",
"(",
"other",
"*",
"HAConfig",
")",
"bool",
"{",
"return",
"h",
".",
"Enabled",
"==",
"other",
".",
"Enabled",
"&&",
"h",
".",
"LocalAddr",
".",
"Equal",
"(",
"other",
".",
"LocalAddr",
")",
"&&",
"h... | // Equal reports whether this HAConfig is equal to the given HAConfig. | [
"Equal",
"reports",
"whether",
"this",
"HAConfig",
"is",
"equal",
"to",
"the",
"given",
"HAConfig",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L158-L164 |
26,357 | google/seesaw | common/seesaw/util.go | String | func (h HAConfig) String() string {
return fmt.Sprintf("Enabled: %v, LocalAddr: %v, RemoteAddr: %v, Priority: %d, VRID: %d",
h.Enabled, h.LocalAddr, h.RemoteAddr, h.Priority, h.VRID)
} | go | func (h HAConfig) String() string {
return fmt.Sprintf("Enabled: %v, LocalAddr: %v, RemoteAddr: %v, Priority: %d, VRID: %d",
h.Enabled, h.LocalAddr, h.RemoteAddr, h.Priority, h.VRID)
} | [
"func",
"(",
"h",
"HAConfig",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"h",
".",
"Enabled",
",",
"h",
".",
"LocalAddr",
",",
"h",
".",
"RemoteAddr",
",",
"h",
".",
"Priority",
",",
"h",
".",
... | // String returns the string representation of an HAConfig. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"an",
"HAConfig",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L167-L170 |
26,358 | google/seesaw | common/seesaw/util.go | String | func (h HAState) String() string {
switch h {
case HAUnknown:
return "Unknown"
case HABackup:
return "Backup"
case HADisabled:
return "Disabled"
case HAError:
return "Error"
case HAMaster:
return "Master"
case HAShutdown:
return "Shutdown"
}
return "(invalid)"
} | go | func (h HAState) String() string {
switch h {
case HAUnknown:
return "Unknown"
case HABackup:
return "Backup"
case HADisabled:
return "Disabled"
case HAError:
return "Error"
case HAMaster:
return "Master"
case HAShutdown:
return "Shutdown"
}
return "(invalid)"
} | [
"func",
"(",
"h",
"HAState",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"h",
"{",
"case",
"HAUnknown",
":",
"return",
"\"",
"\"",
"\n",
"case",
"HABackup",
":",
"return",
"\"",
"\"",
"\n",
"case",
"HADisabled",
":",
"return",
"\"",
"\"",
"\n",... | // String returns the string representation of an HAState. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"an",
"HAState",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L173-L189 |
26,359 | google/seesaw | common/seesaw/util.go | Equal | func (v *VLAN) Equal(other *VLAN) bool {
// Exclude backend and VIP counters from comparison.
return v.ID == other.ID && v.Host.Equal(&other.Host)
} | go | func (v *VLAN) Equal(other *VLAN) bool {
// Exclude backend and VIP counters from comparison.
return v.ID == other.ID && v.Host.Equal(&other.Host)
} | [
"func",
"(",
"v",
"*",
"VLAN",
")",
"Equal",
"(",
"other",
"*",
"VLAN",
")",
"bool",
"{",
"// Exclude backend and VIP counters from comparison.",
"return",
"v",
".",
"ID",
"==",
"other",
".",
"ID",
"&&",
"v",
".",
"Host",
".",
"Equal",
"(",
"&",
"other",... | // Equal reports whether this VLAN is equal to the given VLAN. | [
"Equal",
"reports",
"whether",
"this",
"VLAN",
"is",
"equal",
"to",
"the",
"given",
"VLAN",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L192-L195 |
26,360 | google/seesaw | common/seesaw/util.go | String | func (v *VLAN) String() string {
return fmt.Sprintf("{ID=%d, Host=%s, IPv4=%s, IPv6=%s}", v.ID, v.Hostname, v.IPv4Printable(), v.IPv6Printable())
} | go | func (v *VLAN) String() string {
return fmt.Sprintf("{ID=%d, Host=%s, IPv4=%s, IPv6=%s}", v.ID, v.Hostname, v.IPv4Printable(), v.IPv6Printable())
} | [
"func",
"(",
"v",
"*",
"VLAN",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v",
".",
"ID",
",",
"v",
".",
"Hostname",
",",
"v",
".",
"IPv4Printable",
"(",
")",
",",
"v",
".",
"IPv6Printable",
"... | // String returns the string representation of a VLAN. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"VLAN",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L203-L205 |
26,361 | google/seesaw | common/seesaw/util.go | String | func (sk ServiceKey) String() string {
return fmt.Sprintf("%s %s %d", sk.AF, sk.Proto, sk.Port)
} | go | func (sk ServiceKey) String() string {
return fmt.Sprintf("%s %s %d", sk.AF, sk.Proto, sk.Port)
} | [
"func",
"(",
"sk",
"ServiceKey",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sk",
".",
"AF",
",",
"sk",
".",
"Proto",
",",
"sk",
".",
"Port",
")",
"\n",
"}"
] | // String returns the string representation of a ServiceKey. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"ServiceKey",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L218-L220 |
26,362 | google/seesaw | common/seesaw/util.go | IP | func (d *Destination) IP(af AF) net.IP {
switch af {
case IPv4:
return d.Backend.IPv4Addr
case IPv6:
return d.Backend.IPv6Addr
}
return nil
} | go | func (d *Destination) IP(af AF) net.IP {
switch af {
case IPv4:
return d.Backend.IPv4Addr
case IPv6:
return d.Backend.IPv6Addr
}
return nil
} | [
"func",
"(",
"d",
"*",
"Destination",
")",
"IP",
"(",
"af",
"AF",
")",
"net",
".",
"IP",
"{",
"switch",
"af",
"{",
"case",
"IPv4",
":",
"return",
"d",
".",
"Backend",
".",
"IPv4Addr",
"\n",
"case",
"IPv6",
":",
"return",
"d",
".",
"Backend",
".",... | // IP returns the destination IP address for a given address family. | [
"IP",
"returns",
"the",
"destination",
"IP",
"address",
"for",
"a",
"given",
"address",
"family",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L244-L252 |
26,363 | google/seesaw | common/seesaw/util.go | copyIP | func copyIP(src net.IP) net.IP {
return net.IP(copyBytes(src))
} | go | func copyIP(src net.IP) net.IP {
return net.IP(copyBytes(src))
} | [
"func",
"copyIP",
"(",
"src",
"net",
".",
"IP",
")",
"net",
".",
"IP",
"{",
"return",
"net",
".",
"IP",
"(",
"copyBytes",
"(",
"src",
")",
")",
"\n",
"}"
] | // copyIP creates a copy of an IP. | [
"copyIP",
"creates",
"a",
"copy",
"of",
"an",
"IP",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L262-L264 |
26,364 | google/seesaw | common/seesaw/util.go | copyIPMask | func copyIPMask(src net.IPMask) net.IPMask {
return net.IPMask(copyBytes(src))
} | go | func copyIPMask(src net.IPMask) net.IPMask {
return net.IPMask(copyBytes(src))
} | [
"func",
"copyIPMask",
"(",
"src",
"net",
".",
"IPMask",
")",
"net",
".",
"IPMask",
"{",
"return",
"net",
".",
"IPMask",
"(",
"copyBytes",
"(",
"src",
")",
")",
"\n",
"}"
] | // copyIPMask creates a copy of an IPMask. | [
"copyIPMask",
"creates",
"a",
"copy",
"of",
"an",
"IPMask",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L267-L269 |
26,365 | google/seesaw | common/seesaw/util.go | copyBytes | func copyBytes(src []byte) []byte {
if src == nil {
return nil
}
dst := make([]byte, len(src))
copy(dst, src)
return dst
} | go | func copyBytes(src []byte) []byte {
if src == nil {
return nil
}
dst := make([]byte, len(src))
copy(dst, src)
return dst
} | [
"func",
"copyBytes",
"(",
"src",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"if",
"src",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"dst",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"src",
")",
")",
"\n",
"copy",
"(",
... | // copyBytes creates a copy of a byte slice. | [
"copyBytes",
"creates",
"a",
"copy",
"of",
"a",
"byte",
"slice",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L272-L279 |
26,366 | google/seesaw | common/seesaw/util.go | IsAnycast | func IsAnycast(ip net.IP) bool {
return netIPv4Anycast.Contains(ip) || netIPv6Anycast.Contains(ip)
} | go | func IsAnycast(ip net.IP) bool {
return netIPv4Anycast.Contains(ip) || netIPv6Anycast.Contains(ip)
} | [
"func",
"IsAnycast",
"(",
"ip",
"net",
".",
"IP",
")",
"bool",
"{",
"return",
"netIPv4Anycast",
".",
"Contains",
"(",
"ip",
")",
"||",
"netIPv6Anycast",
".",
"Contains",
"(",
"ip",
")",
"\n",
"}"
] | // IsAnycast reports whether an IP address is an anycast address. | [
"IsAnycast",
"reports",
"whether",
"an",
"IP",
"address",
"is",
"an",
"anycast",
"address",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L282-L284 |
26,367 | google/seesaw | common/seesaw/util.go | InSubnets | func InSubnets(ip net.IP, subnets map[string]*net.IPNet) bool {
for _, subnet := range subnets {
if subnet.Contains(ip) {
return true
}
}
return false
} | go | func InSubnets(ip net.IP, subnets map[string]*net.IPNet) bool {
for _, subnet := range subnets {
if subnet.Contains(ip) {
return true
}
}
return false
} | [
"func",
"InSubnets",
"(",
"ip",
"net",
".",
"IP",
",",
"subnets",
"map",
"[",
"string",
"]",
"*",
"net",
".",
"IPNet",
")",
"bool",
"{",
"for",
"_",
",",
"subnet",
":=",
"range",
"subnets",
"{",
"if",
"subnet",
".",
"Contains",
"(",
"ip",
")",
"{... | // InSubnets reports whether an IP address is in one of a map of subnets. | [
"InSubnets",
"reports",
"whether",
"an",
"IP",
"address",
"is",
"in",
"one",
"of",
"a",
"map",
"of",
"subnets",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/common/seesaw/util.go#L287-L294 |
26,368 | google/seesaw | engine/core.go | NewEngine | func NewEngine(cfg *config.EngineConfig) *Engine {
if cfg == nil {
defaultCfg := config.DefaultEngineConfig()
cfg = &defaultCfg
}
// TODO(jsing): Validate node, peer and cluster IP configuration.
engine := &Engine{
config: cfg,
fwmAlloc: newMarkAllocator(fwmAllocBase, fwmAllocSize),
ncc: ncclient.N... | go | func NewEngine(cfg *config.EngineConfig) *Engine {
if cfg == nil {
defaultCfg := config.DefaultEngineConfig()
cfg = &defaultCfg
}
// TODO(jsing): Validate node, peer and cluster IP configuration.
engine := &Engine{
config: cfg,
fwmAlloc: newMarkAllocator(fwmAllocBase, fwmAllocSize),
ncc: ncclient.N... | [
"func",
"NewEngine",
"(",
"cfg",
"*",
"config",
".",
"EngineConfig",
")",
"*",
"Engine",
"{",
"if",
"cfg",
"==",
"nil",
"{",
"defaultCfg",
":=",
"config",
".",
"DefaultEngineConfig",
"(",
")",
"\n",
"cfg",
"=",
"&",
"defaultCfg",
"\n",
"}",
"\n",
"// T... | // NewEngine returns an initialised Engine struct. | [
"NewEngine",
"returns",
"an",
"initialised",
"Engine",
"struct",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L86-L117 |
26,369 | google/seesaw | engine/core.go | Run | func (e *Engine) Run() {
log.Infof("Seesaw Engine starting for %s", e.config.ClusterName)
e.initNetwork()
n, err := config.NewNotifier(e.config)
if err != nil {
log.Fatalf("config.NewNotifier() failed: %v", err)
}
e.notifier = n
if e.config.AnycastEnabled {
go e.bgpManager.run()
}
go e.hcManager.run()
... | go | func (e *Engine) Run() {
log.Infof("Seesaw Engine starting for %s", e.config.ClusterName)
e.initNetwork()
n, err := config.NewNotifier(e.config)
if err != nil {
log.Fatalf("config.NewNotifier() failed: %v", err)
}
e.notifier = n
if e.config.AnycastEnabled {
go e.bgpManager.run()
}
go e.hcManager.run()
... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"Run",
"(",
")",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"e",
".",
"config",
".",
"ClusterName",
")",
"\n\n",
"e",
".",
"initNetwork",
"(",
")",
"\n\n",
"n",
",",
"err",
":=",
"config",
".",
"NewNot... | // Run starts the Engine. | [
"Run",
"starts",
"the",
"Engine",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L120-L144 |
26,370 | google/seesaw | engine/core.go | haStatus | func (e *Engine) haStatus() seesaw.HAStatus {
e.haManager.statusLock.RLock()
defer e.haManager.statusLock.RUnlock()
return e.haManager.status
} | go | func (e *Engine) haStatus() seesaw.HAStatus {
e.haManager.statusLock.RLock()
defer e.haManager.statusLock.RUnlock()
return e.haManager.status
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"haStatus",
"(",
")",
"seesaw",
".",
"HAStatus",
"{",
"e",
".",
"haManager",
".",
"statusLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"haManager",
".",
"statusLock",
".",
"RUnlock",
"(",
")",
"\n",
"... | // haStatus returns the current HA status from the engine. | [
"haStatus",
"returns",
"the",
"current",
"HA",
"status",
"from",
"the",
"engine",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L152-L156 |
26,371 | google/seesaw | engine/core.go | setHAState | func (e *Engine) setHAState(state seesaw.HAState) {
e.haManager.stateChan <- state
} | go | func (e *Engine) setHAState(state seesaw.HAState) {
e.haManager.stateChan <- state
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"setHAState",
"(",
"state",
"seesaw",
".",
"HAState",
")",
"{",
"e",
".",
"haManager",
".",
"stateChan",
"<-",
"state",
"\n",
"}"
] | // setHAState tells the engine what its current HAState should be. | [
"setHAState",
"tells",
"the",
"engine",
"what",
"its",
"current",
"HAState",
"should",
"be",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L164-L166 |
26,372 | google/seesaw | engine/core.go | setHAStatus | func (e *Engine) setHAStatus(status seesaw.HAStatus) {
e.haManager.statusChan <- status
} | go | func (e *Engine) setHAStatus(status seesaw.HAStatus) {
e.haManager.statusChan <- status
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"setHAStatus",
"(",
"status",
"seesaw",
".",
"HAStatus",
")",
"{",
"e",
".",
"haManager",
".",
"statusChan",
"<-",
"status",
"\n",
"}"
] | // setHAStatus tells the engine what the current HA status is. | [
"setHAStatus",
"tells",
"the",
"engine",
"what",
"the",
"current",
"HA",
"status",
"is",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L169-L171 |
26,373 | google/seesaw | engine/core.go | haConfig | func (e *Engine) haConfig() (*seesaw.HAConfig, error) {
n, err := e.thisNode()
if err != nil {
return nil, err
}
// TODO(jsing): This does not allow for IPv6-only operation.
return &seesaw.HAConfig{
Enabled: n.State != seesaw.HADisabled,
LocalAddr: e.config.Node.IPv4Addr,
RemoteAddr: e.config.VRRPDestI... | go | func (e *Engine) haConfig() (*seesaw.HAConfig, error) {
n, err := e.thisNode()
if err != nil {
return nil, err
}
// TODO(jsing): This does not allow for IPv6-only operation.
return &seesaw.HAConfig{
Enabled: n.State != seesaw.HADisabled,
LocalAddr: e.config.Node.IPv4Addr,
RemoteAddr: e.config.VRRPDestI... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"haConfig",
"(",
")",
"(",
"*",
"seesaw",
".",
"HAConfig",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"e",
".",
"thisNode",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
... | // haConfig returns the HAConfig for an engine. | [
"haConfig",
"returns",
"the",
"HAConfig",
"for",
"an",
"engine",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L174-L187 |
26,374 | google/seesaw | engine/core.go | thisNode | func (e *Engine) thisNode() (*seesaw.Node, error) {
e.clusterLock.RLock()
c := e.cluster
e.clusterLock.RUnlock()
if c == nil {
return nil, fmt.Errorf("cluster configuration not loaded")
}
// TODO(jsing): This does not allow for IPv6-only operation.
ip := e.config.Node.IPv4Addr
for _, n := range c.Nodes {
i... | go | func (e *Engine) thisNode() (*seesaw.Node, error) {
e.clusterLock.RLock()
c := e.cluster
e.clusterLock.RUnlock()
if c == nil {
return nil, fmt.Errorf("cluster configuration not loaded")
}
// TODO(jsing): This does not allow for IPv6-only operation.
ip := e.config.Node.IPv4Addr
for _, n := range c.Nodes {
i... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"thisNode",
"(",
")",
"(",
"*",
"seesaw",
".",
"Node",
",",
"error",
")",
"{",
"e",
".",
"clusterLock",
".",
"RLock",
"(",
")",
"\n",
"c",
":=",
"e",
".",
"cluster",
"\n",
"e",
".",
"clusterLock",
".",
"RUn... | // thisNode returns the Node for the machine on which this engine is running. | [
"thisNode",
"returns",
"the",
"Node",
"for",
"the",
"machine",
"on",
"which",
"this",
"engine",
"is",
"running",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L190-L206 |
26,375 | google/seesaw | engine/core.go | engineIPC | func (e *Engine) engineIPC() {
if err := server.RemoveUnixSocket(e.config.SocketPath); err != nil {
log.Fatalf("Failed to remove socket: %v", err)
}
ln, err := net.Listen("unix", e.config.SocketPath)
if err != nil {
log.Fatalf("Listen failed: %v", err)
}
defer os.Remove(e.config.SocketPath)
seesawIPC := rpc... | go | func (e *Engine) engineIPC() {
if err := server.RemoveUnixSocket(e.config.SocketPath); err != nil {
log.Fatalf("Failed to remove socket: %v", err)
}
ln, err := net.Listen("unix", e.config.SocketPath)
if err != nil {
log.Fatalf("Listen failed: %v", err)
}
defer os.Remove(e.config.SocketPath)
seesawIPC := rpc... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"engineIPC",
"(",
")",
"{",
"if",
"err",
":=",
"server",
".",
"RemoveUnixSocket",
"(",
"e",
".",
"config",
".",
"SocketPath",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"er... | // engineIPC starts an RPC server to handle IPC via a Unix Domain socket. | [
"engineIPC",
"starts",
"an",
"RPC",
"server",
"to",
"handle",
"IPC",
"via",
"a",
"Unix",
"Domain",
"socket",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L209-L226 |
26,376 | google/seesaw | engine/core.go | syncRPC | func (e *Engine) syncRPC() {
// TODO(jsing): Make this default to IPv6, if configured.
addr := &net.TCPAddr{
IP: e.config.Node.IPv4Addr,
Port: e.config.SyncPort,
}
ln, err := net.ListenTCP("tcp", addr)
if err != nil {
log.Fatalf("Listen failed: %v", err)
}
go e.syncServer.serve(ln)
<-e.shutdownRPC
ln... | go | func (e *Engine) syncRPC() {
// TODO(jsing): Make this default to IPv6, if configured.
addr := &net.TCPAddr{
IP: e.config.Node.IPv4Addr,
Port: e.config.SyncPort,
}
ln, err := net.ListenTCP("tcp", addr)
if err != nil {
log.Fatalf("Listen failed: %v", err)
}
go e.syncServer.serve(ln)
<-e.shutdownRPC
ln... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"syncRPC",
"(",
")",
"{",
"// TODO(jsing): Make this default to IPv6, if configured.",
"addr",
":=",
"&",
"net",
".",
"TCPAddr",
"{",
"IP",
":",
"e",
".",
"config",
".",
"Node",
".",
"IPv4Addr",
",",
"Port",
":",
"e",
... | // syncRPC starts a server to handle synchronisation RPCs via a TCP socket. | [
"syncRPC",
"starts",
"a",
"server",
"to",
"handle",
"synchronisation",
"RPCs",
"via",
"a",
"TCP",
"socket",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L229-L245 |
26,377 | google/seesaw | engine/core.go | initNetwork | func (e *Engine) initNetwork() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
if e.config.AnycastEnabled {
if err := e.ncc.BGPWithdrawAll(); err != nil {
log.Fatalf("Failed to withdraw all BGP advertisements: %v", err)
}
}
if err := e.ncc.IPV... | go | func (e *Engine) initNetwork() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
if e.config.AnycastEnabled {
if err := e.ncc.BGPWithdrawAll(); err != nil {
log.Fatalf("Failed to withdraw all BGP advertisements: %v", err)
}
}
if err := e.ncc.IPV... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"initNetwork",
"(",
")",
"{",
"if",
"err",
":=",
"e",
".",
"ncc",
".",
"Dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
"... | // initNetwork initialises the network configuration for load balancing. | [
"initNetwork",
"initialises",
"the",
"network",
"configuration",
"for",
"load",
"balancing",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L248-L280 |
26,378 | google/seesaw | engine/core.go | initAnycast | func (e *Engine) initAnycast() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
vips := make([]*seesaw.VIP, 0)
if e.config.ClusterVIP.IPv4Addr != nil {
for _, ip := range e.config.ServiceAnycastIPv4 {
vips = append(vips, seesaw.NewVIP(ip, nil))
... | go | func (e *Engine) initAnycast() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
vips := make([]*seesaw.VIP, 0)
if e.config.ClusterVIP.IPv4Addr != nil {
for _, ip := range e.config.ServiceAnycastIPv4 {
vips = append(vips, seesaw.NewVIP(ip, nil))
... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"initAnycast",
"(",
")",
"{",
"if",
"err",
":=",
"e",
".",
"ncc",
".",
"Dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
"... | // initAnycast initialises the anycast configuration. | [
"initAnycast",
"initialises",
"the",
"anycast",
"configuration",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L283-L309 |
26,379 | google/seesaw | engine/core.go | gratuitousARP | func (e *Engine) gratuitousARP() {
arpTicker := time.NewTicker(e.config.GratuitousARPInterval)
var announced bool
for {
select {
case <-arpTicker.C:
if e.haManager.state() != seesaw.HAMaster {
if announced {
log.Infof("Stopping gratuitous ARPs for %s", e.config.ClusterVIP.IPv4Addr)
announced = f... | go | func (e *Engine) gratuitousARP() {
arpTicker := time.NewTicker(e.config.GratuitousARPInterval)
var announced bool
for {
select {
case <-arpTicker.C:
if e.haManager.state() != seesaw.HAMaster {
if announced {
log.Infof("Stopping gratuitous ARPs for %s", e.config.ClusterVIP.IPv4Addr)
announced = f... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"gratuitousARP",
"(",
")",
"{",
"arpTicker",
":=",
"time",
".",
"NewTicker",
"(",
"e",
".",
"config",
".",
"GratuitousARPInterval",
")",
"\n",
"var",
"announced",
"bool",
"\n",
"for",
"{",
"select",
"{",
"case",
"<... | // gratuitousARP sends gratuitous ARP messages at regular intervals, if this
// node is the HA master. | [
"gratuitousARP",
"sends",
"gratuitous",
"ARP",
"messages",
"at",
"regular",
"intervals",
"if",
"this",
"node",
"is",
"the",
"HA",
"master",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L313-L344 |
26,380 | google/seesaw | engine/core.go | updateVservers | func (e *Engine) updateVservers() {
e.clusterLock.RLock()
cluster := e.cluster
e.clusterLock.RUnlock()
// Delete vservers that no longer exist in the new configuration.
for name, vserver := range e.vservers {
if cluster.Vservers[name] == nil {
log.Infof("Stopping unconfigured vserver %s", name)
vserver.st... | go | func (e *Engine) updateVservers() {
e.clusterLock.RLock()
cluster := e.cluster
e.clusterLock.RUnlock()
// Delete vservers that no longer exist in the new configuration.
for name, vserver := range e.vservers {
if cluster.Vservers[name] == nil {
log.Infof("Stopping unconfigured vserver %s", name)
vserver.st... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"updateVservers",
"(",
")",
"{",
"e",
".",
"clusterLock",
".",
"RLock",
"(",
")",
"\n",
"cluster",
":=",
"e",
".",
"cluster",
"\n",
"e",
".",
"clusterLock",
".",
"RUnlock",
"(",
")",
"\n\n",
"// Delete vservers tha... | // updateVservers processes a list of vserver configurations then stops
// deleted vservers, spawns new vservers and updates the existing vservers. | [
"updateVservers",
"processes",
"a",
"list",
"of",
"vserver",
"configurations",
"then",
"stops",
"deleted",
"vservers",
"spawns",
"new",
"vservers",
"and",
"updates",
"the",
"existing",
"vservers",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L448-L480 |
26,381 | google/seesaw | engine/core.go | shutdownVservers | func (e *Engine) shutdownVservers() {
for _, v := range e.vservers {
v.stop()
}
for name, v := range e.vservers {
<-v.stopped
delete(e.vservers, name)
}
e.vserverLock.Lock()
e.vserverSnapshots = make(map[string]*seesaw.Vserver)
e.vserverLock.Unlock()
} | go | func (e *Engine) shutdownVservers() {
for _, v := range e.vservers {
v.stop()
}
for name, v := range e.vservers {
<-v.stopped
delete(e.vservers, name)
}
e.vserverLock.Lock()
e.vserverSnapshots = make(map[string]*seesaw.Vserver)
e.vserverLock.Unlock()
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"shutdownVservers",
"(",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"e",
".",
"vservers",
"{",
"v",
".",
"stop",
"(",
")",
"\n",
"}",
"\n",
"for",
"name",
",",
"v",
":=",
"range",
"e",
".",
"vservers",
... | // shutdownVservers shuts down all running vservers. | [
"shutdownVservers",
"shuts",
"down",
"all",
"running",
"vservers",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L483-L494 |
26,382 | google/seesaw | engine/core.go | updateVLANs | func (e *Engine) updateVLANs() {
e.clusterLock.RLock()
cluster := e.cluster
e.clusterLock.RUnlock()
add := make([]*seesaw.VLAN, 0)
remove := make([]*seesaw.VLAN, 0)
e.vlanLock.Lock()
defer e.vlanLock.Unlock()
for key, vlan := range e.vlans {
if cluster.VLANs[key] == nil {
remove = append(remove, vlan)
... | go | func (e *Engine) updateVLANs() {
e.clusterLock.RLock()
cluster := e.cluster
e.clusterLock.RUnlock()
add := make([]*seesaw.VLAN, 0)
remove := make([]*seesaw.VLAN, 0)
e.vlanLock.Lock()
defer e.vlanLock.Unlock()
for key, vlan := range e.vlans {
if cluster.VLANs[key] == nil {
remove = append(remove, vlan)
... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"updateVLANs",
"(",
")",
"{",
"e",
".",
"clusterLock",
".",
"RLock",
"(",
")",
"\n",
"cluster",
":=",
"e",
".",
"cluster",
"\n",
"e",
".",
"clusterLock",
".",
"RUnlock",
"(",
")",
"\n\n",
"add",
":=",
"make",
... | // updateVLANs creates and destroys VLAN interfaces for the load balancer per
// the cluster configuration. | [
"updateVLANs",
"creates",
"and",
"destroys",
"VLAN",
"interfaces",
"for",
"the",
"load",
"balancer",
"per",
"the",
"cluster",
"configuration",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L498-L544 |
26,383 | google/seesaw | engine/core.go | deleteVLANs | func (e *Engine) deleteVLANs() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
e.vlanLock.Lock()
defer e.vlanLock.Unlock()
for k, v := range e.vlans {
if err := e.lbInterface.DeleteVLAN(v); err != nil {
log.Fatalf("Failed to remove VLAN interfa... | go | func (e *Engine) deleteVLANs() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
e.vlanLock.Lock()
defer e.vlanLock.Unlock()
for k, v := range e.vlans {
if err := e.lbInterface.DeleteVLAN(v); err != nil {
log.Fatalf("Failed to remove VLAN interfa... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"deleteVLANs",
"(",
")",
"{",
"if",
"err",
":=",
"e",
".",
"ncc",
".",
"Dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
"... | // deleteVLANs removes all the VLAN interfaces that have been created by this
// engine. | [
"deleteVLANs",
"removes",
"all",
"the",
"VLAN",
"interfaces",
"that",
"have",
"been",
"created",
"by",
"this",
"engine",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L548-L563 |
26,384 | google/seesaw | engine/core.go | handleOverride | func (e *Engine) handleOverride(o seesaw.Override) {
e.overrides[o.Target()] = o
e.distributeOverride(o)
if o.State() == seesaw.OverrideDefault {
delete(e.overrides, o.Target())
}
} | go | func (e *Engine) handleOverride(o seesaw.Override) {
e.overrides[o.Target()] = o
e.distributeOverride(o)
if o.State() == seesaw.OverrideDefault {
delete(e.overrides, o.Target())
}
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"handleOverride",
"(",
"o",
"seesaw",
".",
"Override",
")",
"{",
"e",
".",
"overrides",
"[",
"o",
".",
"Target",
"(",
")",
"]",
"=",
"o",
"\n",
"e",
".",
"distributeOverride",
"(",
"o",
")",
"\n",
"if",
"o",
... | // handleOverride handles an incoming Override. | [
"handleOverride",
"handles",
"an",
"incoming",
"Override",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L566-L572 |
26,385 | google/seesaw | engine/core.go | distributeOverride | func (e *Engine) distributeOverride(o seesaw.Override) {
// Send VserverOverrides and DestinationOverrides to the appropriate vserver.
// Send BackendOverrides to all vservers.
switch override := o.(type) {
case *seesaw.VserverOverride:
if vserver, ok := e.vservers[override.VserverName]; ok {
vserver.queueOver... | go | func (e *Engine) distributeOverride(o seesaw.Override) {
// Send VserverOverrides and DestinationOverrides to the appropriate vserver.
// Send BackendOverrides to all vservers.
switch override := o.(type) {
case *seesaw.VserverOverride:
if vserver, ok := e.vservers[override.VserverName]; ok {
vserver.queueOver... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"distributeOverride",
"(",
"o",
"seesaw",
".",
"Override",
")",
"{",
"// Send VserverOverrides and DestinationOverrides to the appropriate vserver.",
"// Send BackendOverrides to all vservers.",
"switch",
"override",
":=",
"o",
".",
"("... | // distributeOverride distributes an Override to the appropriate vservers. | [
"distributeOverride",
"distributes",
"an",
"Override",
"to",
"the",
"appropriate",
"vservers",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L575-L592 |
26,386 | google/seesaw | engine/core.go | becomeMaster | func (e *Engine) becomeMaster() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
e.syncClient.disable()
e.hcManager.enable()
e.notifier.SetSource(config.SourceServer)
if err := e.lbInterface.Up(); err != nil {
log.Fatalf("Failed to bring LB interf... | go | func (e *Engine) becomeMaster() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
e.syncClient.disable()
e.hcManager.enable()
e.notifier.SetSource(config.SourceServer)
if err := e.lbInterface.Up(); err != nil {
log.Fatalf("Failed to bring LB interf... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"becomeMaster",
"(",
")",
"{",
"if",
"err",
":=",
"e",
".",
"ncc",
".",
"Dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
... | // becomeMaster performs the necessary actions for the Seesaw Engine to
// become the master node. | [
"becomeMaster",
"performs",
"the",
"necessary",
"actions",
"for",
"the",
"Seesaw",
"Engine",
"to",
"become",
"the",
"master",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L596-L609 |
26,387 | google/seesaw | engine/core.go | becomeBackup | func (e *Engine) becomeBackup() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
e.syncClient.enable()
e.hcManager.disable()
e.notifier.SetSource(config.SourcePeer)
if err := e.lbInterface.Down(); err != nil {
log.Fatalf("Failed to bring LB interf... | go | func (e *Engine) becomeBackup() {
if err := e.ncc.Dial(); err != nil {
log.Fatalf("Failed to connect to NCC: %v", err)
}
defer e.ncc.Close()
e.syncClient.enable()
e.hcManager.disable()
e.notifier.SetSource(config.SourcePeer)
if err := e.lbInterface.Down(); err != nil {
log.Fatalf("Failed to bring LB interf... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"becomeBackup",
"(",
")",
"{",
"if",
"err",
":=",
"e",
".",
"ncc",
".",
"Dial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
... | // becomeBackup performs the neccesary actions for the Seesaw Engine to
// stop being the master node and become the backup node. | [
"becomeBackup",
"performs",
"the",
"neccesary",
"actions",
"for",
"the",
"Seesaw",
"Engine",
"to",
"stop",
"being",
"the",
"master",
"node",
"and",
"become",
"the",
"backup",
"node",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L613-L631 |
26,388 | google/seesaw | engine/core.go | newMarkAllocator | func newMarkAllocator(base, size int) *markAllocator {
ma := &markAllocator{
marks: make([]uint32, 0, size),
}
for i := 0; i < size; i++ {
ma.put(uint32(base + i))
}
return ma
} | go | func newMarkAllocator(base, size int) *markAllocator {
ma := &markAllocator{
marks: make([]uint32, 0, size),
}
for i := 0; i < size; i++ {
ma.put(uint32(base + i))
}
return ma
} | [
"func",
"newMarkAllocator",
"(",
"base",
",",
"size",
"int",
")",
"*",
"markAllocator",
"{",
"ma",
":=",
"&",
"markAllocator",
"{",
"marks",
":",
"make",
"(",
"[",
"]",
"uint32",
",",
"0",
",",
"size",
")",
",",
"}",
"\n",
"for",
"i",
":=",
"0",
... | // newMarkAllocator returns a mark allocator initialised with the specified
// base and size. | [
"newMarkAllocator",
"returns",
"a",
"mark",
"allocator",
"initialised",
"with",
"the",
"specified",
"base",
"and",
"size",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L641-L649 |
26,389 | google/seesaw | engine/core.go | get | func (ma *markAllocator) get() (uint32, error) {
ma.lock.Lock()
defer ma.lock.Unlock()
if len(ma.marks) == 0 {
return 0, errors.New("allocator exhausted")
}
mark := ma.marks[0]
ma.marks = ma.marks[1:]
return mark, nil
} | go | func (ma *markAllocator) get() (uint32, error) {
ma.lock.Lock()
defer ma.lock.Unlock()
if len(ma.marks) == 0 {
return 0, errors.New("allocator exhausted")
}
mark := ma.marks[0]
ma.marks = ma.marks[1:]
return mark, nil
} | [
"func",
"(",
"ma",
"*",
"markAllocator",
")",
"get",
"(",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"ma",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ma",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"len",
"(",
"ma",
".",
"mar... | // get returns the next available mark from the mark allocator. | [
"get",
"returns",
"the",
"next",
"available",
"mark",
"from",
"the",
"mark",
"allocator",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L652-L661 |
26,390 | google/seesaw | engine/core.go | put | func (ma *markAllocator) put(mark uint32) {
ma.lock.Lock()
defer ma.lock.Unlock()
ma.marks = append(ma.marks, mark)
} | go | func (ma *markAllocator) put(mark uint32) {
ma.lock.Lock()
defer ma.lock.Unlock()
ma.marks = append(ma.marks, mark)
} | [
"func",
"(",
"ma",
"*",
"markAllocator",
")",
"put",
"(",
"mark",
"uint32",
")",
"{",
"ma",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ma",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"ma",
".",
"marks",
"=",
"append",
"(",
"ma",
".",
... | // put returns the specified mark to the mark allocator. | [
"put",
"returns",
"the",
"specified",
"mark",
"to",
"the",
"mark",
"allocator",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/core.go#L664-L668 |
26,391 | google/seesaw | ecu/auth.go | authenticate | func (e *ECU) authenticate(ctx *ipc.Context) (*ipc.Context, error) {
return nil, errors.New("unimplemented")
} | go | func (e *ECU) authenticate(ctx *ipc.Context) (*ipc.Context, error) {
return nil, errors.New("unimplemented")
} | [
"func",
"(",
"e",
"*",
"ECU",
")",
"authenticate",
"(",
"ctx",
"*",
"ipc",
".",
"Context",
")",
"(",
"*",
"ipc",
".",
"Context",
",",
"error",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // authenticate attempts to validate the given authentication token. | [
"authenticate",
"attempts",
"to",
"validate",
"the",
"given",
"authentication",
"token",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ecu/auth.go#L36-L38 |
26,392 | google/seesaw | ecu/auth.go | authConnect | func (e *ECU) authConnect(ctx *ipc.Context) (*conn.Seesaw, error) {
if ctx == nil {
return nil, errors.New("context is nil")
}
authCtx, err := e.authenticate(ctx)
if err != nil {
return nil, fmt.Errorf("authentication failed: %v", err)
}
seesawConn, err := conn.NewSeesawIPC(authCtx)
if err != nil {
return... | go | func (e *ECU) authConnect(ctx *ipc.Context) (*conn.Seesaw, error) {
if ctx == nil {
return nil, errors.New("context is nil")
}
authCtx, err := e.authenticate(ctx)
if err != nil {
return nil, fmt.Errorf("authentication failed: %v", err)
}
seesawConn, err := conn.NewSeesawIPC(authCtx)
if err != nil {
return... | [
"func",
"(",
"e",
"*",
"ECU",
")",
"authConnect",
"(",
"ctx",
"*",
"ipc",
".",
"Context",
")",
"(",
"*",
"conn",
".",
"Seesaw",
",",
"error",
")",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
... | // authConnect attempts to authenticate the user using the given context. If
// authentication succeeds an authenticated IPC connection to the Seesaw
// Engine is returned. | [
"authConnect",
"attempts",
"to",
"authenticate",
"the",
"user",
"using",
"the",
"given",
"context",
".",
"If",
"authentication",
"succeeds",
"an",
"authenticated",
"IPC",
"connection",
"to",
"the",
"Seesaw",
"Engine",
"is",
"returned",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ecu/auth.go#L43-L61 |
26,393 | google/seesaw | binaries/seesaw_cli/main.go | commandChain | func commandChain(chain []*cli.Command, args []string) string {
s := make([]string, 0)
for _, c := range chain {
s = append(s, c.Command)
}
s = append(s, args...)
if len(s) > 0 && len(args) == 0 {
s = append(s, "")
}
return strings.Join(s, " ")
} | go | func commandChain(chain []*cli.Command, args []string) string {
s := make([]string, 0)
for _, c := range chain {
s = append(s, c.Command)
}
s = append(s, args...)
if len(s) > 0 && len(args) == 0 {
s = append(s, "")
}
return strings.Join(s, " ")
} | [
"func",
"commandChain",
"(",
"chain",
"[",
"]",
"*",
"cli",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"string",
"{",
"s",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"chain",
"{",... | // commandChain builds a command chain from the given command slice. | [
"commandChain",
"builds",
"a",
"command",
"chain",
"from",
"the",
"given",
"command",
"slice",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/binaries/seesaw_cli/main.go#L93-L103 |
26,394 | google/seesaw | binaries/seesaw_cli/main.go | autoComplete | func autoComplete(line string, pos int, key rune) (string, int, bool) {
switch key {
case 0x01: // Ctrl-A
return line, 0, true
case 0x03: // Ctrl-C
exit()
case 0x05: // Ctrl-E
return line, len(line), true
case 0x09: // Ctrl-I (Tab)
_, _, chain, args := cli.FindCommand(string(line))
line := commandChain(c... | go | func autoComplete(line string, pos int, key rune) (string, int, bool) {
switch key {
case 0x01: // Ctrl-A
return line, 0, true
case 0x03: // Ctrl-C
exit()
case 0x05: // Ctrl-E
return line, len(line), true
case 0x09: // Ctrl-I (Tab)
_, _, chain, args := cli.FindCommand(string(line))
line := commandChain(c... | [
"func",
"autoComplete",
"(",
"line",
"string",
",",
"pos",
"int",
",",
"key",
"rune",
")",
"(",
"string",
",",
"int",
",",
"bool",
")",
"{",
"switch",
"key",
"{",
"case",
"0x01",
":",
"// Ctrl-A",
"return",
"line",
",",
"0",
",",
"true",
"\n",
"cas... | // autoComplete attempts to complete the user's input when certain
// characters are typed. | [
"autoComplete",
"attempts",
"to",
"complete",
"the",
"user",
"s",
"input",
"when",
"certain",
"characters",
"are",
"typed",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/binaries/seesaw_cli/main.go#L107-L143 |
26,395 | google/seesaw | binaries/seesaw_cli/main.go | interactive | func interactive() {
status, err := seesawConn.ClusterStatus()
if err != nil {
fatalf("Failed to get cluster status: %v", err)
}
fmt.Printf("\nSeesaw CLI - Engine version %d\n\n", status.Version)
u, err := user.Current()
if err != nil {
fatalf("Failed to get current user: %v", err)
}
ha, err := seesawConn... | go | func interactive() {
status, err := seesawConn.ClusterStatus()
if err != nil {
fatalf("Failed to get cluster status: %v", err)
}
fmt.Printf("\nSeesaw CLI - Engine version %d\n\n", status.Version)
u, err := user.Current()
if err != nil {
fatalf("Failed to get current user: %v", err)
}
ha, err := seesawConn... | [
"func",
"interactive",
"(",
")",
"{",
"status",
",",
"err",
":=",
"seesawConn",
".",
"ClusterStatus",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\... | // interactive invokes the interactive CLI interface. | [
"interactive",
"invokes",
"the",
"interactive",
"CLI",
"interface",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/binaries/seesaw_cli/main.go#L146-L191 |
26,396 | google/seesaw | ipvs/ipvs.go | newIPVSService | func newIPVSService(svc *Service) *ipvsService {
ipvsSvc := &ipvsService{
Address: svc.Address,
Protocol: svc.Protocol,
Port: svc.Port,
FirewallMark: svc.FirewallMark,
Scheduler: svc.Scheduler,
Flags: svc.Flags,
Timeout: svc.Timeout,
Pe... | go | func newIPVSService(svc *Service) *ipvsService {
ipvsSvc := &ipvsService{
Address: svc.Address,
Protocol: svc.Protocol,
Port: svc.Port,
FirewallMark: svc.FirewallMark,
Scheduler: svc.Scheduler,
Flags: svc.Flags,
Timeout: svc.Timeout,
Pe... | [
"func",
"newIPVSService",
"(",
"svc",
"*",
"Service",
")",
"*",
"ipvsService",
"{",
"ipvsSvc",
":=",
"&",
"ipvsService",
"{",
"Address",
":",
"svc",
".",
"Address",
",",
"Protocol",
":",
"svc",
".",
"Protocol",
",",
"Port",
":",
"svc",
".",
"Port",
","... | // newIPVSService converts a service to its IPVS representation. | [
"newIPVSService",
"converts",
"a",
"service",
"to",
"its",
"IPVS",
"representation",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L81-L102 |
26,397 | google/seesaw | ipvs/ipvs.go | newIPVSDestination | func newIPVSDestination(dst *Destination) *ipvsDestination {
return &ipvsDestination{
Address: dst.Address,
Port: dst.Port,
Flags: dst.Flags,
Weight: uint32(dst.Weight),
UpperThreshold: dst.UpperThreshold,
LowerThreshold: dst.LowerThreshold,
}
} | go | func newIPVSDestination(dst *Destination) *ipvsDestination {
return &ipvsDestination{
Address: dst.Address,
Port: dst.Port,
Flags: dst.Flags,
Weight: uint32(dst.Weight),
UpperThreshold: dst.UpperThreshold,
LowerThreshold: dst.LowerThreshold,
}
} | [
"func",
"newIPVSDestination",
"(",
"dst",
"*",
"Destination",
")",
"*",
"ipvsDestination",
"{",
"return",
"&",
"ipvsDestination",
"{",
"Address",
":",
"dst",
".",
"Address",
",",
"Port",
":",
"dst",
".",
"Port",
",",
"Flags",
":",
"dst",
".",
"Flags",
",... | // newIPVSDestination converts a destination to its IPVS representation. | [
"newIPVSDestination",
"converts",
"a",
"destination",
"to",
"its",
"IPVS",
"representation",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L105-L114 |
26,398 | google/seesaw | ipvs/ipvs.go | toService | func (ipvsSvc ipvsService) toService() *Service {
svc := &Service{
Address: ipvsSvc.Address,
Protocol: ipvsSvc.Protocol,
Port: ipvsSvc.Port,
FirewallMark: ipvsSvc.FirewallMark,
Scheduler: ipvsSvc.Scheduler,
Flags: ipvsSvc.Flags,
Timeout: ... | go | func (ipvsSvc ipvsService) toService() *Service {
svc := &Service{
Address: ipvsSvc.Address,
Protocol: ipvsSvc.Protocol,
Port: ipvsSvc.Port,
FirewallMark: ipvsSvc.FirewallMark,
Scheduler: ipvsSvc.Scheduler,
Flags: ipvsSvc.Flags,
Timeout: ... | [
"func",
"(",
"ipvsSvc",
"ipvsService",
")",
"toService",
"(",
")",
"*",
"Service",
"{",
"svc",
":=",
"&",
"Service",
"{",
"Address",
":",
"ipvsSvc",
".",
"Address",
",",
"Protocol",
":",
"ipvsSvc",
".",
"Protocol",
",",
"Port",
":",
"ipvsSvc",
".",
"Po... | // toService converts a service entry from its IPVS representation to the Go
// equivalent Service structure. | [
"toService",
"converts",
"a",
"service",
"entry",
"from",
"its",
"IPVS",
"representation",
"to",
"the",
"Go",
"equivalent",
"Service",
"structure",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L118-L147 |
26,399 | google/seesaw | ipvs/ipvs.go | toDestination | func (ipvsDst ipvsDestination) toDestination() *Destination {
dst := &Destination{
Address: ipvsDst.Address,
Port: ipvsDst.Port,
Weight: int32(ipvsDst.Weight), // TODO(jsing): uint32?
Flags: ipvsDst.Flags,
LowerThreshold: ipvsDst.LowerThreshold,
UpperThreshold: ipvsDst.Upp... | go | func (ipvsDst ipvsDestination) toDestination() *Destination {
dst := &Destination{
Address: ipvsDst.Address,
Port: ipvsDst.Port,
Weight: int32(ipvsDst.Weight), // TODO(jsing): uint32?
Flags: ipvsDst.Flags,
LowerThreshold: ipvsDst.LowerThreshold,
UpperThreshold: ipvsDst.Upp... | [
"func",
"(",
"ipvsDst",
"ipvsDestination",
")",
"toDestination",
"(",
")",
"*",
"Destination",
"{",
"dst",
":=",
"&",
"Destination",
"{",
"Address",
":",
"ipvsDst",
".",
"Address",
",",
"Port",
":",
"ipvsDst",
".",
"Port",
",",
"Weight",
":",
"int32",
"(... | // toDestination converts a destination entry from its IPVS representation
// to the Go equivalent Destination structure. | [
"toDestination",
"converts",
"a",
"destination",
"entry",
"from",
"its",
"IPVS",
"representation",
"to",
"the",
"Go",
"equivalent",
"Destination",
"structure",
"."
] | 34716af0775ecb1fad239a726390d63d6b0742dd | https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ipvs/ipvs.go#L151-L171 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.