]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/cypherpunks.ru/govpn/client/client.go
It is better to work directly with structs, returning pointer when necessary
[govpn.git] / src / cypherpunks.ru / govpn / client / client.go
index cfeba815de38bf0585a974aa0ea4311c540b688d..76635a88ec9a9e84e8b456e53943e4cc518a08da 100644 (file)
@@ -27,7 +27,8 @@ type Configuration struct {
        ProxyAddress        string
        ProxyAuthentication string
        RemoteAddress       string
-       UpPath, DownPath    string
+       UpPath              string
+       DownPath            string
        StatsAddress        string
        NoReconnect         bool
        MTU                 int
@@ -62,7 +63,7 @@ type Client struct {
        termSignal    chan os.Signal
        config        Configuration
 
-       // Error receive any error of all routines
+       // Error channel receives any kind of routine errors
        Error chan error
 }
 
@@ -103,7 +104,7 @@ MainCycle:
                case <-c.termSignal:
                        govpn.BothPrintf(`[finish remote="%s"]`, c.config.RemoteAddress)
                        c.termination <- struct{}{}
-                       // send a non-error to let know everything went fine
+                       // empty value signals that everything is fine
                        c.Error <- nil
                        break MainCycle
                case <-c.timeouted:
@@ -118,13 +119,17 @@ MainCycle:
                close(c.rehandshaking)
                close(c.termination)
        }
-       if _, err = govpn.ScriptCall(c.config.DownPath, c.config.InterfaceName, c.config.RemoteAddress); err != nil {
+       if _, err = govpn.ScriptCall(
+               c.config.DownPath,
+               c.config.InterfaceName,
+               c.config.RemoteAddress,
+       ); err != nil {
                c.Error <- err
        }
 }
 
 func NewClient(conf Configuration, verifier *govpn.Verifier, termSignal chan os.Signal) *Client {
-       client := &Client{
+       client := Client{
                idsCache:    govpn.NewMACCache(),
                firstUpCall: true,
                config:      conf,
@@ -133,5 +138,5 @@ func NewClient(conf Configuration, verifier *govpn.Verifier, termSignal chan os.
        }
        confs := map[govpn.PeerId]*govpn.PeerConf{*verifier.Id: conf.Peer}
        client.idsCache.Update(&confs)
-       return client
+       return &client
 }