]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/cypherpunks.ru/govpn/conf.go
Upgrade Client
[govpn.git] / src / cypherpunks.ru / govpn / conf.go
index c8232d64b047a91644b47111b8cf6db8384613b0..825a0cf87327d48c10b8e551d24954dde9c49e21 100644 (file)
@@ -21,26 +21,48 @@ package govpn
 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
 }