]> Cypherpunks.ru repositories - govpn.git/commitdiff
Copyright and stylistic changes
authorSergey Matveev <stargrave@stargrave.org>
Sat, 25 Feb 2017 08:15:18 +0000 (11:15 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 25 Feb 2017 08:23:45 +0000 (11:23 +0300)
src/cypherpunks.ru/govpn/action.go
src/cypherpunks.ru/govpn/client/client.go
src/cypherpunks.ru/govpn/client/proxy.go
src/cypherpunks.ru/govpn/client/udp.go
src/cypherpunks.ru/govpn/cmd/govpn-client/main.go
src/cypherpunks.ru/govpn/conf.go

index 5ad35b2fb33ed2bf605a1c8e886c935379157674..5251dd3dd6cf05f028ed3bd312dc0e4475a06faa 100644 (file)
@@ -1,6 +1,7 @@
 /*
 GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
+              2016-2017 Bruno Clermont <bruno@robotinfra.com>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -25,7 +26,7 @@ import (
        "github.com/pkg/errors"
 )
 
-// PeerContext hold info about a peer that connect or disconnect
+// PeerContext holds info about a peer that connect or disconnect
 // used for Up, PreUp and Down
 type PeerContext struct {
        RemoteAddress string
@@ -41,7 +42,7 @@ type TunnelAction func(PeerContext) error
 // after user is authenticated
 type TunnelPreUpAction func(PeerContext) (*TAP, error)
 
-// RunScriptAction convert the path to a script into a TunnelAction
+// RunScriptAction converts the path to a script into a TunnelAction
 func RunScriptAction(path *string) TunnelAction {
        if path == nil {
                return nil
@@ -52,7 +53,7 @@ func RunScriptAction(path *string) TunnelAction {
        }
 }
 
-// ScriptCall call external program/script.
+// ScriptCall calls external program/script.
 // You have to specify path to it and (inteface name as a rule) something
 // that will be the first argument when calling it. Function will return
 // it's output and possible error.
index d04dc6b1171d055871ad582a7dd31c3736c65bef..4ebd8a98fa47e1eb5955971f2d1c83c47e20dfe6 100644 (file)
@@ -40,8 +40,8 @@ type Configuration struct {
        ProxyAuthentication string
        RemoteAddress       string
        NoReconnect         bool
-       // FileDescriptor allow to create a Client from a pre-existing file descriptor.
-       // Required for Android. requires TCP protocol
+       // FileDescriptor allows creating Client from a pre-existing file
+       // descriptor. Required for Android. Requires TCP transport.
        FileDescriptor int
 }
 
@@ -54,18 +54,21 @@ func (c *Configuration) Validate() error {
                return errors.New("Missing RemoteAddress")
        }
        if len(c.Peer.Iface) == 0 && c.Peer.PreUp == nil {
-               return errors.New("Missing InterfaceName *or* PreUp")
+               return errors.New("Missing InterfaceName or PreUp")
        }
        if c.Protocol != govpn.ProtocolTCP && c.Protocol != govpn.ProtocolUDP {
                return errors.Errorf("Invalid protocol %d for client", c.Protocol)
        }
        if c.FileDescriptor > 0 && c.Protocol != govpn.ProtocolTCP {
-               return errors.Errorf("Connect with file descriptor requires protocol %s", govpn.ProtocolTCP.String())
+               return errors.Errorf(
+                       "Connect with file descriptor requires protocol %s",
+                       govpn.ProtocolTCP.String(),
+               )
        }
        return nil
 }
 
-// LogFields return a logrus compatible logging context
+// LogFields returns a logrus compatible logging context
 func (c *Configuration) LogFields() logrus.Fields {
        const prefix = "client_conf_"
        f := c.Peer.LogFields(prefix)
@@ -103,7 +106,7 @@ type Client struct {
        Error chan error
 }
 
-// LogFields return a logrus compatible logging context
+// LogFields returns a logrus compatible logging context
 func (c *Client) LogFields() logrus.Fields {
        const prefix = "client_"
        f := logrus.Fields{
@@ -142,8 +145,7 @@ func (c *Client) postUpAction() error {
        return errors.Wrap(err, "c.config.Peer.Up")
 }
 
-// KnownPeers return GoVPN peers. Always 1.
-// used to get client statistics.
+// KnownPeers returns GoVPN peers. Always 1. Used to get client statistics.
 func (c *Client) KnownPeers() *govpn.KnownPeers {
        return &c.knownPeers
 }
@@ -170,12 +172,16 @@ func (c *Client) MainCycle() {
                l.Debug("No PreUp to run")
        }
 
-       // if tap wasn't set by PreUp, listen here
+       // if TAP wasn't set by PreUp, listen here
        if c.tap == nil {
                l.WithField("asking", c.config.Peer.Iface).Debug("No interface, try to listen")
                c.tap, err = govpn.TAPListen(c.config.Peer.Iface, c.config.Peer.MTU)
                if err != nil {
-                       c.Error <- errors.Wrapf(err, "govpn.TAPListen inteface:%s mtu:%d", c.config.Peer.Iface, c.config.Peer.MTU)
+                       c.Error <- errors.Wrapf(
+                               err,
+                               "govpn.TAPListen inteface:%s mtu:%d",
+                               c.config.Peer.Iface, c.config.Peer.MTU,
+                       )
                        return
                }
        }
index 9ee1208d9bac3fee97af5cb7b283d9059362f1a3..31d7897711ccc9b9a96ad3ff70b6ea449b72ce4e 100644 (file)
@@ -63,9 +63,16 @@ func (c *Client) proxyTCP() {
        }
        if resp.StatusCode != http.StatusOK {
                govpn.CloseLog(conn, c.logger, c.LogFields())
-               c.Error <- errors.Errorf("Unexpected response from proxy: %s", http.StatusText(resp.StatusCode))
+               c.Error <- errors.Errorf(
+                       "Unexpected response from proxy: %s",
+                       http.StatusText(resp.StatusCode),
+               )
                return
        }
-       c.logger.WithField("func", logFuncPrefix+"Client.proxyTCP").WithFields(c.config.LogFields()).Debug("Proxy connected")
+       c.logger.WithField(
+               "func", logFuncPrefix+"Client.proxyTCP",
+       ).WithFields(
+               c.config.LogFields(),
+       ).Debug("Proxy connected")
        go c.handleTCP(conn)
 }
index 24702f3b6837e3e30a9162ec1c6459adc8f806b9..a4bbcf756cb8aca8e72576f0fa50100dfa0039fc 100644 (file)
@@ -1,6 +1,6 @@
 /*
 GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
index f6530dfe8505b70aaf86e8979472d52d0d26417b..31f9e6e3da7b8dd719db1602bb5dd4a6e0daca66 100644 (file)
@@ -1,6 +1,6 @@
 /*
 GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
index 825a0cf87327d48c10b8e551d24954dde9c49e21..ba7c3b8d8505be2bdb98ccc5d60e91aa8d6224a2 100644 (file)
@@ -1,6 +1,6 @@
 /*
 GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by