Documentation
¶
Index ¶
- Constants
- Variables
- func AddSyslogHook()
- func AddSyslogHookToLogger(logger *log.Logger)
- func CopyFileContents(src, dst string) (err error)
- func DirectWriteJson(ctx context.Context, file string, obj interface{}) (err error)
- func EnforcePermission(dirPath string) error
- func False() *bool
- func FileExists(path string) bool
- func FindFirstLogPath(logs []string) string
- func FindFirstLogrotateConflict() (bool, string)
- func GetCallerName() string
- func HasGraphicalSession() bool
- func InitLog(logLevel string, logs ...string) error
- func InitLogger(logger *log.Logger, logLevel string, logs ...string) error
- func IsAdmin() bool
- func ListFiles(dir, pattern string) ([]string, error)
- func OpenBrowser(url string) error
- func ReadJson(file string, res interface{}) (interface{}, error)
- func ReadJsonWithEnvSub(file string, res interface{}) (interface{}, error)
- func RemoveJson(file string) error
- func Retry(attempts int, sleep time.Duration, toExec func() error, onError func(e error)) error
- func ReturnBoolWithDefaultFalse(b *bool) bool
- func ReturnBoolWithDefaultTrue(b *bool) bool
- func SameServiceURL(a, b *url.URL) bool
- func SameServiceURLStrings(a, b string) bool
- func ServiceURLPort(u *url.URL) string
- func SetLogOutputs(logger *log.Logger, logs ...string) error
- func SliceDiff(x, y []string) []string
- func True() *bool
- func WriteBytesWithRestrictedPermission(ctx context.Context, file string, bs []byte) error
- func WriteJson(ctx context.Context, file string, obj interface{}) error
- func WriteJsonWithRestrictedPermission(ctx context.Context, file string, obj interface{}) error
- type Duration
Constants ¶
const ( LogConsole = "console" LogSyslog = "syslog" )
Variables ¶
var ( SpecialLogs = []string{ LogSyslog, LogConsole, } )
Functions ¶
func AddSyslogHook ¶ added in v0.28.5
func AddSyslogHook()
func AddSyslogHookToLogger ¶ added in v0.65.0
func CopyFileContents ¶
CopyFileContents copies contents of the given src file to the dst file
func DirectWriteJson ¶ added in v0.23.3
DirectWriteJson writes JSON config object to a file creating parent directories if required without creating a temporary file
func EnforcePermission ¶ added in v0.29.3
func False ¶ added in v0.26.0
func False() *bool
False returns a *bool whose underlying value is false.
func FileExists ¶ added in v0.8.1
FileExists returns true if specified file exists
func FindFirstLogPath ¶ added in v0.52.0
FindFirstLogPath returns the first logs entry that could be a log path, that is neither empty, nor a special value
func FindFirstLogrotateConflict ¶ added in v0.72.0
FindLogrotateConflicts scans the standard logrotate locations for indications of conflict with netbird. It returns true and the config file path if a conflict was found.
func GetCallerName ¶ added in v0.52.0
func GetCallerName() string
func HasGraphicalSession ¶ added in v0.77.1
func HasGraphicalSession() bool
HasGraphicalSession reports whether this process can open a browser and serve a loopback redirect back to it. Windows and macOS always can. On Linux and FreeBSD the answer is env based, so it only holds for a process started from the graphical session itself: a service does not inherit those variables and always reports false, which is why callers running in the user's session pass their own answer to the daemon.
func InitLogger ¶ added in v0.65.0
InitLogger parses and sets log-level input for a logrus logger
func ListFiles ¶ added in v0.52.0
ListFiles returns the full paths of all files in dir that match pattern. Pattern uses shell-style globbing (e.g. "*.json").
func OpenBrowser ¶ added in v0.60.3
OpenBrowser opens the URL in a browser, respecting the BROWSER environment variable.
func ReadJsonWithEnvSub ¶ added in v0.30.1
ReadJsonWithEnvSub reads JSON config file and maps to a provided interface with environment variable substitution
func RemoveJson ¶ added in v0.52.0
RemoveJson removes the specified JSON file if it exists
func Retry ¶
Retry retries a given toExec function calling onError on failed attempts onError shouldn be a lightweight function and shouldn't be blocking
func ReturnBoolWithDefaultFalse ¶ added in v0.26.0
Return bool representation if the bool pointer is non-nil, otherwise returns false
func ReturnBoolWithDefaultTrue ¶ added in v0.26.0
Return bool representation if the bool pointer is non-nil, otherwise returns true
func SameServiceURL ¶ added in v0.79.0
SameServiceURL reports whether two service URLs address the same endpoint. One endpoint can be written several ways, and every spelling below reaches the same server, so none of them is a divergence from another:
an implicit default port https://mgmt.example.com :443 a zero-padded port https://mgmt.example.com:0443 a different host case https://MGMT.example.com a trailing slash https://mgmt.example.com/
A path is otherwise part of the identity: https://mgmt.example.com and https://mgmt.example.com/other are two endpoints.
It lives here rather than next to any one caller because several of them compare the same kind of URL — an MDM-enforced management URL against a requested one, a stored profile URL against a command-line one — and every copy of these rules that drifts turns an equivalent URL into a refused request.
func SameServiceURLStrings ¶ added in v0.79.0
SameServiceURLStrings is SameServiceURL for unparsed input. Input that does not parse falls back to string equality, which is the strictest thing left to do with it.
func ServiceURLPort ¶ added in v0.79.0
ServiceURLPort is the port a URL addresses: the one it carries, normalized numerically so ":0443" and ":443" are one port, or the scheme's default.
func SetLogOutputs ¶ added in v0.75.0
SetLogOutputs re-points an already-initialized logger to the given targets (console/syslog/file), with the same target semantics as InitLogger, but without re-parsing the level or resetting the formatter. The desktop GUI uses it to attach the rotated gui-client.log alongside the console when the daemon enters debug, and drop back to console-only when it leaves.
func WriteBytesWithRestrictedPermission ¶ added in v0.32.0
Types ¶
type Duration ¶
Duration is used strictly for JSON requests/responses due to duration marshalling issues
func (Duration) MarshalJSON ¶
func (*Duration) UnmarshalJSON ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package capture provides userspace packet capture in pcap format.
|
Package capture provides userspace packet capture in pcap format. |
|
Package netrelay provides a bidirectional byte-copy helper for TCP-like connections with correct half-close propagation.
|
Package netrelay provides a bidirectional byte-copy helper for TCP-like connections with correct half-close propagation. |