-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclientstate.go
58 lines (47 loc) · 1.49 KB
/
clientstate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// CGo binding for Avahi
//
// Copyright (C) 2024 and up by Alexander Pevzner ([email protected])
// See LICENSE for license terms and conditions
//
// Avahi Client State
//
//go:build linux || freebsd
package avahi
import "fmt"
// #include <avahi-client/client.h>
import "C"
// ClientState represents a [Client] state.
type ClientState int
// ClientState values:
const (
// Avahi server is being registering host RRs on a network
ClientStateRegistering ClientState = C.AVAHI_CLIENT_S_REGISTERING
// Ahavi server is up and running
ClientStateRunning ClientState = C.AVAHI_CLIENT_S_RUNNING
// Avahi server was not able to register host RRs due to collision
// with some another host.
//
// Administrator needs to update the host name to avoid the
// collision.
ClientStateCollision ClientState = C.AVAHI_CLIENT_S_COLLISION
// Avahi server failure.
ClientStateFailure ClientState = C.AVAHI_CLIENT_FAILURE
// Avahi Client is trying to connect the server.
ClientStateConnecting ClientState = C.AVAHI_CLIENT_CONNECTING
)
// clientStateNames contains names for known client states.
var clientStateNames = map[ClientState]string{
ClientStateRegistering: "registering",
ClientStateRunning: "running",
ClientStateCollision: "collision",
ClientStateFailure: "failure",
ClientStateConnecting: "connecting",
}
// String returns name of the ClientState.
func (state ClientState) String() string {
n := clientStateNames[state]
if n == "" {
n = fmt.Sprintf("UNKNOWN %d", int(state))
}
return n
}