import (
"time"
+ "github.com/Sirupsen/logrus"
"github.com/agl/ed25519"
)
+// PeerConf is configuration of a single GoVPN Peer (client)
type PeerConf struct {
- ID *PeerID `yaml:"-"`
- Name string `yaml:"name"`
- Iface string `yaml:"iface"`
- MTU int `yaml:"mtu"`
- Up string `yaml:"up"`
- Down string `yaml:"down"`
- TimeoutInt int `yaml:"timeout"`
- Timeout time.Duration `yaml:"-"`
- Noise bool `yaml:"noise"`
- CPR int `yaml:"cpr"`
- Encless bool `yaml:"encless"`
- TimeSync int `yaml:"timesync"`
- VerifierRaw string `yaml:"verifier"`
-
- // This is passphrase verifier
- Verifier *Verifier `yaml:"-"`
+ ID *PeerID
+ Name string
+ Iface string
+ MTU int
+ PreUp TunnelPreUpAction
+ Up TunnelAction
+ Down TunnelAction
+ Timeout time.Duration
+ Noise bool
+ CPR int
+ Encless bool
+ TimeSync int
+
+ // This is passphrase verifier, client side only
+ Verifier *Verifier
// This field exists only on client's side
- DSAPriv *[ed25519.PrivateKeySize]byte `yaml:"-"`
+ DSAPriv *[ed25519.PrivateKeySize]byte
+}
+
+// LogFields return a logrus compatible logging context
+func (pc *PeerConf) LogFields(rootPrefix string) logrus.Fields {
+ p := rootPrefix + "peerconf_"
+ output := logrus.Fields{
+ p + "peer_name": pc.Name,
+ p + "mtu": pc.MTU,
+ p + "noise": pc.Noise,
+ p + "pcr": pc.CPR,
+ p + "encless": pc.Encless,
+ p + "timesync": pc.TimeSync,
+ p + "timeout": pc.Timeout.String(),
+ p + "pre_up": pc.PreUp != nil,
+ p + "up": pc.Up != nil,
+ p + "down": pc.Down != nil,
+ }
+ if pc.ID != nil {
+ output[p+"id"] = pc.ID.String()
+ }
+ return output
}